Mastering Python Design Patterns - Second Edition

Book description

Exploit various design patterns to master the art of solving problems using Python

Key Features

  • Master the application design using the core design patterns and latest features of Python 3.7
  • Learn tricks to solve common design and architectural challenges
  • Choose the right plan to improve your programs and increase their productivity

Book Description

Python is an object-oriented scripting language that is used in a wide range of categories. In software engineering, a design pattern is an elected solution for solving software design problems. Although they have been around for a while, design patterns remain one of the top topics in software engineering, and are a ready source for software developers to solve the problems they face on a regular basis. This book takes you through a variety of design patterns and explains them with real-world examples. You will get to grips with low-level details and concepts that show you how to write Python code, without focusing on common solutions as enabled in Java and C++. You'll also fnd sections on corrections, best practices, system architecture, and its designing aspects. This book will help you learn the core concepts of design patterns and the way they can be used to resolve software design problems. You'll focus on most of the Gang of Four (GoF) design patterns, which are used to solve everyday problems, and take your skills to the next level with reactive and functional patterns that help you build resilient, scalable, and robust applications. By the end of the book, you'll be able to effciently address commonly faced problems and develop applications, and also be comfortable working on scalable and maintainable projects of any size.

What you will learn

  • Explore Factory Method and Abstract Factory for object creation
  • Clone objects using the Prototype pattern
  • Make incompatible interfaces compatible using the Adapter pattern
  • Secure an interface using the Proxy pattern
  • Choose an algorithm dynamically using the Strategy pattern
  • Keep the logic decoupled from the UI using the MVC pattern
  • Leverage the Observer pattern to understand reactive programming
  • Explore patterns for cloud-native, microservices, and serverless architectures

Who this book is for

This book is for intermediate Python developers. Prior knowledge of design patterns is not required to enjoy this book.

Table of contents

  1. Title Page
  2. Copyright and Credits
    1. Mastering Python Design Patterns Second Edition
  3. Dedication
  4. Packt Upsell
    1. Why subscribe?
    2. PacktPub.com
  5. Contributors
    1. About the authors
    2. About the reviewer
    3. Packt is searching for authors like you
  6. Preface
    1. Who this book is for
    2. What this book covers
    3. To get the most out of this book
      1. Download the example code files
      2. Conventions used
    4. Get in touch
      1. Reviews
  7. The Factory Pattern
    1. The factory method
      1. Real-world examples
      2. Use cases
      3. Implementing the factory method
    2. The abstract factory
      1. Real-world examples
      2. Use cases
      3. Implementing the abstract factory pattern
    3. Summary
  8. The Builder Pattern
    1. Real-world examples
    2. Use cases
    3. Implementation
    4. Summary
  9. Other Creational Patterns
    1. The prototype pattern
      1. Real-world examples
      2. Use cases
      3. Implementation
    2. Singleton
      1. Real-world examples
      2. Use cases
      3. Implementation
    3. Summary
  10. The Adapter Pattern
    1. Real-world examples
    2. Use cases
    3. Implementation
    4. Summary
  11. The Decorator Pattern
    1. Real-world examples
    2. Use cases
    3. Implementation
    4. Summary
  12. The Bridge Pattern
    1. Real-world examples
    2. Use cases
    3. Implementation
    4. Summary
  13. The Facade Pattern
    1. Real-world examples
    2. Use cases
    3. Implementation
    4. Summary
  14. Other Structural Patterns
    1. The flyweight pattern
      1. Real-world examples
      2. Use cases
      3. Implementation
    2. The model-view-controller pattern
      1. Real-world examples
      2. Use cases
      3. Implementation
    3. The proxy pattern
      1. Real-world examples
      2. Use cases
      3. Implementation
    4. Summary
  15. The Chain of Responsibility Pattern
    1. Real-world examples
    2. Use cases
    3. Implementation
    4. Summary
  16. The Command Pattern
    1. Real-world examples
    2. Use cases
    3. Implementation
    4. Summary
  17. The Observer Pattern
    1. Real-world examples
    2. Use cases
    3. Implementation
    4. Summary
  18. The State Pattern
    1. Real-world examples
    2. Use cases
    3. Implementation
    4. Summary
  19. Other Behavioral Patterns
    1. Interpreter pattern
      1. Real-world examples
      2. Use cases
      3. Implementation
    2. Strategy pattern
      1. Real-world examples
      2. Use cases
      3. Implementation
    3. Memento pattern
      1. Real-world examples
      2. Use cases
      3. Implementation
    4. Iterator pattern
      1. Real-world examples
      2. Use cases
      3. Implementation
    5. Template pattern
      1. Real-world examples
      2. Use cases
      3. Implementation
    6. Summary
  20. The Observer Pattern in Reactive Programming
    1. Real-world examples
    2. Use cases
    3. Implementation
      1. A first example
      2. A second example
      3. A third example
      4. A fourth example
    4. Summary
  21. Microservices and Patterns for the Cloud
    1. The Microservices pattern
      1. Real-world examples
      2. Use cases
      3. Implementation
        1. A first example
        2. A second example
    2. The Retry pattern
      1. Real-world examples
      2. Use cases
      3. Implementation
        1. A first example
        2. A second example, using a third-party module
        3. A third example, using another third-party module
    3. The Circuit Breaker pattern
      1. Real-world examples
      2. Use cases
      3. Implementation
    4. The Cache-Aside pattern
      1. Real-world examples
      2. Use cases
      3. Implementation
    5. Throttling
      1. Real-world examples
      2. Use cases
      3. Implementation
    6. Summary
  22. Other Books You May Enjoy
    1. Leave a review - let other readers know what you think

Product information

  • Title: Mastering Python Design Patterns - Second Edition
  • Author(s): Kamon Ayeva, Sakis Kasampalis
  • Release date: August 2018
  • Publisher(s): Packt Publishing
  • ISBN: 9781788837484