Java Design Pattern Essentials - Second Edition

Recommended retail price: £ 19.95 Our price: £ 18.95 each Publisher: Ability First Limited

Paperback (ISBN: 978-09565758-4-5)

For the ebook version on Amazon Kindle click here

  • Java Design Pattern Essentials - Second Edition (available as a paperback book or as a downloadable eBook) will help take your knowledge of the fundamentals of the Java programming language and put it into practice in the real world by learning about Design Patterns.

    Now you too can use the techniques developed by experts over the last couple of decades to solve your programming challenges, through easy to implement solutions to the most common problems that programmers face. Understanding design patterns is essential in being able to write clear, concise and effective code, even for complex applications.

    Java Design Pattern Essentials - Second Edition gives you a step-by-step guide to the world of object-oriented software development, using tried and trusted techniques. The examples and code extracts have been deliberately kept simple, enabling you to concentrate on understanding the concepts and application of each pattern rather than having to wade through irrelevant source code. And the pattern examples have been designed around a common theme, making it easier for you to see how they relate to each other and more importantly how you can adapt them to your applications.

    While the book assumes a basic knowledge of Java you certainly don't need to be a guru. This book is perfect for the programmer who wishes to take their skills up to the next level, so you can feel confident about using Java in real-world applications.

    Coverage includes:

    • All 23 of the design patterns described in the seminal work of Erich Gamma, Richard Helm, Ralph Johnson, John Vlissides; Design Patterns: Elements of Reusable Object-Oriented Software (Addison-Wesley, 1995);
    • Additional patterns for use in real-world applications;
    • Full, simple explanation of the Model-View-Controller (MVC) pattern;
    • Sample 3-tier application applying commonly used patterns;
    • Easy to follow UML diagrams;
    • Advice on how to use the patterns in practice.


    The author has over three decades of software development experience and is a Sun Certified Java Programmer.

  • Table of contents


    Preface to the Second Edition

    Part I: Introduction

    • 1. What are Design Patterns?

    Part II: Creational Patterns

    • 2. Abstract Factory
    • 3. Builder
    • 4. Factory Method
    • 5. Prototype
    • 6. Singleton

    Part III: Structural Patterns

    • 7. Adapter
    • 8. Bridge
    • 9. Composite
    • 10. Decorator
    • 11. Facade
    • 12. Flyweight
    • 13. Proxy

    Part IV: Behavioural Patterns

    • 14. Chain of Responsibility
    • 15. Command
    • 16. Interpreter
    • 17. Iterator
    • 18. Mediator
    • 19. Memento
    • 20. Observer
    • 21. State
    • 22. Strategy
    • 23. Template Method
    • 24. Visitor

    Part V: Other Useful Patterns

    • 25. Null Object
    • 26. Simple Factory
    • 27. Model View Controller
    • 28. Layers

    Part VI: Design Patterns in Practice

    • 29. Sample 3-Tier Application

    Part VII: Appendixes

    • A: UML Diagrams
    • B: Quick Reference
    • C: Bibliography
  • Chapter 1

    • (eBook only): In the toString() method in AbstractVehicle there is a missing quotation mark just before the semi-colon;
    • (paperback page 25 and eBook): The last sentence in point 4 should read - An example pattern that uses this principle is Strategy.;


    Chapter 2

    • (paperback page 30 and eBook): Given that class names should be named in the singular the interface Windows and implementing classes CarWindows and VanWindows would probably be better named as GlasswareCarGlassware and VanGlassware respectively;
    • (paperback page 32 and eBook): In the UML diagram for the Abstract Factory pattern the shaded box on the right should be named VanFactory;


    Chapter 3

    • (paperback page 37 and eBook): In the UML diagram for the Builder pattern the class box on the right of VanClient should be named VanBuilder;


    Chapter 5

    • (eBook only): In the toString() method in AbstractVehicle there is a missing quotation mark just before the semi-colon.


    Chapter 7

    • (paperback page 64 and eBook): The last line of output after using the adapter class should be SuperGreenEngineAdapter (1200) and not SuperGreenEngine (1200).


    Chapter 8

    • (paperback page 71 and eBook): The line of code in the constructor of SportControls should be super(engine);.


    Chapter 10

    • (paperback page 80 and eBook): In the constructor within class AbstractVehicleOption the first line should read super(vehicle.getEngine(), vehicle.getColour()); in order for both the engine and colour attributes to be set.
    • (paperback pages 81-82 and eBook): The constructor names should match the class names.


    Chapter 16

    • (paperback page 119 and eBook): Inside the interpret() method of classMostEasterlyExpression the comparison should be if (currentCity.getLongitude() > resultingCity.getLongitude()).


    Chapter 17

    • (paperback page 126 and eBook): Inside the constructor of the modified version of theVanRange class (toward the end of the chapter) the created Engine instances calledonePointSix and twoLitreTurbo are unused and should be deleted.


    Chapter 20

    • (paperback page 149 and eBook): In subsection An alternative approach using events & listeners the paragraph just before the modified version of SpeedMonitor should read - "TheSpeedMonitor class is our listener and now needs to implement the SpeedometerListenerinterface instead of java.util.Observer".


    Chapter 21

    • (paperback page 155 and eBook): In class MonthSetupState the first statement inside method selectValue() should read - System.out.println("Month set to " + (month + 1));
    • (paperback page 156 and eBook): In class HourSetupState the last statement inside the constructor should read - hour = Calendar.getInstance().get(Calendar.HOUR_OF_DAY);


    Chapter 22

    • (paperback page 163 and eBook): The second constructor in class AbstractCar should specify a second argument defined as Vehicle.Colour colour, and the first statement inside the constructor should be super(engine, colour);
    • (paperback page 163 and eBook): The getGearboxStrategy() method body should be return gearboxStrategy;


    Chapter 29

    • (paperback page 218 and eBook): In class ManageEnginesPanel the statement new BuildEngineDialog(owner),show() uses the deprecated show() method. This should be new BuildEngineDialog(owner).setVisible(true);
    • (paperback page 218 & 219 and eBook):  In class ManageEnginesPanel there are two uses of JOptionPane.showMessageDialog(). In both cases the first argument should be ManageEnginesPanel.this.
  • The source code for the book is hosted on GitHub. You can either view it online or click the Download ZIP button (on the GitHub site) to obtain a copy on your local computer. Please take note of the README file that appears on the page.

    The following link will take you to the hosted source code on GitHub:

    (Please ensure you choose the correct version for your edition of the book)