
🌻 Abstract Factory 📝 한 줄 정리 Factory에서 생성 하는 것 : product => product family 로 확장 🤔 해결할 문제 상황 가구샵 시뮬레이터를 만들고 있는 상황을 가정해보자. 다음과 같은 것을 표현할 클래스들이 필요하다. 1. 연관된 가구 품목의 패밀리 : 의자 + 쇼파 + 커피 테이블 2. 해당 패밀리의 여러 variant : 모던 스타일 / 빅토리안 스타일 / 아르데코 스타일 같은 스타일에 매칭되는 개별 가구 객체를 생성할 수 있어야 한다. 그리고 프로그램에 새로운 상품이나 제품군을 추가하려고 할 때 기존 코드를 수정하고 싶지 않다. 🧐 해결 방법 각 제품군에 대한 인터페이스를 명시적으로 선언한다음 각 (스타일의)제품이 해당 인터페이스를 구현하도록 만든다. 그 ..

🌻 ⬇️ https://refactoring.guru/design-patterns/factory-method Factory Method / Design Patterns / Creational Patterns Factory Method Also known as: Virtual Constructor Intent Factory Method is a creational design pattern that provides an interface for creating objects in a superclass, but allows subclasses to alter the type of objec refactoring.guru 📝 한 줄 정리 A.k.a. Virtual Constructor Factory 인터페이..

🦄위키피디아 설명에 따르면 class-based 언어 => 클래스가 먼저 정의되어 있고, 객체는 클래스를 기반으로 인스턴스화 되어 생성된다. 만약 두 객체 "사과", "오렌지"가 과일 클래스의 인스턴스라면 이 둘은 본질적으로 과일이고, 같은 방식으로 핸들링할 수 있음을 보장한다. (개발자는 color, sugar_content, is_ripe 같은 동일한 attribute를 가지고 있음을 예상할 수 있다) prototype-based 언어 => 객체가 primary entity 이다. 클래스는 존재하지 않음 (그래도 자바스크립트 es6에 클래스 키워드는 있음. 내부적으로 class-based 언어의 클래스와 완전 동일하게 동작한다고 말할 수는 없지만) 어떤 객체의 프로토타입은 해당 객체가 연결되어 있는 ..

🐶prototype Prototype / Design Patterns / Creational Patterns Prototype Also known as: Clone Intent Prototype is a creational design pattern that lets you copy existing objects without making your code dependent on their classes. Problem Say you have an object, and you want to refactoring.guru 📝한 줄 정리 클라이언트 코드에서는 클래스를 신경 쓸 필요 없이 객체에 내장된 clone 인스턴스 메소드를 호출하여 해당 객체를 손쉽게 클론한다. clone 메소드 동작 방식 : 자기 클..

디자인 패턴 관련한 엄청 좋은 사이트를 발견했다. 이제 여기 게시글을 한개씩 정리하면서 미뤄왔던 디자인 패턴 공부를 해봐야겠다. 💪🤔 👾singleton Singleton Real-World Analogy The government is an excellent example of the Singleton pattern. A country can have only one official government. Regardless of the personal identities of the individuals who form governments, the title, “The Government of X”, is a g refactoring.guru 📝한 줄 정리 어느 코드 영역에서든지 이 클래스에 대해 유..