My Account Log in

1 option

Mastering Python Design Patterns : Craft Essential Python Patterns by Following Core Design Principles / Kamon Ayeva and Sakis Kasampalis.

Ebook Central Academic Complete Available online

View online
Format:
Book
Author/Creator:
Ayeva, Kamon, author.
Kasampalis, Sakis, author.
Language:
English
Subjects (All):
Computer software--Development.
Computer software.
Python (Computer program language).
Software patterns.
Physical Description:
1 online resource (296 pages)
Edition:
Third edition.
Place of Publication:
Birmingham, England : Packt Publishing, [2024]
Summary:
Learn Python design patterns such as Observer, Proxy, Throttling, Dependency Injection, and Anti-Patterns to develop efficient, scalable applications. Key Features Master essential design principles to build robust software architecture with the latest features in Python 3.10 Leverage concurrency, async patterns, and testing strategies for optimal performance Apply SOLID principles and advanced patterns to real-world Python projects Purchase of the print or Kindle book includes a free PDF eBook Book Description As software systems become increasingly complex, maintaining code quality, scalability, and efficiency can be a daunting challenge. Mastering Python Design Patterns is an essential resource that equips you with the tools you need to overcome these hurdles and create robust, scalable applications.The book delves into design principles and patterns in Python, covering both classic and modern patterns, and apply them to solve daily challenges as a Python developer or architect.Co-authored by two Python experts with a combined experience of three decades, this new edition covers creational, structural, behavioral, and architectural patterns, including concurrency, asynchronous, and performance patterns. You'll find out how these patterns are relevant to various domains, such as event handling, concurrency, distributed systems, and testing. Whether you're working on user interfaces (UIs), web apps, APIs, data pipelines, or AI models, this book equips you with the knowledge to build robust and maintainable software. The book also presents Python anti-patterns, helping you avoid common pitfalls and ensuring your code remains clean and efficient.By the end of this book, you'll be able to confidently apply classic and modern Python design patterns to build robust, scalable applications. What you will learn Master fundamental design principles and SOLID concepts Become familiar with Gang of Four (GoF) patterns and apply them effectively in Python Explore architectural design patterns to architect robust systems Delve into concurrency and performance patterns for optimized code Discover distributed systems patterns for scalable applications Get up to speed with testing patterns to ensure code reliability and maintainability Develop modular, decoupled systems and manage dependencies efficiently Who this book is for With a focus on intermediate and advanced Python programmers, this book offers valuable insights into the best practices for software design, backed by real-world examples and decades of experience. The book is also an excellent resource for software architects and team leaders who want to improve code quality and maintainability across their projects. Prior Python proficiency, including syntax, data structures, and OOP will help you get the most out of this book. ]]>
Contents:
Cover
Title Page
Copyright
Dedication
Contributors
Table of Contents
Preface
Part 1: Start with Principles
Chapter 1: Foundational Design Principles
Technical requirements
Following the Encapsulate What Varies principle
What does it mean?
Benefits
Techniques for achieving encapsulation
An example - encapsulating using polymorphism
An example - encapsulating using a property
Following the Favor Composition Over Inheritance principle
Techniques for composition
An example - compose a car using the engine
Following the Program to Interfaces, Not Implementations principle
Techniques for interfaces
An example - different types of logger
An example - different types of logger, now using Protocols
Following the Loose Coupling principle
Techniques for loose coupling
An example - a message service
Summary
Chapter 2: SOLID Principles
SRP
An example of software design following the SRP
OCP
An example of design following the OCP
LSP
An example of design following the LSP
ISP
An example of design following the ISP
DIP
Part 2: From the Gang of Four
Chapter 3: Creational Design Patterns
The factory pattern
The factory method
The abstract factory pattern
The builder pattern
Real-world examples
Comparison with the factory pattern
Use cases for the builder pattern
Implementing the builder pattern
The prototype pattern
Use cases for the prototype pattern
Implementing the prototype pattern
The singleton pattern
Use cases for the singleton pattern.
Implementing the singleton pattern
Should you use the singleton pattern?
The object pool pattern
Use cases for the object pool pattern
Implementing the object pool pattern
Chapter 4: Structural Design Patterns
The adapter pattern
Use cases for the adapter pattern
Implementing the adapter pattern - adapt a legacy class
Implementing the adapter pattern - adapt several classes into a unified interface
The decorator pattern
Use cases for the decorator pattern
Implementing the decorator pattern
The bridge pattern
Use cases for the bridge pattern
Implementing the bridge pattern
The facade pattern
Use cases for the facade pattern
Implementing the facade pattern
The flyweight pattern
Use cases for the flyweight pattern
Implementing the flyweight pattern
The proxy pattern
Use cases for the proxy pattern
Implementing the proxy pattern - a virtual proxy
Implementing the proxy pattern - a protection proxy
Implementing the proxy pattern - a remote proxy
Implementing the proxy pattern - a smart proxy
Chapter 5: Behavioral Design Patterns
The Chain of Responsibility pattern
Use cases for the Chain of Responsibility pattern
Implementing the Chain of Responsibility pattern
The Command pattern
Use cases for the Command pattern
Implementing the Command pattern
The Observer pattern
Use cases for the Observer pattern
Implementing the Observer pattern
The State pattern
Use cases for the State pattern
Implementing the State pattern
The Interpreter pattern.
Real-world examples
Use cases for the Interpreter pattern
Implementing the Interpreter pattern
The Strategy pattern
Use cases for the Strategy pattern
Implementing the Strategy pattern
The Memento pattern
Use cases for the Memento pattern
Implementing the Memento pattern
The Iterator pattern
Use cases for the Iterator pattern
Implementing the Iterator pattern
The Template pattern
Use cases for the Template pattern
Implementing the Template pattern
Other behavioral design patterns
Part 3: Beyond the Gang of Four
Chapter 6: Architectural Design Patterns
The MVC pattern
Use cases for the MVC pattern
Implementing the MVC pattern
The Microservices pattern
Use cases for the Microservices pattern
Implementing the microservices pattern - a payment service using gRPC
Implementing the microservices pattern - an LLM service using Lanarky
The Serverless pattern
Use cases for the Serverless pattern
Implementing the Serverless pattern
The Event Sourcing pattern
Use cases for the Event Sourcing pattern
Implementing the event sourcing pattern - the manual way
Implementing the Event Sourcing pattern - using a library
Other architectural design patterns
Chapter 7: Concurrency and Asynchronous Patterns
The Thread Pool pattern
Use cases for the Thread Pool pattern
Implementing the Thread Pool pattern
The Worker Model pattern
Use cases for the Worker Model pattern
Implementing the Worker Model pattern
The Future and Promise pattern
Real-world examples.
Use cases for the Future and Promise pattern
Implementing the Future and Promise pattern - using concurrent.futures
Implementing the Future and Promise pattern - using asyncio
The Observer pattern in reactive programming
Use cases for the Observer pattern in reactive programming
Implementing the Observer pattern in reactive programming
Other concurrency and asynchronous patterns
Chapter 8: Performance Patterns
The Cache-Aside pattern
Use cases for the cache-aside pattern
Implementing the cache-aside pattern
The Memoization pattern
Use cases for the memoization pattern
Implementing the memoization pattern
The Lazy Loading pattern
Use cases for the lazy loading pattern
Implementing the lazy loading pattern - lazy attribute loading
Implementing the lazy loading pattern - using caching
Chapter 9: Distributed Systems Patterns
The Throttling pattern
Use cases for the Throttling pattern
Implementing the Throttling pattern
The Retry pattern
Use cases for the Retry pattern
Implementing the Retry pattern
The Circuit Breaker pattern
Use cases for the Circuit Breaker pattern
Implementing the Circuit Breaker pattern
Other distributed systems patterns
Chapter 10: Patterns for Testing
The Mock Object pattern
Use cases for the Mock Object pattern
Implementing the Mock Object pattern
The Dependency Injection pattern
Use cases for the Dependency Injection pattern
Implementing the Dependency Injection pattern - using a mock object.
Implementing the Dependency Injection pattern - using a decorator
Chapter 11: Python Anti-Patterns
Code style violations
Tools for fixing coding style violations
Indentation
Maximum line length and blank lines
Imports
Naming conventions
Comments
Whitespace in expressions and statements
Correctness anti-patterns
Using the type() function for comparing types
Mutable default argument
Accessing a protected member from outside a class
Maintainability anti-patterns
Using a wildcard import
LBYL versus EAFP
Overusing inheritance and tight coupling
Using global variables for sharing data between functions
Performance anti-patterns
Not using .join() to concatenate strings in a loop
Using global variables for caching
Index
About Packt
Other Books You May Enjoy.
Notes:
Includes index.
Description based on publisher supplied metadata and other sources.
Description based on print version record.
ISBN:
9781837637652
1837637652
OCLC:
1436833129

The Penn Libraries is committed to describing library materials using current, accurate, and responsible language. If you discover outdated or inaccurate language, please fill out this feedback form to report it and suggest alternative language.

Find

Home Release notes

My Account

Shelf Request an item Bookmarks Fines and fees Settings

Guides

Using the Find catalog Using Articles+ Using your account