Software design pattern – definition

It is a documented best practice or core of a solution that has been applied successfully in multiple environments to solve a recurring problem.

Diffences btw Design Pattern (DP) and Framework are

  • DP is a recurring solutions to problems, FW is a group of component cooperating with each other to provide a reusable architecture for app with a given domain

Here are some common types of DP:

  • Basic (7):

    The most common and important ones that can be found everywhere in OOP and Programming

    1. Interface:
      Use to design a set of service provider classes that offer same service so that client obj can use different classes of service provider objects in a seamless manner without having to alter the client implementation.
      Example: UserNotification from MySQL or XML service
      Modem and FTP protocol
    2. Abstract parent class
      Use to design a framework for the consistent implementation of the functionality common to a set of related classes
    3. Private method
      Only for internal use, outside object cannot accesc
    4. Accesor method
      Method allow client objects (outside) access states (or properties) of an object. Prevent to access states directly so resulting in more maintainable class structure. Useful for validate data
    5. Constant Data manager
      Useful for design an centralized repository for the constant data in an application
    6. Immutable Object
      The object that has its state unchangeable, so that concurrent access to a data object by several client obj not result in race condition. To achive that, just declare the Properties and Class “final“. If have reference instance variable, return a copy of the obj, but not actual object. (Maybe problems, need decide carefully)
    7. Monitor
      To design an object so that it does not produce unpredictable results when more than one thread tries to access the object at the same time in a multithreaded environment. (use synchronize keywords in JAVA)
  • Creational (5)
    1. Factory method
    2. Singleton
    3. Abstract Factory
    4. Prototype
    5. Builder
  • Collectional (4)
    1. Composite
    2. Iterator
    3. Flyweight
    4. Visitor
  • Structural (11)
    1. Decorator
    2. Adapter
    3. Chain of Responsibility
    4. Facade
    5. Proxy
    6. Bridge
    7. Virtual proxy
    8. Counting proxy
    9. Aggregate Enforcer
    10. Explicit Obj Release
    11. Object Cache
  • Behavioral (11)
    • Command
    • Mediator
    • Memento
    • Observer
    • Interpreter
    • State
    • Strategy
    • Null Obj
    • Template Method
    • Object Auth
    • Common Attribute Registry
  • Concurrency
    • Critical section
    • Consisten lock order
    • guarded suspension
    • Read-write lock

Leave a Reply

Your email address will not be published. Required fields are marked *