Article image Design patterns

29. Design patterns

Page 29 | Listen in audio

29. Design Patterns

Design patterns, also known as Design Patterns, are generalized solutions to common problems in software design and provide a framework for reusable solutions in the context of specific problems. In other words, they are templates that can be used in many different situations.

Origin of Design Patterns

Design patterns were popularized by a group of four authors known as the Gang of Four (GoF). They wrote a book entitled "Design Patterns: Elements of Reusable Object-Oriented Software", which is considered the bible of design patterns. In the book, they introduced 23 design patterns that have become widely accepted and used in the software development community.

Why Use Design Patterns?

Design patterns provide tried-and-true solutions to common problems in software design. They improve developer efficiency by reducing the amount of issues that need to be resolved from scratch. In addition, design patterns promote code reuse and can speed up the development process, improving software quality.

Types of Design Patterns

Design patterns can be categorized into three main types: Creational, Structural, and Behavioral.

Creational Patterns

Creational design patterns deal with object creation mechanisms, trying to design objects appropriately for the situation. The basic creational patterns are: Singleton, Factory, Abstract Factory, Builder, Prototype.

Structural Patterns

Structural design patterns are concerned with the composition of classes or objects. They help ensure that when one part of the system changes, the entire system doesn't have to change with it. The basic structural patterns are: Adapter, Bridge, Composite, Decorator, Facade, Flyweight and Proxy.

Behavioral Patterns

Behavioral design patterns are concerned with communication between objects, how they interact, and allocating responsibilities. They can help increase flexibility in carrying out this communication. The basic behavioral patterns are: Chain of Responsibility, Command, Interpreter, Iterator, Mediator, Memento, Observer, State, Strategy, Template Method and Visitor.

Conclusion

Design patterns are an essential part of object-oriented programming. They provide ready-made solutions that can be adapted to real-world coding problems. Learning these patterns and knowing when and where to apply them can help speed up the development process, improve code quality, and make code easier to understand and maintain.

In our programming logic course, we will explore each of these patterns in detail, showing practical examples of how they can be used in real situations. We'll discuss the advantages and disadvantages of each pattern and provide tips on when it's appropriate to use each one. With a solid understanding of design patterns, you'll be well equipped to tackle any programming challenge you encounter.

Now answer the exercise about the content:

Who popularized design patterns and what book did they write?

You are right! Congratulations, now go to the next page

You missed! Try again.

Article image Code refactoring

Next page of the Free Ebook:

30Code refactoring

3 minutes

Earn your Certificate for this Course for Free! by downloading the Cursa app and reading the ebook there. Available on Google Play or App Store!

Get it on Google Play Get it on App Store

+ 6.5 million
students

Free and Valid
Certificate with QR Code

48 thousand free
exercises

4.8/5 rating in
app stores

Free courses in
video, audio and text