I decided to read up on design patterns. However I did not read the Gang of Four (GoF) book. I read Design Patterns for Dummies instead. A design pattern is a solution to a problem. There are 23 standard design patterns. They are documented in the GoF book.
You should not add unneeded layers of abstraction in your design. There is no need to memorize patterns. You must understand object oriented programming (OOP) first. Then you can move on to understand design patterns.
Design patterns make maintenance easier. Inheritance does not handle functionality changes well. Inheritance spreads functionality out over many classes. The “has a” method let’s you switch algorithms at run time. Algorithm is another word for a strategy.
You should employ the Principle of Least Knowledge when designing your classes. Objects should not need to know too much about each other. We call this loose coupling. And loose coupling produces effective encapsulation.
Feel free to create your own design patterns. You should use your pattern in at least three applications before trying to share it with others. This is the Rule of Three in effect. Your homegrown pattern should make solutions easier to create.
Free Laundry
-
Apparently a lot of apartment buildings have coin operated laundry machines
in the basement. And guess what? You can order a key to unlock the payment
me...