0. introduction to design patterns

yongduk kim·2024년 1월 30일

designPattern

목록 보기
1/1

the purpose of design pattern


  1. to reuse solution already solved
  2. facilitate communication
  3. for making more flexible and reusable design

the definition of design pattern(example: iterator patterns)


A solution to a problem in a context

  • context: recurring situation in which pattern applies
    • ex: collection of objects
  • problem: constraint to acheive the goal, or goal itself
    • ex: not exposing implementation of collection but need to step through object
  • solution: what do you after about problem
    • Structure of component and relationship
    • run-time mechanism
    • ex: encapsulate iterator to separate class - make iterator to interface
      • give resposibility to collection to make new concrete class that implementation iterator interface

collection: like array, list, set, queue, map…. can contain many element in itself

category of GoF Patterns


  • purpose:
    • Creational: related to address creating object or class
    • Structural: related to construct of relation(class and object)
    • Behavioral: related to responsibilities and communication
  • Scope:
    • Class: related to class and usely solve problem with inheritance
    • Object: related to instance and usely solve porblem with “composition”
      • composition: one class has another classes in body and delegate some functions to them

design pattern’s key feature(7 keywords)

  • Bridge

keyword: intent, problem, solution, participants and collaborators, consequence, implementation, generic structure

  • intent: purpose
  • problem: pattern trying to solve
  • solution: not absstract description, emphasizes component’s relationship, responsibilities and collaborations
  • participants and collaborators: entities involved in the pattern
  • consequences: pros and cons of using pattern in point of reusability, portability, extensibility
  • implementation: how pattern can be implemented
    • it should not be considered as the pattern itself, it was just concrete manifestations of the pattern
  • generic structure: standard diagram

component: service unit, have some feature

  • independent, minimize dependency, interface, reuse, looe coupling

hierarchy of pattern knowledge


  1. basic: basic concept or knowledge about software

    ex: abstraction, inheritance, oop concept

  2. principles: guildline or general rule of design

    ex: soild(SRP, OCP, LSP, ISP, DIP) principle, DRY(Don't Repeat Yourself) principle, SRP

  3. pattern: Strategy pattern, a solution to a problem in a context, based on principles and basic, used to improve design of software

level of patterns[POSA - pattern oriented software archtecture]


  1. Architectural pattern

    1. overall based structure and organization
    2. provide predefined subsystem, define their responsibility, rules and guildlines for organizing relationshiip between them
    3. pattern for system structure

    ex. MVC pattern

  2. Design pattern

    1. refine subsystem or components or relationships between them
    2. not affect to overall structure, pattern for component that in the system.

    ex. observer pattern

  3. Coding pattern

    1. specific to a programming language
    2. how to implement particular aspect of components or relationship in given language

summary


Software pattern and pattern history

Design pattern categories

  • creational, structural, behavior

Benefit of patterns

  • reusable
  • communication

Levels of pattern

  • Architectural, design, coding
profile
기록과 함께하는 백엔드 개발

0개의 댓글