Join Jungwoo Ryoo for an in-depth discussion in this video What is a design pattern?, part of Python: Advanced Design Patterns.
- [Narrator] Have you ever wished if someone else already developed a solution to your programming problem? If you have, you are not alone. In fact, there are communities of people out there, as you can see on this website, who are devoting a significant part of their professional careers to helping you more effectively reuse software design solutions called patterns. Design patterns are well-known and documented solutions to recurring challenges in an object-oriented programming environment.
There are three different types of design patterns, creational, structural, and behavioral. Creational patterns are useful when you need to create an object or objects for a specific purpose. For example, there is a situation in which you need to restrict a number of objects extentiated from the same class. In this case, you don't need to look too far for a solution.
There is a design pattern called singleton which many other programmers have already tried out and recommended. There are also code examples available in many languages, including Python. You may simply be able to modify the code a little to incorporate it into your project. This example clearly demonstrates the power of using design patterns. There are also other creational patterns such as factory, abstract factory, builder, and prototype.
Structural design patterns cover various ways to assemble classes and their instances. Examples of structural patterns are decorator, proxy, adaptor, composite, and bridge. Finally, behavioral patterns are common solutions to programming problems occurring when trying to effectively regulate communication among objects.
Major behavioral patterns include observer, visitor, iterator, strategy, and chain of responsibility. If any of the things I have talked about so far are new to you, I strongly recommend that you take my earlier course Python Design Patterns, otherwise, let's continue on with our journey into the advanced Python design patterns.
- Architectural vs. design patterns
- Why use design patterns?
- Design best practices
- Domain-specific patterns and security patterns
- Gang of Four design patterns
- Command, Mediator, and State
- Template method