https://abs.twimg.com/emoji/v2/... draggable="false" alt="❓" title="Rotes Fragezeichen-Symbol" aria-label="Emoji: Rotes Fragezeichen-Symbol"> What are design patterns?

Design patterns emerged (roughly) 30 years ago.

And yet, many people believe they are as relevant today as they& #39;ve always been.

A thread https://abs.twimg.com/emoji/v2/... draggable="false" alt="🧵" title="Thread" aria-label="Emoji: Thread"> about design patterns. https://abs.twimg.com/emoji/v2/... draggable="false" alt="👇" title="Rückhand Zeigefinger nach unten" aria-label="Emoji: Rückhand Zeigefinger nach unten">
https://abs.twimg.com/emoji/v2/... draggable="false" alt="❓" title="Rotes Fragezeichen-Symbol" aria-label="Emoji: Rotes Fragezeichen-Symbol"> First, what is "design"?

This thread is about software design, not UI design.

Everything in the code is design. From details such as variable names to more architectural issues.

https://abs.twimg.com/emoji/v2/... draggable="false" alt="🔑" title="Schlüssel" aria-label="Emoji: Schlüssel"> Design is the shape that the system takes to meet its requirements.
https://abs.twimg.com/emoji/v2/... draggable="false" alt="📔" title="Notizbuch mit verziertem Umschlag" aria-label="Emoji: Notizbuch mit verziertem Umschlag"> A design pattern:

https://abs.twimg.com/emoji/v2/... draggable="false" alt="🔹" title="Kleine blaue Raute" aria-label="Emoji: Kleine blaue Raute"> Describes a design solution to a problem that occurs repeatedly.

https://abs.twimg.com/emoji/v2/... draggable="false" alt="🔹" title="Kleine blaue Raute" aria-label="Emoji: Kleine blaue Raute"> Describes the elements (e.g. objects) that make up the solution and their relationships.

https://abs.twimg.com/emoji/v2/... draggable="false" alt="🔹" title="Kleine blaue Raute" aria-label="Emoji: Kleine blaue Raute"> Explains the trade-offs of using the pattern.

https://abs.twimg.com/emoji/v2/... draggable="false" alt="🔹" title="Kleine blaue Raute" aria-label="Emoji: Kleine blaue Raute">Captures experience of skilled designers.
There are others, but you can find the most famous patterns in the book:

https://abs.twimg.com/emoji/v2/... draggable="false" alt="➡️" title="Pfeil nach rechts" aria-label="Emoji: Pfeil nach rechts"> "Design Patterns: Elements of Reusable Object-Oriented Software" [GoF book].

Examples: facade, adapter, command, ...

https://abs.twimg.com/emoji/v2/... draggable="false" alt="❓" title="Rotes Fragezeichen-Symbol" aria-label="Emoji: Rotes Fragezeichen-Symbol"> What are the main advantages of design patterns?

Let& #39;s talk about 4 of them. https://abs.twimg.com/emoji/v2/... draggable="false" alt="👇" title="Rückhand Zeigefinger nach unten" aria-label="Emoji: Rückhand Zeigefinger nach unten">
https://abs.twimg.com/emoji/v2/... draggable="false" alt="1⃣" title="Tastenkappe Ziffer 1" aria-label="Emoji: Tastenkappe Ziffer 1"> They give us vocabulary to talk about design.

In a team familiar with patterns, design discussions become very productive.

Can you imagine an architect that doesn& #39;t use "room patterns" such as bedroom or kitchen?

Patterns allow you to pack a lot of info in short sentences.
https://abs.twimg.com/emoji/v2/... draggable="false" alt="2⃣" title="Tastenkappe Ziffer 2" aria-label="Emoji: Tastenkappe Ziffer 2"> Design patterns can be seen as examples that show good design principles in action.

For instance, the "State" pattern shows how the "Open-Closed Principle" makes the addition of new states easier.

https://abs.twimg.com/emoji/v2/... draggable="false" alt="📔" title="Notizbuch mit verziertem Umschlag" aria-label="Emoji: Notizbuch mit verziertem Umschlag"> If you study design patterns, you will gain invaluable design knowledge.
https://abs.twimg.com/emoji/v2/... draggable="false" alt="3⃣" title="Tastenkappe Ziffer 3" aria-label="Emoji: Tastenkappe Ziffer 3"> Design patterns can give us refactoring targets.

We must avoid overengineering and follow the rules of simple design, refactoring continuously.

When a pattern solves a *real* problem that we have, then we can use the pattern as a guide in the refactoring process.
https://abs.twimg.com/emoji/v2/... draggable="false" alt="4⃣" title="Tastenkappe Ziffer 4" aria-label="Emoji: Tastenkappe Ziffer 4"> Design patterns can improve the readability of your code.

If the patterns are obvious in our code (that is, if the code *evokes* the patterns, whether using the pattern names or not), then the readers that know the patterns will easily understand our intent.
You can follow @macerub.
Tip: mention @twtextapp on a Twitter thread with the keyword “unroll” to get a link to it.

Latest Threads Unrolled: