해당 글은 https://refactoring.guru/design-patterns을 참고하여 번역/작성되었습니다.
디자인 패턴은 흔히 맞닥뜨릴 수 있는 소프트웨어 설계 문제를 해결하는 전형적인 해결 방안(노하우)들을 모아 그 방법에 이름을 붙여 정리한 것입니다.
각 패턴들은 반복적으로 발생하는 구조적인 문제를 사용자 정의하여 해결할 수 있도록 미리 설계된 blueprints와 같습니다.
Design patterns are typical solutions to common problems
in software design. They are like pre-made blueprints that you can customize to solve a recurring design problem in your code.
디자인 패턴과 알고리즘 모두 문제를 해결하는 방법을 제시하는 컨셉은 유사하지만 차이점이 있습니다.
비유를 하자면 알고리즘은 순서가 중요한 요리 레시피와 같고, 디자인 패턴은 결과와 기능이 무엇인지 알 수 있지만 정확한 구현 순서는 사용자에게 달려 있는 blueprint와 비유할 수 있습니다.
Patterns are often confused with algorithms, because both concepts describe typical solutions to some known problems. While an algorithm always defines a clear set of actions that can achieve some goal, a pattern is a more high-level description of a solution. The code of the same pattern applied to two different programs may be different.
패턴들은 각각의 의도와 목적에 따라 크게 3개의 카테고리로 분류할 수 있습니다.
객체 생성을 다루는 매커니즘
효율적이고 유연한 구조를 유지하면서 클래스나 객체를 조합해 더 큰 구조를 만드는 패턴
객체나 클래스 사이의 알고리즘이나 책임 분배에 관련된 패턴
All patterns can be categorized by their intent, or purpose.
- Creational patterns provide object creation mechanisms that increase flexibility and reuse of existing code.
- Structural patterns explain how to assemble objects and classes into larger structures, while keeping the structures flexible and efficient.
- Behavioral patterns take care of effective communication and the assignment of responsibilities between objects.
https://github.com/xiaoyang-sde/typescript-design-pattern