Women Who Code Belfast: Introduction to Design patterns

1,035 views
858 views

Published on

A brief overview of common design patterns including code samples as presented to Women Who Code Belfast on 26th Nov 2013

Published in: Technology, Design
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
1,035
On SlideShare
0
From Embeds
0
Number of Embeds
55
Actions
Shares
0
Downloads
14
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide
  • Creational – concerned with everything about the creation of objectsStructural – how classes and objects are composed to form larger structuresBehavioural – algorithms and assignment of responsibilities between objects
  • Creational Concerned with everything about the creation of objectsStructural How classes and objects are composed to form larger structuresBehavioural Algorithms and assignment of responsibilities between objects
  • Women Who Code Belfast: Introduction to Design patterns

    1. 1. Colleen Crangle • Woman in tech throughout the 70s and 80s • PhD in Philosophy (Logic and the Philosophy of Language and Science), in follow-up to a BSc cum laude and an MSc in Computer Science and Mathematics from South Africa • Affiliated scholar with the Centre for the Study of Language and Information at Stanford University and a partner in a small R&D business in Silicon Valley, California
    2. 2. Introduction to Design Patterns Jackie Pollock
    3. 3. Who am I? • Technical Consultant @ Kainos Software • Joined June 2006 as Graduate Software Engineer • Specialities: • Document Management • Workflow • Scanning • Integration
    4. 4. Overview • What are design patterns? • Why are they useful • Types of design pattern • Creational • Structural • Behavioural
    5. 5. What is a design pattern? • General repeatable solution to commonly occurring problem • Not a finished design to be transformed directly into code • Relationships and interactions between classes or objects without implementation specifics
    6. 6. Where did they come from? • Architectural concept by Christopher Alexander in 1977 • Ward Cunningham and Kent Beck 1987 “Using pattern languages for objectorientated programmers” • 1990s Gamma, Helm, Johnson, and Vlissides. AKA: Gang of Four (GoF) book “Design Patterns: Elements of Reusable Object-Oriented Software”
    7. 7. Benefits • Design reuse • Uniform design vocabulary • Enhance understanding, restructuring, & team communication • Basis for automation • Transcends language-centric biases • Abstracts away from many unimportant details
    8. 8. Drawbacks • Require significant tedious & error-prone human effort to handcraft pattern implementations / design reuse • Can be deceptively simple • May limit design options • Leaves some important details unresolved
    9. 9. Creational Patterns
    10. 10. Factory Creating objects without having to specify the exact class of object that will be created – will be determined at runtime
    11. 11. Abstract Factory Creates family of objects at runtime – each of which will likely be a Factory in its own right
    12. 12. Builder Separates construction of the various elements from the representation of the whole therefore same process can create different variants of theme
    13. 13. Singleton Only one instance of object across application. Used to provide single point of access. Should not be used to replace global variables
    14. 14. Prototype Create complex objects by cloning existing ones and changing required characteristics. Useful when cost of new objects is prohibitive
    15. 15. Structural Patterns
    16. 16. Adapter Converts an existing interface into another that your application can use.
    17. 17. Composite Treat a group of objects the same way as a single instance of object. Tree structures with a has-a relationship
    18. 18. Decorator Add behaviour to object without affecting behaviour of other objects from the same class
    19. 19. Facade Simplified interface to larger body of code. Reduces dependencies on inner class objects, wraps complex product APIs in manageable layer
    20. 20. Proxy Placeholder for another object, controlling access. Used for lazy loading resource hungry objects
    21. 21. Behavioural Patterns
    22. 22. Command Turns requests into objects, separating out the code making the request from the object performing it
    23. 23. Iterator Access elements of collection sequentially without focusing on underlying object types
    24. 24. Observer When one object changes state, all dependent objects notified and updated. View element of Model-View-Controller pattern
    25. 25. State Object alters behaviour when internal state changes
    26. 26. Word of Caution Always go for simplistic approach rather than applying patterns to every situation If you force-fit a pattern into a situation where the pattern doesn’t apply, you are, by definition, not following the pattern
    27. 27. Resources • Books • Design Patterns • Head First Design Patterns • Design Patterns for Dummies • Online • Slideshare • Pluralsight • SourceMaking • Wikipedia • Image Credits • Nelleke Verhoeff (Yepr)
    28. 28. Thanks for listening Any Questions? j.pollock@kainos.com @kievia jackiepollock
    29. 29. Finish • Any queries? • WomenWhoCodeBelfast@Gmail.com • Twitter • #WomenWhoCodeBelfast • @WWCBelfast, @nirushika Looking forward to seeing you at our next event!

    ×