2017년 1월 28일 토요일

Design Patterns

1. Design Patterns
 - describes a problem which frequently occurs in our environment, and then describes the core of the solution to the problem
 - a way of reusing abstract knowledge about a problem and its solution
 - Different types of Patterns
  * Creational patterns: the process of object construction and the instantiation process
   e.g. Singleton pattern / Abstract pattern / Factory Method pattern
  * Structural patterns: Composition of classes/objects: how classes and objects are composed to form larger structures
   e.g. Adapter pattern: when an existing class performs the services that a client needs but has different method names
        Composite pattern: compose objects (Component interface) into tree structures to represent part-whole (Leaf-Composite class) hierarchies
        Decorator pattern
  * Behavioural patterns: the way classes and objects interact/patterns of communication between class
   e.g. Iterator pattern / Observer pattern

https://www.tutorialspoint.com/design_pattern/design_pattern_overview.htm

http://www.oodesign.com/adapter-pattern.html

http://www.oodesign.com/composite-pattern.html

2. Observer Pattern
 : defines a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically
 - Subject: the object which will frequently change its state and upon which other objects depend
  * Keep track of its observers. Any number of Observer objects may observe a subject
  * Provides an interface for attaching/detaching an observer
 - Observer: the object which depends on a subject and updates according to its subject's state
  * An updating interface for objects that gets notified of changes in a subject

 (+) Minimal coupling between the Subject and the Observer
 (+) Liability: possible cascading of notifications

 - Implementing Issues
  * Make sure the subject updates its state before sending out notifications

https://www.tutorialspoint.com/design_pattern/observer_pattern.htm

댓글 없음:

댓글 쓰기