Diese Präsentation wurde erfolgreich gemeldet.
Wir verwenden Ihre LinkedIn Profilangaben und Informationen zu Ihren Aktivitäten, um Anzeigen zu personalisieren und Ihnen relevantere Inhalte anzuzeigen. Sie können Ihre Anzeigeneinstellungen jederzeit ändern.

Software Engineering - chp4- design patterns

8.344 Aufrufe

Veröffentlicht am

Software Design patterns

Veröffentlicht in: Technologie
  • Thanks for the previous comments. www.HelpWriting.net helped me too
       Antworten 
    Sind Sie sicher, dass Sie …  Ja  Nein
    Ihre Nachricht erscheint hier
  • heloo chpter 5 is not found
       Antworten 
    Sind Sie sicher, dass Sie …  Ja  Nein
    Ihre Nachricht erscheint hier
  • Have u ever tried external professional writing services like ⇒ www.HelpWriting.net ⇐ ? I did and I am more than satisfied.
       Antworten 
    Sind Sie sicher, dass Sie …  Ja  Nein
    Ihre Nachricht erscheint hier
  • You can ask here for a help. They helped me a lot an i`m highly satisfied with quality of work done. I can promise you 100% un-plagiarized text and good experts there. Use with pleasure! ⇒ www.WritePaper.info ⇐
       Antworten 
    Sind Sie sicher, dass Sie …  Ja  Nein
    Ihre Nachricht erscheint hier
  • I think you need a perfect and 100% unique academic essays papers have a look once this site i hope you will get valuable papers, ⇒ www.HelpWriting.net ⇐
       Antworten 
    Sind Sie sicher, dass Sie …  Ja  Nein
    Ihre Nachricht erscheint hier

Software Engineering - chp4- design patterns

  1. 1. MedTech Chapter 4 – Design Patterns Known Patterns and Design and Implementation Examples Dr. Lilia SFAXI www.liliasfaxi.wix.com/liliasfaxi Slide 1 MedTech – Mediterranean Institute of Technology Software Engineering MedTech
  2. 2. MedTech DESIGN PATTERNS: DEFINITION AND UTILITY Design Patterns Dr. Lilia SFAXI www.liliasfaxi.wix.com/liliasfaxi Slide 2
  3. 3. MedTech Design Patterns • In software engineering, a design pattern is a general repeatable solution to a commonly occuring problem in software design • It isn’t a finished design that can be transformed directly into code, but a description or template for how to solve a problem that can be used in many different situations Dr. Lilia SFAXI www.liliasfaxi.wix.com/liliasfaxi Slide 3 Design Patterns: Definition and Utility
  4. 4. MedTech Design Patterns: Usage • Design patterns: • Provide general solutions, documented in a format that doesn’t require specifics tied to a particular problem • Can speed up the development process by providing tested, proven development paradigms • Help you benefit from the experience of fellow developers • Prevent subtle issues that can cause major problems • Improve code readability for coders and architects familiar with them Dr. Lilia SFAXI www.liliasfaxi.wix.com/liliasfaxi Slide 4 Design Patterns: Definition and Utility
  5. 5. MedTech Design Patterns: Essential Elements • A pattern has four essential elements: • The pattern name that we use to describe a design problem • The problem that describes when to apply the pattern • The solution that describes the elements that make up the design • The consequences that are the results and trade-offs of applying the pattern Dr. Lilia SFAXI www.liliasfaxi.wix.com/liliasfaxi Slide 5 Design Patterns: Definition and Utility
  6. 6. MedTech GoF Design Patterns Dr. Lilia SFAXI www.liliasfaxi.wix.com/liliasfaxi Slide 6 Design Patterns: Definition and Utility • The Gang of Four are the four authors of the book « Design Patterns: Elements of Reusable Object-Oriented Software » • Defined 23 design patterns for recurrent design issues, called GoF design patterns • Classified by purpose: • Structural : Concerns the composition of classes and objects • Behavioral : Characterizes the interaction and responsibility of objects and classes • Creational : Concerns the creation process of objects and classes • … and by scope: • Class scope: relationship between classes and subclasses, defined statically • Object scope: object relationships, dynamic
  7. 7. MedTech GoF Design Patterns Dr. Lilia SFAXI www.liliasfaxi.wix.com/liliasfaxi Slide 7 Design Patterns: Definition and Utility
  8. 8. MedTech CREATIONAL PATTERNS Design Patterns Dr. Lilia SFAXI www.liliasfaxi.wix.com/liliasfaxi Slide 8
  9. 9. MedTech Creational Patterns: Definition • Creational patterns abstract the instantiation process. • They help to make a system independent of how its objects are created, composed, and represented • Creational patterns for classes use inheritance to vary the class that is instantiated. • Creational patterns for objects delegate instantiation to another object. • Examples: • Factory • Singleton • Builder • Prototype Dr. Lilia SFAXI www.liliasfaxi.wix.com/liliasfaxi Slide 9 Creational Patterns
  10. 10. MedTech Singleton • Ensure that only one instance of a class is created and provide a global access point to the object. Dr. Lilia SFAXI www.liliasfaxi.wix.com/liliasfaxi Slide 10 Creational Patterns
  11. 11. MedTech Singleton: Usage • When to Use • When we must ensure that only one instance of a class is created • When the instance must be available through all the code • In multi-threading environments when multiple threads must access the same resources through the same singleton object. • Common Usage • Logger Classes • Configuration Classes • Accessing resources in shared mode • Other design patterns implemented as Singletons: • Factories and Abstract Factories, Builder, Prototype Dr. Lilia SFAXI www.liliasfaxi.wix.com/liliasfaxi Slide 11 Creational Patterns
  12. 12. MedTech Factory • Creates objects without exposing the instantiation logic to the client • Refers to the newly created object through a common interface. Dr. Lilia SFAXI www.liliasfaxi.wix.com/liliasfaxi Slide 12 Creational Patterns
  13. 13. MedTech Factory: Usage • When to use • When a framework delegates the creation of objects derived from a common superclass to the factory • When we need flexibility in adding new types of objects that must be created by the class • Common Usage • factories providing an xml parser: • javax.xml.parsers.DocumentBuilderFactory • javax.xml.parsers.SAXParserFactory • java.net.URLConnection Dr. Lilia SFAXI www.liliasfaxi.wix.com/liliasfaxi Slide 13 Creational Patterns
  14. 14. MedTech Builder • Defines an instance for creating an object but letting subclasses decide which class to instanciate • Allows finer control over the construction process Dr. Lilia SFAXI www.liliasfaxi.wix.com/liliasfaxi Slide 14 Creational Patterns
  15. 15. MedTech Builder Dr. Lilia SFAXI www.liliasfaxi.wix.com/liliasfaxi Slide 15 Creational Patterns
  16. 16. MedTech Builder Dr. Lilia SFAXI www.liliasfaxi.wix.com/liliasfaxi Slide 16 Creational Patterns
  17. 17. MedTech Builder Dr. Lilia SFAXI www.liliasfaxi.wix.com/liliasfaxi Slide 17 Creational Patterns
  18. 18. MedTech Builder Dr. Lilia SFAXI www.liliasfaxi.wix.com/liliasfaxi Slide 18 Creational Patterns
  19. 19. MedTech Builder Dr. Lilia SFAXI www.liliasfaxi.wix.com/liliasfaxi Slide 19 Creational Patterns
  20. 20. MedTech Builder: Usage • When to use • When the creation algorithm of a complex object is independent from the parts that actually compose the object • When the system needs to allow different representations for the objects that are being built • Builder and Factory • Very similar to the Factory pattern • Factory: the client uses the factory’s methods to create its own objects • Builder: the Builder class is instructed on how to create the object and then it is asked for it, but the way that the class is put together is up to the Builder class Dr. Lilia SFAXI www.liliasfaxi.wix.com/liliasfaxi Slide 20 Creational Patterns
  21. 21. MedTech STRUCTURAL PATTERNS Design Patterns Dr. Lilia SFAXI www.liliasfaxi.wix.com/liliasfaxi Slide 21
  22. 22. MedTech Definition • Structural patterns are concerned with how classes and objects are composed to form larger structures. • Structural class patterns use inheritance to compose interfaces or implementations. • Structural object patterns describe ways to compose objects to realize new functionality. The added flexibility of object composition comes from the ability to change the composition at runtime, which is impossible with static class composition. • Examples: • Adapter • Proxy • Bridge • Composite Dr. Lilia SFAXI www.liliasfaxi.wix.com/liliasfaxi Slide 22 Structural Patterns
  23. 23. MedTech Adapter • Converts the interface of a class into another interface the clients expect • Lets classes work together, that normally wouldn’t, due to incompatible interfaces Dr. Lilia SFAXI www.liliasfaxi.wix.com/liliasfaxi Slide 23 Structural Patterns
  24. 24. MedTech Adapter Dr. Lilia SFAXI www.liliasfaxi.wix.com/liliasfaxi Slide 24 Structural Patterns
  25. 25. MedTech Adapter Dr. Lilia SFAXI www.liliasfaxi.wix.com/liliasfaxi Slide 25 Structural Patterns
  26. 26. MedTech Adapter Dr. Lilia SFAXI www.liliasfaxi.wix.com/liliasfaxi Slide 26 Structural Patterns
  27. 27. MedTech Adapter Dr. Lilia SFAXI www.liliasfaxi.wix.com/liliasfaxi Slide 27 Structural Patterns
  28. 28. MedTech Adapter Dr. Lilia SFAXI www.liliasfaxi.wix.com/liliasfaxi Slide 28 Structural Patterns
  29. 29. MedTech Proxy • Provide a « Placeholder » for an object to control references to it Dr. Lilia SFAXI www.liliasfaxi.wix.com/liliasfaxi Slide 29 Structural Patterns
  30. 30. MedTech Proxy Dr. Lilia SFAXI www.liliasfaxi.wix.com/liliasfaxi Slide 30 Structural Patterns
  31. 31. MedTech Proxy Dr. Lilia SFAXI www.liliasfaxi.wix.com/liliasfaxi Slide 31 Structural Patterns
  32. 32. MedTech Proxy Dr. Lilia SFAXI www.liliasfaxi.wix.com/liliasfaxi Slide 32 Structural Patterns
  33. 33. MedTech Proxy Dr. Lilia SFAXI www.liliasfaxi.wix.com/liliasfaxi Slide 33 Structural Patterns
  34. 34. MedTech Composite • Compose objects into tree structures to represent part-whole hierarchies. • Composite lets clients treat individual objects and compositions of objects uniformly. Dr. Lilia SFAXI www.liliasfaxi.wix.com/liliasfaxi Slide 34 Structural Patterns
  35. 35. MedTech Composite Dr. Lilia SFAXI www.liliasfaxi.wix.com/liliasfaxi Slide 35 Structural Patterns
  36. 36. MedTech Composite Dr. Lilia SFAXI www.liliasfaxi.wix.com/liliasfaxi Slide 36 Structural Patterns
  37. 37. MedTech Composite Dr. Lilia SFAXI www.liliasfaxi.wix.com/liliasfaxi Slide 37 Structural Patterns
  38. 38. MedTech Composite Dr. Lilia SFAXI www.liliasfaxi.wix.com/liliasfaxi Slide 38 Structural Patterns
  39. 39. MedTech BEHAVIORAL PATTERNS Design Patterns Dr. Lilia SFAXI www.liliasfaxi.wix.com/liliasfaxi Slide 39
  40. 40. MedTech Definition • Behavioral patterns are concerned with algorithms and the assignment of responsibilities between objects • Behavioral class patterns use inheritance to distribute behavior between classes. • Behavioral object patterns use composition rather than inheritance. Some describe how a group of peer objects cooperate to perform a task that no single object can carry out by itself. • Examples: • Command • Iterator • Observer • Strategy Dr. Lilia SFAXI www.liliasfaxi.wix.com/liliasfaxi Slide 40 Behavioral Patterns
  41. 41. MedTech Command • Encapsulates a request in an object • Allows the parameterization of clients with different requests • Allows saving the request in a queue Dr. Lilia SFAXI www.liliasfaxi.wix.com/liliasfaxi Slide 41 Behavioral Patterns
  42. 42. MedTech Command Dr. Lilia SFAXI www.liliasfaxi.wix.com/liliasfaxi Slide 42 Behavioral Patterns
  43. 43. MedTech Command Dr. Lilia SFAXI www.liliasfaxi.wix.com/liliasfaxi Slide 43 Behavioral Patterns
  44. 44. MedTech Iterator • The iterator pattern allows us to: • Access contents of a collection without exposing its internal structure. • Support multiple simultaneous traversals of a collection. • Provide a uniform interface for traversing different collections. Dr. Lilia SFAXI www.liliasfaxi.wix.com/liliasfaxi Slide 44 Behavioral Patterns
  45. 45. MedTech Iterator Dr. Lilia SFAXI www.liliasfaxi.wix.com/liliasfaxi Slide 45 Behavioral Patterns
  46. 46. MedTech Observer • Defines a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically. Dr. Lilia SFAXI www.liliasfaxi.wix.com/liliasfaxi Slide 46 Behavioral Patterns
  47. 47. MedTech Observer Dr. Lilia SFAXI www.liliasfaxi.wix.com/liliasfaxi Slide 47 Behavioral Patterns
  48. 48. MedTech References Dr. Lilia SFAXI www.liliasfaxi.wix.com/liliasfaxi Slide 48 • Object Oriented Design, http://www.oodesign.com/, consulted november 2016 • Gang of Four (GoF)OO Design Patterns, (Course) WATERLOO CHERITON SCHOOL OF COMPUTER SCIENCE, 2011 • Design Patterns, (Course) Faculty of Science, Engineering and Technology, 2007 • Textbooks • E. Gamma & al. Design Patterns: Elements of Reusable Object-Oriented Software, Addison-Wesley, 1994 • B. Christiansson & al. GoF Design Patterns -with examples using Java and UML2, 2008

×