본문 바로가기

디자인 패턴10

3. Strategy Pattern 첫 번째로 알아볼 디자인 패턴은 행위 패턴의 일종인 Strategy Pattern(스트래티지 패턴)입니다. ▣ What is Strategy Pattern? Define a family of algorithms, encapsulate each one, and make them interchangeable. Strategy lets the algorithm vary independently from clients that use it 스트래티지 패턴은 같은 종류의 작업을 하는 알고리즘을 정의하고, 각 알고리즘을 캡슐화하며, 각 알고리즘들을 서로 바꿔 사용할 수 있도록 하는 디자인 패턴입니다. 다시 말해서, 알고리즘을 사용하는 클라이언트로부터 독립적으로 알고리즘을 바꿔서 적용시킬 수 있도록 합니다. 위와 같.. 2023. 10. 29.
2-2. SOLID(S.O.L.I.D) 지난 포스팅에 이어 LSP, ISP, DIP에 대해 알아보도록 하겠습니다. ▣ LSP (Liskov Substitution Principle) Subclasses should be substitutable for their base classes - Robert C.Martin - LSP는 자식 클래스는 부모 클래스를 대체 할 수 있어야 하며, 부모 클래스 객체 대신 자식 클래스를 사용했을 때 문제없이 프로그램이 동작해야한다는 원칙입니다. 정사각형과 직사각형을 생각해볼까요? 정사각형은 직사각형의 일부, 즉 부분집합이라고 생각할 수 있습니다. 즉 아래 그림과 같이 직사각형 클래스를 상속받아 정사각형 클래스를 구현할 수 있습니다. Java 코드를 통해 직사각형 클래스와 정사각형 클래스를 구현해보겠습니다. p.. 2023. 10. 18.
2-1. SOLID(S.O.L.I.D.) ▣ What is "SOLID"? SOLID(S.O.L.I.D.)는 미국의 프로그래머 Robert C. Martin이 2000년에 발표한 논문 "Design Principles and Design Patterns")에서 발표한 5가지의 소프트웨어 설계 원칙입니다. 이해하기 쉽고, 유연하며, 유지 보수가 쉬운 소프트웨어 개발을 위한 원칙들이죠. 그 5가지의 원칙은 아래와 같습니다. - SRP : Single Responsibility Principle (단일 책임 원칙) - OCP : Open-Closed Principle (개방-폐쇄 원칙) - LSP : Liskov Substituion Principle (리스코프 치환 원칙) - ISP : Interface Segregation Principle (인.. 2023. 10. 16.
1. Software Design Pattern ▣ 디자인 패턴(design pattern)이란? 영어 위키백과에 있는 정의를 통해 디자인 패턴의 정의가 무엇인지 알아보겠습니다. In software enginerring, a software design pattern is a general, reusable solution to a commonly ocurring problem within a given context in software design. It is not a finished design that can be transformed directly int source or machine code. Rather, it is a description or template for how to solve a problem that can be .. 2023. 10. 6.