If, in future, you were only able to use a single one of the canonical patterns defined in the Gang of Four book, which one would you choose and for what reason?
There are 11 behavioral design patterns defined in the GoF design patterns. used to create a template method stub and defer some of the steps of implementation to the subclasses. used to provide a centralized communication medium between different objects in a system.
Explanation: Creational Patterns for the creation of objects; Structural Patterns to provide relationship between objects; and finally, Behavioral Patterns to help define how objects interact. and this does not include user defined, because Java is not a valid classification of designed patterns.
Since its release in 1994, the Design Patterns book continues to be a seminal work in building software. The book created a new shared vocabulary and named these repeated solutions we see all over different codebases.
Not a design pattern, but to me this principle was definitely the most influential on my programming style of the whole book:
Favor object composition over class inheritance.
Combined with the other principle "Program to an interface, not an implementation", most design patterns follow naturally.
Choosing one pattern as the most important is in my opinion impossible. They all have their purpose and complement each other. Its like asking if a hammer or a screwdriver is more useful. It depends on the problem, sometimes you have a nail and sometimes a screw.
Abstract Factory Pattern or Template Method Pattern... but mostly Abstract Factory Pattern. They have just been extremely useful on a lot of situations.
I specially liked the way Abstract Factory allows you to prepare for situations where you know your program may change in the future by following the same rules in a different way.
Is mostly like the Abstract Class allows you to define specs "inside" the code, restrain the code to follow that specs while the factory allows you to "choose" among those specs. Simply beautiful.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With