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

DESIGN PATTERNS WITH PYTHON

DESIGN PATTERNS WITH PYTHON

how to apply design patterns to create python programs that easy to write, read and maintain.

cleopatra douglas

September 15, 2017
Tweet

More Decks by cleopatra douglas

Other Decks in Technology

Transcript

  1. Expectations At the end of this course you would have

    learnt how to apply design patterns to create python programs that easy to write, read and maintain.
  2. WHAT ARE DESIGN PATTERNS? WHY DO WE NEED THEM? CLASSIFICATION

    PRINCIPLES OF OBJECT-ORIENTED DESIGN SOLID DEFINING INTERFACES IN PYTHON OVERVIEW 1
  3. WHAT ARE DESIGN PATTERNS? A design pattern is a model

    solution to a common design problem. It describes the problem and a general approach to solving it.
  4. ‘Each pattern describes a problem which occurs over and over

    again in our environment and then describes the core of the solution to the problem’ - Christopher Alexander (An Architect)
  5. WHY DO WE NEED DESIGN PATTERNS? We need to design

    patterns to ensure that our work is consistent, reliable and understandable.
  6. S - SINGLE RESPONSIBILITY O- OPEN-CLOSED L- LISKOV SUBSTITUTION I-

    INTERFACE SEGREGATION D- DEPENDENCY INVERSION
  7. WHAT PYTHON VERSION We will be referencing python language 2.7x

    or 3.5x -https://www.python.org/downl oads/
  8. INTERFACES IN PYTHON THIS IS ‘ I ‘ IN SOLID

    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Incididunt ut labore et dolore. Consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
  9. STRATEGY PATTERN CLASSIFICATION: BEHAVIORAL FAMILY OF ALGORITHMS ENCAPSULATE EACH ONE

    MAKE THEM INTERCHANGEABLE ALSO KNOWN AS POLICY PATTERN
  10. EXAMPLE ONLINE SHOPPING WEBSITE SHIPPING PAGE Must Support: - FEDEX

    - UPS - Nigerian Postal Service Must be extendable (add new shippers)
  11. Fixed the problems we discovered Test of algorithms in isolation

    Test the outer code with deterministic mock algorithms No more Long list of if/elif clauses
  12. OBSERVER PATTERN CLASSIFICATION: BEHAVIORAL ONE TO MANY RELATIONSHIP BETWEEN A

    SET OF OBJECTS WHEN THE STATE OF ONE CHANGES ITS DEPENDENTS ARE NOTIFIED ALSO KNOWN AS: DEPENDENTS PATTERN PUBLISH-SUSCRIBE PATTERN
  13. EXAMPLE DASHBOARD FOR A TECH SUPPORT CENTER KPIs: - Open

    Tickets - New tickets in last hour - Closed tickets in last hours Dashboard is the observer KPI source is the subject or publisher.