0
Design Patterns for 70% of genious programmers Aamir Khan Solution Architect
Design Patterns for 70% of programmers in the world Saurabh Verma Solution Architect  I blog at http://www.domaindrivendes...
Agenda <ul><li>Do you OOPs? </li></ul><ul><li>Design Patterns? Why </li></ul><ul><li>Design Patterns? What </li></ul><ul><...
Normal Classes vs Abstract Classes vs Interfaces Normal Class:  This is a normal class   Abstract Class:  These cannot be...
Million Dollar Question? What is Why?
Normal Class vs Abstract Class? If a particular class is a entity which is not required to be instantiated by the applicat...
Abstract Class vs Interfaces? If a particular class contains any default behavior, go for  Abstract Class If every concret...
MOVIES & ACTORS Shahrukh Khan Salman Khan riding bike Actors in a Movie
IS-A vs HAS-A vs CAN-DO IS-A Inheritance Shahrukh Khan is an ACTOR HAS-A Composition Movie has ACTORS CAN-DO Interfaces Sa...
What is a Pattern <ul><li>An 'element of reusable software’ </li></ul><ul><li>A design pattern systematically names, motiv...
History of Software Patterns
What Wikipedia says, <ul><li>A design pattern is a general repeatable solution to a commonly occurring problem in software...
Let’s understand design patterns by purpose
Let’s understand the purpose + Creational Patterns Structural Patterns Final Product Behavioral Patterns
Let’s understand the purpose
Design Patterns as per their  PURPOSE
Creational Patterns
Factory Method
Factory Method <ul><li>Define an interface for creating an object, but let subclass decide which class to instantiate </li...
Factory Method System.Data.SqlClient.SqlClientFactory
Abstract Factory Pattern
Abstract Factory Pattern <ul><li>Provide an interface for creating families of related or dependent objects without specif...
Abstract Factory Method System.Data.Common.DbProviderFactories
Singleton Pattern
Singleton Pattern <ul><li>Ensure a class has only  one instance, and provide a global point to it. </li></ul><ul><li>Preve...
Singleton Pattern System.Data.SqlClient.SqlClientFactory
Structural Patterns
Façade Pattern
Façade Pattern <ul><li>Provide a unified interface to set of interfaces in a subsystem. </li></ul><ul><li>Is generally one...
Façade Pattern Its all about the service
Decorator Pattern
Decorator Pattern <ul><li>Attach additional responsibilities to an object dynamically. </li></ul><ul><li>Flexible alternat...
Decorator Pattern System.IO.BufferedStream:Stream
Composite Pattern
Composite Pattern <ul><li>Compose objects into tree structures to represent  part-whole hierarchies </li></ul><ul><li>When...
Composite Pattern System.Web.UI.Control   (Render Mechanism)
Composite Pattern
Adapter Pattern
Adapter Pattern <ul><li>Convert the interface of a class into another interface clients expect </li></ul><ul><li>Lets clas...
Adapter Pattern GearsTypelib.HtmlDialogHostClass (Interop.GearsTypelib)
Decorator vs Adapter Decorator looks like Adapter which “decorates” an existing class to make it compatible. Though, Decor...
Decorator vs Façade Façade is a way of hiding a complex system inside a simpler interface, whereas Decorator adds function...
Behavioural Patterns
Command Pattern
Command Pattern <ul><li>Encapsulate a request as an object, thereby letting you parameterize clients with different reques...
Command Pattern System.ComponentModel.Design.MenuCommand
Command Pattern Saurabh.Learning.DesignPatterns.Patterns.CommandPattern
Strategy Pattern
Strategy Pattern <ul><li>Define strategies for a performing a behavior and change them dynamically as per requirement </li...
Strategy Pattern System.Collections.ArrayList
Template Method
Template Method <ul><li>Define the skeleton of an algorithm in an operations, deferring some steps to subclass </li></ul><...
Template Method
Strategy Pattern vs Template Method <ul><li>Strategy allows callers to change the algorithm  or order of steps whereas Tem...
I hate my job
Top 5 ADVICES NOT TO FOLLOW
Reflect when you want  
Answers, anybody?
CONTENT STOLEN FROM   BOOKS: Head First Design Patterns Design Patterns in C# Design Patterns WEBSITES: Wikipedia, MSDN, ...
Learn it all,   at my blog http://www.domaindrivendesign.info Don’t contact  me at, saurabh.net [at] gmail.com Saurabh Ver...
Upcoming SlideShare
Loading in...5
×

Design Patterns For 70% Of Programmers In The World

25,518

Published on

This presentation is for everyone who wants to understand design patterns

For downloading the presentation, visit http://www.domaindrivendesign.info

8 Comments
93 Likes
Statistics
Notes
No Downloads
Views
Total Views
25,518
On Slideshare
0
From Embeds
0
Number of Embeds
25
Actions
Shares
0
Downloads
1,894
Comments
8
Likes
93
Embeds 0
No embeds

No notes for slide
  • Transcript of "Design Patterns For 70% Of Programmers In The World"

    1. 1. Design Patterns for 70% of genious programmers Aamir Khan Solution Architect
    2. 2. Design Patterns for 70% of programmers in the world Saurabh Verma Solution Architect I blog at http://www.domaindrivendesign.info
    3. 3. Agenda <ul><li>Do you OOPs? </li></ul><ul><li>Design Patterns? Why </li></ul><ul><li>Design Patterns? What </li></ul><ul><li>Design Patterns? How </li></ul><ul><li>I hate my job </li></ul>
    4. 4. Normal Classes vs Abstract Classes vs Interfaces Normal Class: This is a normal class  Abstract Class: These cannot be instantiated directly. They may provide partial implementations and exists solely for the purpose of inheritance. Interfaces: Defines a contract. Concrete implementations needs to implement each property and method as per contract. Shut up ! We know all this
    5. 5. Million Dollar Question? What is Why?
    6. 6. Normal Class vs Abstract Class? If a particular class is a entity which is not required to be instantiated by the application directly, go for Abstract Class Employee can be abstract class
    7. 7. Abstract Class vs Interfaces? If a particular class contains any default behavior, go for Abstract Class If every concrete class has its own implementation, go for Interfaces Work – Management, Programming
    8. 8. MOVIES & ACTORS Shahrukh Khan Salman Khan riding bike Actors in a Movie
    9. 9. IS-A vs HAS-A vs CAN-DO IS-A Inheritance Shahrukh Khan is an ACTOR HAS-A Composition Movie has ACTORS CAN-DO Interfaces Salman Khan can DRIVE BIKE IS-A Inheritance Shahrukh Khan is an ACTOR HAS-A Composition Movie has ACTORS CAN-DO Interfaces Salman Khan can DRIVE BIKE
    10. 10. What is a Pattern <ul><li>An 'element of reusable software’ </li></ul><ul><li>A design pattern systematically names, motivates, and explains a general design that addresses a recurring design problem in object-oriented systems. </li></ul><ul><li>It describes the problem, the solution, when to apply the solution, and its consequences. </li></ul><ul><li>It also gives implementation hints and examples. The solution is a general arrangement of objects and classes that solve the problem. The solution is customized and implemented to solve the problem in a particular context. </li></ul>
    11. 11. History of Software Patterns
    12. 12. What Wikipedia says, <ul><li>A design pattern is a general repeatable solution to a commonly occurring problem in software design. </li></ul><ul><li>A design pattern is not a finished design that can be transformed directly into code. </li></ul><ul><li>Algorithms are not thought of as design patterns. </li></ul>
    13. 13. Let’s understand design patterns by purpose
    14. 14. Let’s understand the purpose + Creational Patterns Structural Patterns Final Product Behavioral Patterns
    15. 15. Let’s understand the purpose
    16. 16. Design Patterns as per their PURPOSE
    17. 17. Creational Patterns
    18. 18. Factory Method
    19. 19. Factory Method <ul><li>Define an interface for creating an object, but let subclass decide which class to instantiate </li></ul><ul><li>Prevents creation of any additional instances, while simultaneously allowing global access </li></ul><ul><li>Creation can be delayed until it is actually required </li></ul>
    20. 20. Factory Method System.Data.SqlClient.SqlClientFactory
    21. 21. Abstract Factory Pattern
    22. 22. Abstract Factory Pattern <ul><li>Provide an interface for creating families of related or dependent objects without specifying their concrete classes. </li></ul><ul><li>Provides creation of families of related or dependent objects without specifying their concrete class </li></ul>
    23. 23. Abstract Factory Method System.Data.Common.DbProviderFactories
    24. 24. Singleton Pattern
    25. 25. Singleton Pattern <ul><li>Ensure a class has only one instance, and provide a global point to it. </li></ul><ul><li>Prevents creation of any additional instances, while simultaneously allowing global access </li></ul><ul><li>Creation can be delayed until it is actually required </li></ul>
    26. 26. Singleton Pattern System.Data.SqlClient.SqlClientFactory
    27. 27. Structural Patterns
    28. 28. Façade Pattern
    29. 29. Façade Pattern <ul><li>Provide a unified interface to set of interfaces in a subsystem. </li></ul><ul><li>Is generally one side of the exterior of a building, especially the front </li></ul><ul><li>Origin from a FRENCH word means “face” or “front” </li></ul>
    30. 30. Façade Pattern Its all about the service
    31. 31. Decorator Pattern
    32. 32. Decorator Pattern <ul><li>Attach additional responsibilities to an object dynamically. </li></ul><ul><li>Flexible alternative to subclassing for extending functionality </li></ul><ul><li>Allows dynamic and transparent addition and removal of responsibilities without affecting object </li></ul>simple actress ( act ) in role of modern girl (go out and act ) in role of homely girl (be in home and act )
    33. 33. Decorator Pattern System.IO.BufferedStream:Stream
    34. 34. Composite Pattern
    35. 35. Composite Pattern <ul><li>Compose objects into tree structures to represent part-whole hierarchies </li></ul><ul><li>When dealing with collections of objects, there are often operations that are appropriate for both a single object and the entire collection </li></ul><ul><li>Treats individual objects and composition of objects uniformly </li></ul><ul><li>Example: </li></ul><ul><li>Every object “IS-A” shape </li></ul><ul><li>Every shape “HAS-A” draw behavior </li></ul>
    36. 36. Composite Pattern System.Web.UI.Control (Render Mechanism)
    37. 37. Composite Pattern
    38. 38. Adapter Pattern
    39. 39. Adapter Pattern <ul><li>Convert the interface of a class into another interface clients expect </li></ul><ul><li>Lets classes work together that couldn’t work otherwise </li></ul><ul><li>Works good for making compliance </li></ul>Application Framework Adapter Legacy Component
    40. 40. Adapter Pattern GearsTypelib.HtmlDialogHostClass (Interop.GearsTypelib)
    41. 41. Decorator vs Adapter Decorator looks like Adapter which “decorates” an existing class to make it compatible. Though, Decorator doesn’t wants you to decorate every method in the Adapted class. But who has stopped from doing it. “ Never underestimate the power of a developer”
    42. 42. Decorator vs Façade Façade is a way of hiding a complex system inside a simpler interface, whereas Decorator adds function by wrapping a class.
    43. 43. Behavioural Patterns
    44. 44. Command Pattern
    45. 45. Command Pattern <ul><li>Encapsulate a request as an object, thereby letting you parameterize clients with different requests, queue or log requests. </li></ul><ul><li>If all commands can service a specific request, they can be entertained by the invoker </li></ul><ul><li>Concrete command performs the action on Receiver </li></ul><ul><li>Encapsulate method invocation </li></ul>One Receiver and Multiple actions
    46. 46. Command Pattern System.ComponentModel.Design.MenuCommand
    47. 47. Command Pattern Saurabh.Learning.DesignPatterns.Patterns.CommandPattern
    48. 48. Strategy Pattern
    49. 49. Strategy Pattern <ul><li>Define strategies for a performing a behavior and change them dynamically as per requirement </li></ul><ul><li>This lets the algorithm vary independently from clients that uses it </li></ul><ul><li>It is about choice, which affects outcomes </li></ul>
    50. 50. Strategy Pattern System.Collections.ArrayList
    51. 51. Template Method
    52. 52. Template Method <ul><li>Define the skeleton of an algorithm in an operations, deferring some steps to subclass </li></ul><ul><li>Main algorithm skeleton is defined in a base class and subclasses can then plug in their own details without affecting the algorithm itself </li></ul><ul><li>Uses Inheritance – Abstract Class defines the template (algorithm) and Concrete class manages the implementation. </li></ul><ul><li>Template uses the implementation on demand </li></ul>
    53. 53. Template Method
    54. 54. Strategy Pattern vs Template Method <ul><li>Strategy allows callers to change the algorithm or order of steps whereas Template method allow steps to be modified </li></ul><ul><li>Strategy uses Interfaces whereas Template method uses Inheritance </li></ul>
    55. 55. I hate my job
    56. 56. Top 5 ADVICES NOT TO FOLLOW
    57. 57. Reflect when you want 
    58. 58. Answers, anybody?
    59. 59. CONTENT STOLEN FROM  BOOKS: Head First Design Patterns Design Patterns in C# Design Patterns WEBSITES: Wikipedia, MSDN, doFactory and GOOGLE
    60. 60. Learn it all, at my blog http://www.domaindrivendesign.info Don’t contact me at, saurabh.net [at] gmail.com Saurabh Verma Solution Architect
    1. A particular slide catching your eye?

      Clipping is a handy way to collect important slides you want to go back to later.

    ×