Design Patterns | Classification

May Han·2022년 1월 27일
2

Design Patterns

목록 보기
1/3
post-thumbnail

해당 글은 https://refactoring.guru/design-patterns을 참고하여 번역/작성되었습니다.


What's a design pattern?

디자인 패턴은 흔히 맞닥뜨릴 수 있는 소프트웨어 설계 문제를 해결하는 전형적인 해결 방안(노하우)들을 모아 그 방법에 이름을 붙여 정리한 것입니다.
각 패턴들은 반복적으로 발생하는 구조적인 문제를 사용자 정의하여 해결할 수 있도록 미리 설계된 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.

Additional Description

  • 디자인 패턴은 소프트웨어 설계에 있어 공통적인 문제들에 대한 표준적인 해법과 작명법을 제안
  • 알고리즘과 같이 프로그램 코드로 바로 변환될 수 있는 형태는 아니지만, 특정한 상황에서 구조적인 문제를 해결하는 방식
  • 효율적인 코드를 만들기 위한 방법론




Patterns vs Algorithms

디자인 패턴과 알고리즘 모두 문제를 해결하는 방법을 제시하는 컨셉은 유사하지만 차이점이 있습니다.

  • Algorithm
    알고리즘은 항상 어떤 목표를 달성할 수 있는 명확한 일련의 작업을 정의합니다.
  • Patterns
    디자인 패턴은 해결 방안에 대해 보다 높은 수준의 설명입니다. 만약 동일한 패턴의 코드를 다른 두개의 프로그램에 적용한다면 두개 모두 다른 코드가 필요하게 될 것입니다.

비유를 하자면 알고리즘은 순서가 중요한 요리 레시피와 같고, 디자인 패턴은 결과와 기능이 무엇인지 알 수 있지만 정확한 구현 순서는 사용자에게 달려 있는 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.




Classification of patterns

패턴들은 각각의 의도와 목적에 따라 크게 3개의 카테고리로 분류할 수 있습니다.

1. 생성 패턴 (Creational Patterns)

객체 생성을 다루는 매커니즘

  • 팩토리 메서드 패턴(Factory Method)
  • 추상팩토리 패턴(Abstract Factory)
  • 빌더 패턴(Builder)
  • 싱글톤 패턴(Singleton)
  • 프로토타입 패턴(Prototype)

2. 구조 패턴 (Structural Patterns)

효율적이고 유연한 구조를 유지하면서 클래스나 객체를 조합해 더 큰 구조를 만드는 패턴

  • 적응자 패턴(Adapter or Wrapper)
  • 브리지 패턴(Bridge)
  • 데코레이터 패턴(Decorator)
  • 퍼사드 패턴(Facade)
  • 프록시 패턴(Proxy)
  • Composite

3. 행위 패턴 (Behavioral Patterns)

객체나 클래스 사이의 알고리즘이나 책임 분배에 관련된 패턴

  • 역할 사슬 패턴(Chain of Responsibility)
  • 이터레이터 패턴(Iterator)
  • 옵저버 패턴(Observer)
  • 상태 패턴(State)
  • 전략 패턴(Strategy)
  • 템플릿 패턴(Template Method)
  • 비지터 패턴(Visitor)

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.





Reference

https://github.com/xiaoyang-sde/typescript-design-pattern

https://refactoring.guru/design-patterns

https://coding-factory.tistory.com/708

profile
🚢 크루즈승무원 출신 백엔드 개발자, 기록하는 것을 좋아합니다.

0개의 댓글