design patterns
play

Design Patterns Massimo Felici Massimo Felici Design Patterns - PowerPoint PPT Presentation

Design Patterns Massimo Felici Massimo Felici Design Patterns 2011 c 1 Design Patterns A design pattern is a standardised solution to a problem commonly encountered during object-oriented software development. A pattern is not a


  1. Design Patterns Massimo Felici Massimo Felici Design Patterns � 2011 c

  2. 1 Design Patterns • A design pattern is a standardised solution to a problem commonly encountered during object-oriented software development. • A pattern is not a piece of reusable code, but an overall approach that has proven to be useful in several different systems already. Massimo Felici Design Patterns � 2011 c

  3. Slide 1: References • Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides, Design Patterns: Elements of Reusable Object-Oriented Software, Addison-Wesley, 1995. • Frank Buschmann, Eduardo Fernandez-Buglioni, Duane Hybertson, and Peter Sommerlad, Security Patterns: Integrating Security and Systems Engineering, John Wiley & Sons, 2005.

  4. 2 Contents of a Design Pattern Design patterns usually include: • A pattern name • A statement of the problem solved by the pattern • A description of the solution • A list of advantages and liabilities (good and bad consequences) Massimo Felici Design Patterns � 2011 c

  5. 3 Design Patterns and Large-Scale Development • For a large team, design patterns are useful in creating a shared vocabulary. • First, everyone agrees on a standard reference text (or set of them). • Informal discussions, class naming, etc. can then use the pattern names. • Large groups can develop and name their own patterns. Massimo Felici Design Patterns � 2011 c

  6. 4 Design Pattern Examples • Creational Patterns: – E.g. Abstract Factory, Factory Method, etc. • Structural Patterns: – E.g. Composite, Proxy, etc. • Behavioral Patterns: – E.g. Command, Visitor, etc. These are from the “Design Patterns” book (a.k.a. the Gang of Four book), but there are many other pattern collections Massimo Felici Design Patterns � 2011 c

  7. 5 Composite: Pattern • Composes objects into tree structures to represent part-whole hierarchies. • Lets clients treat individual objects and compositions of objects uniformly. Massimo Felici Design Patterns � 2011 c

  8. 6 Composite: Problem • User wants to be able to treat groups of things as a unit • Surrounding code would get complex if it were always conditional on whether an object was a group or a primitive • Want to support hierarchical containers of containers Massimo Felici Design Patterns � 2011 c

  9. 7 Composite: Solution Three classes: • Component: Shared interface between all, some shared implementation • Leaf: A primitive, implemented directly • Composite: for all children Components, do operation Massimo Felici Design Patterns � 2011 c

  10. 8 Composite: Example Massimo Felici Design Patterns � 2011 c

  11. 9 Composite: Advantages • Simple support for arbitrarily complex hierarchies • Clients can be simple — do not need to know about composition • New Composite and Leaf classes can be introduced without changing Component Massimo Felici Design Patterns � 2011 c

  12. 10 Composite: Liabilities • Hard for client to predict/restrict what components might be encountered • Hard to test that client works for all components • Often need to define operations on Components that make sense only for some Component types, e.g. Composites Massimo Felici Design Patterns � 2011 c

  13. 11 Summary • Many, many other patterns available • Design patterns help provide a library of solutions to common OO problems • Usually low level, but form vocabulary for a large team • Important to agree on definitions, apply consistently Massimo Felici Design Patterns � 2011 c

  14. 12 Required Readings • T. Winn, P. Calder. Is This a Pattern?. IEEE Software, 19(1):59-66, January/February, 2002. http://dx.doi.org/10.1109/52.976942 • F. Buschmann, K. Henney, D.C. Schmidt. Past, Present, and Future Trends in Software Patterns. IEEE Software, 24(4):31-37, July, 2007. http://dx.doi.org/10.1109/MS.2007. 115 • Erich Gamma, Richard Helm, Ralph E. Johnson, and John M. Vlissides. 1993. Design Patterns: Abstraction and Reuse of Object-Oriented Design. In Proceedings of the 7th European Conference on Object-Oriented Programming (ECOOP ’93), Oscar Nierstrasz (Ed.). Springer- Verlag, London, UK, UK, 406-431. http://dx.doi.org/10.1007/3-540-47910-4_21 Massimo Felici Design Patterns � 2011 c

  15. 13 Suggested Readings • D. Manolescu, W. Kozaczynski, A. Miller, J. Hogg. The Growing Divide in the Patterns World. IEEE Software, 24(4):61-67, July 2007. http://dx.doi.org/10.1109/MS.2007.120 • M.P. Cline. The pros and cons of adopting and applying design patterns in the real world. Communications of the ACM, 39(10):47-49, October, 1996. http://dx.doi.org/10.1145/ 236156.236167 • L. D’Adderio, R. Dewar, A. Lloyd, P. Stevens. Has the pattern emperor any clothes? A controversy in three acts. In ACM/SIGSOFT Software Engineering Notes, Jan/Feb 2002. http://dx.doi.org/10.1145/566493.1148026 Massimo Felici Design Patterns � 2011 c

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend