목록Software Design Pattern (19)
Moe's Tech Blog
I was in the task of building software requiring many subtasks. Some of the functions included data analysis, data filtering, data customization, and generation of output. Depending on audiences, the data filtering and data customization may differ. Initially, I attacked the problem using only functions. It resulted in a thousand lines of functions and codes. Even though it worked, it was hard t..

Buildings are composed of rooms Although buildings and rooms have slightly different functions, they are essentially treated as generic housing structures An individual can be entered and exited from a building or a room A building or a room can both be used to store furnitures Despite being unique types of objects, they can be dealt with uniformly Composite Design Pattern Achieves two goals 1. ..

Introduction Thereis a common issue when the pre-existing system needs to incorprate third-party libraries or needs to connect to other systems Adapter design pattern Are frequently used because the output of one system may not conform to the expected input of another system Helps to facilitate communication between two existing systems by providing a compatible interface Adapter Pattern Is comp..

Motivation As system gets larger, code gets more and more complex This can get confusing for the client classes in your system to use System complexity is not always a sign of poor design The scope of problem you are trying to solve is so large it requires a complex solution But client classes prefer a simplier, and easy to use interaction Example 1. Consider a large home has many subsystems (el..
is responsible soely for the wholesale creation of objects It's like outsourcing the creation of objects involving several steps Motivation 1. When object creation logic becomes too convoluted When initialization procedure becomes too complex, wants to move this part of code somewhere 2. Initializer is not descriptive (in python) name is always __init__ cannot overload with same sets of argument..

Design Principle 1. Coupling and Cohesion are the metrics used to evaluate design complexity Coupling focuses on complexities between a module and other modules Cohesion focuses on complexities within a module Help better apply object-oriented design principles achieve more managable system Think of badly designed system like a puzzle You can only connect specific puzzle to another puzzle Think ..

Facilitates communication between other components without them necessarily being aware of each other or having direct (reference) access to each other Motivation for using it is: 1. Some components may go in and out of a system at anytime Example 1. Chat room participants 2. Customers on airplane 3. Players on MMORPG (leave the game, suffer disconnection) 2. Makes no sense for them to have a di..

싱글톤은 프로세스가 실행중에 오직 하나의 오브젝트만 생성 되로록 강제하는 패턴이다 프로그램이 shutdown 될때까지 싱글톤을 없애면 안된다 class Singleton { static instance; constructor() { if (!Singleton.instance) { Singleton.instance = this; } return Singleton.instance; } } 싱글톤 패턴을 사용하는 이유 메모리 절약 하나의 클래스 인스턴스로 수행하기 때문에 일반 클래스보다 사용되는 메모리가 적다 클래스간의 데이터 공유가 쉽다 싱글톤 패턴이 유용할때 병렬 프로그래밍 - 실행과 함께 함수의 작업 진행상태를 보고싶을때 싱글톤 패턴의 문제점 테스트 하기 어렵다 격리된 상황에서 수행되려면 매번 인스턴스의..