본문 바로가기

분류 전체보기185

[디자인패턴] Adapter pattern (어댑터 패턴) Purpose of Adapter Pattern (어댑터 패턴의 목적) aka) Wrapper - Permits classes with different interfaces to work together by creating a common object by which they may communicate and interact. - 서로 다른 인터페이스를 가진 클래스가 통신하고 상호 작용할 수 있는 공통 개체를 만들어 함께 작동하도록 Adapter pattern (어댑터 패턴) - Converts the interface of a class into another interface clients expect. - 클래스의 인터페이스를 클라이언트가 기대하는 다른 인터페이스로 변환 - Mechanism →.. 2022. 8. 28.
[디자인패턴] Decorator pattern (데코레이터 패턴) Purpose of Decorator Pattern (데코레이터 패턴의 목적) - Allows for the dynamic wrapping of objects in order to modify their existing responsibilities and behaviors. - 객체를 동적으로 래핑하여 기존 책임과 동작을 수정할 수 있습니다. Design Principle (디자인원칙) - OCP (Open-Closed Principle) : easily extended to incorporate new behavior without modifying existing code Decorator pattern (데코레이터 패턴) - decoration은 '장식(포장)'이란 뜻 - The Decorator.. 2022. 8. 28.
[디자인패턴] Singleton pattern (싱글톤 패턴) Singleton Pattern (싱글톤 패턴) - Ensures that only one instance of a class is allowed within a system. - multi-threaded issue해결을 위해, 시스템 내에서 클래스의 인스턴스 하나만 허용 → instance는 외부에서 바꿀 수 없게 private으로 선언 →public static으로 제공 uniqueInstace를 null check 후, 없을 때만 생성해서 return → '하나'의 인스턴스만 생성하여, 한 번만 메모리에 올리고 사용하는 디자인 패턴 → 인스턴스가 필요할 때, 똑같은 인스턴스를 만들지 않고 기존의 인스턴스를 활용 → 단점: 싱글톤 인스턴스가 혼자 너무 많은 일을 하거나, 많은 데이터를 공유시키면 다.. 2022. 8. 28.
[디자인패턴] Builder pattern (빌더 패턴) Purpose of Builder Pattern (빌더 패턴의 목적) - Allows for the dynamic creation of objects based upon easily interchangeable algorithms. - 쉽게 교환할 수 있는 알고리즘을 기반으로 개체를 동적으로 만들 수 있다. Builder pattern (빌더 패턴) - 생성 패턴의 한 종류로 전략 패턴의 특화된 형태 - Composite는 Builder가 만드는 것 - Director와 Builder 구조 → Director knows what parts are needed for the final product. (Director는 어떤 부품이 필요한지 알고 있고) → Concrete builder knows how .. 2022. 8. 28.
[디자인패턴] Factory Method Pattern & Abstract Factory Pattern (팩토리 메서드 패턴 & 추상 팩토리 패턴) Purpose of Creational patterns (생성 패턴의 목적) - Allow to creating new objects without explicitly using the new operator. - 새 연산자를 명시적으로 사용하지 않고 새 개체를 만들 수 있도록 허용 - Factory Method Pattern은 하위 클래스가 실제로 creation을 할지 결정하도록 하는 패턴이기도 함 - Abstract Factory Method Pattern은 객체들을 만드는 인터페이스를 구체적인 클래스에 대해 특정하지 않은 채로 제공 Design Principle (디자인원칙) - DIP : Dependency Inversion Principle → Depend upon abstractions. D.. 2022. 8. 28.
[디자인패턴] Mediator pattern (중재자 패턴) Purpose of Mediator Pattern (중재자 패턴의 목적) - Allows loose coupling by encapsulating the way disparate sets of objects interact and communicate with each other. - 상호 작용하고 통신하는 방식을 캡슐화하는 것으로 그 개체 집합 사이에서 컨트롤 타워(관제탑) 같은 역할을 함 Mediator pattern (중재자 패턴) - mediator는 '중재자', '조정자', '중개인'이란 뜻 - Encapsulates interconnects between objects into Mediator : 연결을 Mediator로 캡슐화 - Promotes loose coupling between cl.. 2022. 8. 28.
[디자인패턴] State pattern (상태 패턴) Purpose of State Pattern (상태 패턴의 목적) - Ties object circumstances to its behavior, allowing the object to behave in different ways based upon its internal state. - 내부 상태에 따라 다르게 동작할 수 있도록! Design Principle (디자인원칙) - OCP : Open-Closed Principle State pattern (상태 패턴) - Define a State interface that contains a method for every action. - Get rid of all of our conditional code and instead delegate to .. 2022. 8. 28.
[디자인패턴] Iterator pattern (반복자 패턴) Purpose of Iterator Pattern (반복자 패턴의 목적) aka) Cursor - Allows for access to the elements of an aggregate object without allowing access to its underlying representation. - 외부에 노출 없이, 자료형 관계없이, collection에서 객체를 꺼낼 때 사용 Design Principle (디자인원칙) - Single Responsibility Principle (단일 책임의 원칙) - A class should have only one reason to change * Aggregate and Iteration – two different responsibilities * .. 2022. 8. 28.
[디자인패턴] Template method pattern (템플릿 메소드 패턴) Purpose of Template method Pattern (템플릿 메소드 패턴의 목적) - Identifies the framework of an algorithm, allowing implementing classes to define the actual behavior. - 실제 동작을 정의하기 위해 클래스를 구현할 수 있도록 알고리즘의 프레임워크 구성하는 데 사용 Design Principle (디자인원칙) - Hollywood Principle : Don't call us, we'll call you - High level component --call--> low-level component → "프레임워크(framework)에서 흔히 적용되는 설계원칙으로, 저수준(low-level) 구성.. 2022. 8. 28.