Design Patterns Shailesh Kumar S
Agenda Structural Design Patterns: Adapter Decorator Bridge Facade
Structural Patterns What? Defines composition between entities to build larger systems. Why? Helps in understanding the relationship between classes and objects. How? By using following Patterns: Adapter, Facade, Bridge, Decorator, etc.
Adapter Pattern What? Translate one interface of a class into a compatible interface. Why? And old legacy class needs to be reused, but its interface is different than application expects .
Example 1: Example 2:
Decorator Pattern What? Defines attaching new responsibility to the object dynamically. Why? Helps in wrapping an existing object with another object with out breaking the interface or other objects.
Example 1: Example 2:
Bridge Pattern What? Separates objects interface and its implementation. Why? Both abstraction and implementation can vary independently. Avoiding hard binding between abstraction and implementation. Reduce number of sub classes and this reduction in code size.
Example:  House electrical equipment and switch Text file storage and representation across operating systems.
Facade Pattern What? An Higher level interface to a complex sub-system to simplify communication. Why? Re-structuring a complex system into less complex sub-systems Reduce dependencies between sub-systems .
Example: Client Object 1 Client Object 2 Client objects Sub-systems objects Ordering  System Billing System Query System Client Object 3
With Facade Pattern: Example:  Customer Service Support system Library Management system Client objects Sub-system objects Facade Client Object 2 Client Object 1 Client Object 3 Billing System Ordering  System
When to choose what: Adapter:  You want to use an existing class, and its interface does not match the one you need. Decorator: When you want to enhance the responsibilities of an object. When extension for an object via sub-classing is complex/tedious. Bridge: Only applied before the classes are designed. When both side of the interfaces can vary independently.
Facade: When you want to define new interface for a group of objects with out adding new functionality. When you want to represent 1 object for a group of objects to simplify communication.
Questions?

My design patterns

  • 1.
  • 2.
    Agenda Structural DesignPatterns: Adapter Decorator Bridge Facade
  • 3.
    Structural Patterns What?Defines composition between entities to build larger systems. Why? Helps in understanding the relationship between classes and objects. How? By using following Patterns: Adapter, Facade, Bridge, Decorator, etc.
  • 4.
    Adapter Pattern What?Translate one interface of a class into a compatible interface. Why? And old legacy class needs to be reused, but its interface is different than application expects .
  • 5.
  • 6.
    Decorator Pattern What?Defines attaching new responsibility to the object dynamically. Why? Helps in wrapping an existing object with another object with out breaking the interface or other objects.
  • 7.
  • 8.
    Bridge Pattern What?Separates objects interface and its implementation. Why? Both abstraction and implementation can vary independently. Avoiding hard binding between abstraction and implementation. Reduce number of sub classes and this reduction in code size.
  • 9.
    Example: Houseelectrical equipment and switch Text file storage and representation across operating systems.
  • 10.
    Facade Pattern What?An Higher level interface to a complex sub-system to simplify communication. Why? Re-structuring a complex system into less complex sub-systems Reduce dependencies between sub-systems .
  • 11.
    Example: Client Object1 Client Object 2 Client objects Sub-systems objects Ordering System Billing System Query System Client Object 3
  • 12.
    With Facade Pattern:Example: Customer Service Support system Library Management system Client objects Sub-system objects Facade Client Object 2 Client Object 1 Client Object 3 Billing System Ordering System
  • 13.
    When to choosewhat: Adapter: You want to use an existing class, and its interface does not match the one you need. Decorator: When you want to enhance the responsibilities of an object. When extension for an object via sub-classing is complex/tedious. Bridge: Only applied before the classes are designed. When both side of the interfaces can vary independently.
  • 14.
    Facade: When youwant to define new interface for a group of objects with out adding new functionality. When you want to represent 1 object for a group of objects to simplify communication.
  • 15.