Successfully reported this slideshow.
Design Patterns <ul><li>Shailesh Kumar S </li></ul>
Agenda <ul><li>Structural Design Patterns: </li></ul><ul><ul><li>Adapter </li></ul></ul><ul><ul><li>Decorator </li></ul></...
Structural Patterns <ul><li>What? </li></ul><ul><ul><li>Defines composition between entities to build larger systems. </li...
Adapter Pattern <ul><li>What? </li></ul><ul><ul><li>Translate one interface of a class into a compatible interface. </li><...
<ul><ul><li>Example 1: </li></ul></ul><ul><ul><li>Example 2: </li></ul></ul>
Decorator Pattern <ul><li>What? </li></ul><ul><ul><li>Defines attaching new responsibility to the object dynamically. </li...
<ul><li>Example 1: </li></ul><ul><li>Example 2: </li></ul>
Bridge Pattern <ul><li>What? </li></ul><ul><ul><li>Separates objects interface and its implementation. </li></ul></ul><ul>...
<ul><li>Example:  </li></ul><ul><ul><li>House electrical equipment and switch </li></ul></ul><ul><ul><li>Text file storage...
Facade Pattern <ul><li>What? </li></ul><ul><ul><li>An Higher level interface to a complex sub-system to simplify communica...
<ul><li>Example: </li></ul>Client Object 1 Client Object 2 Client objects Sub-systems objects Ordering  System Billing Sys...
<ul><li>With Facade Pattern: </li></ul><ul><li>Example:  </li></ul><ul><li>Customer Service Support system </li></ul><ul><...
<ul><li>When to choose what: </li></ul><ul><li>Adapter:  </li></ul><ul><li>You want to use an existing class, and its inte...
<ul><li>Facade: </li></ul><ul><li>When you want to define new interface for a group of objects with out adding new functio...
<ul><li>Questions? </li></ul>
Upcoming SlideShare
Loading in …5
×

My design patterns

2,733 views

Published on

I presented my understanding on few design patterns to my team @ex employer. They liked it coz of its simplicity and crips and clear.

  • Be the first to comment

  • Be the first to like this

My design patterns

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

×