Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Introduction to Design Patterns

Introduction to Design Patterns

Motivating developers to learn about design patterns.

Zaki Shaheen

July 15, 2014
Tweet

More Decks by Zaki Shaheen

Other Decks in Technology

Transcript

  1. Agenda • What is “design”? • What is “pattern”? •

    Motivation for design patterns • “The pattern language” • Brief intro to GoF Design Patterns • How to learn design patterns • Summary + QnA
  2. What is “design”? "I think there is a profound and

    enduring beauty in simplicity; in clarity, in efficiency. True simplicity is derived from so much more than just the absence of clutter and ornamentation. It's about bringing order to complexity." - Sir Johnathan Ive, Apple SVP of Industrial design.
  3. "a specification of an object, manifested by an agent, intended

    to accomplish goals, in a particular environment, using a set of primitive components, satisfying a set of requirements, subject to constraints;" “Form follows function”
  4. What is “pattern”? • recurrence of a phenomenon (activity, event,

    problem, solution, situation) ◦ explicit recurrence (Bathing, city centers, wanting to write) ◦ implicit recurrence (relationships, building entrance, screw drivers?)
  5. Motivation for design patterns • Patterns are everywhere and so

    is design • The Pattern language by Christopher Alexander (1977) • Art of War by Sun Tzu. (300-500 BC)
  6. “The pattern language” • 253 patterns for towns, buildings and

    construction • Towns (Ring roads, web of shopping, network of learning, green streets, graveyards) • Buildings (south facing outdoors, indoor sunlight, fire place) • Construction (box columns, stair vault, floor surface, colors)
  7. "The street cafe provides a unique setting, special to cities:

    a place where people can sit lazily, legitimately, be on view, and watch the world go by... Encourage local cafes to spring up in each neighborhood. Make them intimate places, with several rooms, open to a busy path, where people can sit with coffee or a drink and watch the world go by. Build the front of the cafe so that a set of tables stretch out of the cafe, right into the street." https://www.patternlanguage.com/labyrinth/apl-tour2.html
  8. (Brief) introduction to GoF • Software architecture patterns • “Design

    Patterns: Elements of Reusable Object-Oriented Software” • Creational / Structural / Behavioral
  9. Creational Design Patterns • Singleton ◦ UIApplication, UIWindow, zend_controller_front •

    Object pool ◦ Reusable cells in UITableView, photo controller, carousels
  10. Structural Design patterns • Composite ◦ The “V” in MVC.

    ◦ View hierarchy ◦ Could be your REST representation. • Adapter • Decorator • Flyweight
  11. Behavioral Patterns • Observer ◦ NSNotification System ◦ ServiceManager, EventManager

    (in ZF2) ◦ Also called pub-sub • Chain of responsibility ◦ UIResponder chain • Command ◦ NSInvocation • Iterator ◦ Enumerators
  12. Other patterns • Enterprise Architecture Patterns ◦ Gateway ◦ Mapper

    ◦ Front Controller ◦ Active Record ◦ http://martinfowler.com/eaaCatalog/ • SOA Patterns (http://www.soapatterns.org) • Cloud Patterns ◦ Load balancing, clustering, naming, provisioning ◦ http://cloudpatterns.org
  13. Tips on learning patterns • Requires deep, focused and abstract

    thinking • No use without solid OOP principles and design thinking/practice • No use without learning UML • No use without experience of problems • Read the GoF book • Think abstractly, profoundly, retrospectively • Start with birds eye view • Learn creational, structural and behavioral in that order. • Don't restrict yourself to GoF Book • Don't restrict yourself to other people's patterns
  14. Key takeaways • Design is not art. • Patterns are

    everywhere, requires deep abstract thinking to find them. • Design patterns give a vocabulary to tackle “design” problems.