Learn the rationale for design patterns in Java. Learn about 23 GoF (Gang of Four) patterns.
Design patterns in software engineering began with publication of the book Design Patterns: Elements of Reusable Object-Oriented Software by Erich Gamma, Richard Helm, Ralph Johnson and John Vlissides in 1984, collectively known as the Gang of Four. According to these authors, design patterns are software templates for recurring problems that software engineers frequently encounter. The authors recommend several software engineering principals including: program to an interface, not to an implementation and favor object composition over class inheritance.
The authors refer to inheritance as white-box reuse because the internals of the parent classes are visible to the subclasses. In contrast, the authors refer to object composition as black-box reuse because no internal details of composed objects need to be visible. The authors state that because inheritance exposes a subclass to details of its parent's implementation, it's often said that inheritance breaks encapsulation.
The authors admit that delegation and parameterization are very powerful but add a warning. Dynamic, highly parameterized software is harder to understand and build than more static software. There are three categories of design patterns: creational, structural and behavioral. Creational patterns are ones that create objects for you, rather than having you instantiate objects directly. This gives your program more flexibility in deciding which objects need to be created for a given case.
Structural patterns concern class and object composition. They use inheritance to compose interfaces and define ways to compose objects to obtain new functionality. Behavioral design patterns are concerned with communications between objects. The use of design patterns has both proponents and detractors. There are at least two circumstances where you should be familiar with design patterns: you work in an organization that uses design patterns or you're preparing for a job interview where job description say that knowledge of design patterns is required.
In the remainder of this chapter, we examine how to implement three design patterns using Java.
- The IMQAV model
- Downloading software
- Installing and setting up a Java coding environment
- Mock tests
- Code coverage
- Using windows, views, and modes in IntelliJ IDEA
- Creating classes and attributes
- Creating constructors
- Casting variables
- Matching literals with regular expressions
- Regular expressions
- Design patterns
Skill Level Intermediate
Java: Database Integration with JDBCwith David Gassner2h 51m Intermediate
NumPy Data Science Essential Trainingwith Charles Kelly3h 54m Intermediate
1. Getting Started with Java
2. Test-Driven Development
3. IntelliJ IDEA
4. Object-Oriented Java
6. Regular Expressions (Regex)
8. Design Patterns
9. Applying Data Science
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.