Learning Python Design Patterns - Second Edition
eBook - ePub

Learning Python Design Patterns - Second Edition

Chetan Giridhar

Buch teilen
  1. 164 Seiten
  2. English
  3. ePUB (handyfreundlich)
  4. Über iOS und Android verfügbar
eBook - ePub

Learning Python Design Patterns - Second Edition

Chetan Giridhar

Angaben zum Buch
Buchvorschau
Inhaltsverzeichnis
Quellenangaben

Über dieses Buch

Leverage the power of Python design patterns to solve real-world problems in software architecture and design

About This Book

  • Understand the structural, creational, and behavioral Python design patterns
  • Get to know the context and application of design patterns to solve real-world problems in software architecture, design, and application development
  • Get practical exposure through sample implementations in Python v3.5 for the design patterns featured

Who This Book Is For

This book is for Software architects and Python application developers who are passionate about software design. It will be very useful to engineers with beginner level proficiency in Python and who love to work with Python 3.5

What You Will Learn

  • Enhance your skills to create better software architecture
  • Understand proven solutions to commonly occurring design issues
  • Explore the design principles that form the basis of software design, such as loose coupling, the Hollywood principle and the Open Close principle among others
  • Delve into the object-oriented programming concepts and find out how they are used in software applications
  • Develop an understanding of Creational Design Patterns and the different object creation methods that help you solve issues in software development
  • Use Structural Design Patterns and find out how objects and classes interact to build larger applications
  • Focus on the interaction between objects with the command and observer patterns
  • Improve the productivity and code base of your application using Python design patterns

In Detail

With the increasing focus on optimized software architecture and design it is important that software architects think about optimizations in object creation, code structure, and interaction between objects at the architecture or design level. This makes sure that the cost of software maintenance is low and code can be easily reused or is adaptable to change. The key to this is reusability and low maintenance in design patterns.

Building on the success of the previous edition, Learning Python Design Patterns, Second Edition will help you implement real-world scenarios with Python's latest release, Python v3.5.

We start by introducing design patterns from the Python perspective. As you progress through the book, you will learn about Singleton patterns, Factory patterns, and Facade patterns in detail. After this, we'll look at how to control object access with proxy patterns. It also covers observer patterns, command patterns, and compound patterns.

By the end of the book, you will have enhanced your professional abilities in software architecture, design, and development.

Style and approach

This is an easy-to-follow guide to design patterns with hands-on examples of real-world scenarios and their implementation in Python v3.5. Each topic is explained and placed in context, and for the more inquisitive, there are more details on the concepts used.

Häufig gestellte Fragen

Wie kann ich mein Abo kündigen?
Gehe einfach zum Kontobereich in den Einstellungen und klicke auf „Abo kündigen“ – ganz einfach. Nachdem du gekündigt hast, bleibt deine Mitgliedschaft für den verbleibenden Abozeitraum, den du bereits bezahlt hast, aktiv. Mehr Informationen hier.
(Wie) Kann ich Bücher herunterladen?
Derzeit stehen all unsere auf Mobilgeräte reagierenden ePub-Bücher zum Download über die App zur Verfügung. Die meisten unserer PDFs stehen ebenfalls zum Download bereit; wir arbeiten daran, auch die übrigen PDFs zum Download anzubieten, bei denen dies aktuell noch nicht möglich ist. Weitere Informationen hier.
Welcher Unterschied besteht bei den Preisen zwischen den Aboplänen?
Mit beiden Aboplänen erhältst du vollen Zugang zur Bibliothek und allen Funktionen von Perlego. Die einzigen Unterschiede bestehen im Preis und dem Abozeitraum: Mit dem Jahresabo sparst du auf 12 Monate gerechnet im Vergleich zum Monatsabo rund 30 %.
Was ist Perlego?
Wir sind ein Online-Abodienst für Lehrbücher, bei dem du für weniger als den Preis eines einzelnen Buches pro Monat Zugang zu einer ganzen Online-Bibliothek erhältst. Mit über 1 Million Büchern zu über 1.000 verschiedenen Themen haben wir bestimmt alles, was du brauchst! Weitere Informationen hier.
Unterstützt Perlego Text-zu-Sprache?
Achte auf das Symbol zum Vorlesen in deinem nächsten Buch, um zu sehen, ob du es dir auch anhören kannst. Bei diesem Tool wird dir Text laut vorgelesen, wobei der Text beim Vorlesen auch grafisch hervorgehoben wird. Du kannst das Vorlesen jederzeit anhalten, beschleunigen und verlangsamen. Weitere Informationen hier.
Ist Learning Python Design Patterns - Second Edition als Online-PDF/ePub verfügbar?
Ja, du hast Zugang zu Learning Python Design Patterns - Second Edition von Chetan Giridhar im PDF- und/oder ePub-Format sowie zu anderen beliebten Büchern aus Computer Science & Programming in Python. Aus unserem Katalog stehen dir über 1 Million Bücher zur Verfügung.

Information

Jahr
2016
ISBN
9781785888038

Learning Python Design Patterns Second Edition


Table of Contents

Learning Python Design Patterns Second Edition
Credits
Foreword
About the Author
About the Reviewer
www.PacktPub.com
Support files, eBooks, discount offers, and more
Why subscribe?
Free access for Packt account holders
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Errata
Piracy
Questions
1. Introduction to Design Patterns
Understanding object-oriented programming
Objects
Classes
Methods
Major aspects of object-oriented programming
Encapsulation
Polymorphism
Inheritance
Abstraction
Composition
Object-oriented design principles
The open/close principle
The inversion of control principle
The interface segregation principle
The single responsibility principle
The substitution principle
The concept of design patterns
Advantages of design patterns
Taxonomy of design patterns
Context – the applicability of design patterns
Patterns for dynamic languages
Classifying patterns
Creational patterns:
Structural patterns
Behavioral patterns
Summary
2. The Singleton Design Pattern
Understanding the Singleton design pattern
Implementing a classical Singleton in Python
Lazy instantiation in the Singleton pattern
Module-level Singletons
The Monostate Singleton pattern
Singletons and metaclasses
A real-world scenario – the Singleton pattern, part 1
A real-world scenario – the Singleton pattern, part 2
Drawbacks of the Singleton pattern
Summary
3. The Factory Pattern – Building Factories to Create Objects
Understanding the Factory pattern
The Simple Factory pattern
The Factory Method pattern
Implementing the Factory Method
Advantages of the Factory method pattern
The Abstract Factory pattern
Implementing the Abstract Factory pattern
The Factory method versus Abstract Factory method
Summary
4. The Façade Pattern – Being Adaptive with Façade
Understanding Structural design patterns
Understanding the Façade design pattern
A UML class diagram
Façade
System
Client
Implementing the Façade pattern in the real world
The principle of least knowledge
Frequently asked questions
Summary
5. The Proxy Pattern – Controlling Object Access
Understanding the Proxy design pattern
A UML class diagram for the Proxy pattern
Understanding different types of Proxies
A virtual proxy
A remote proxy
A protective proxy
A smart proxy
The Proxy pattern in the real world
Advantages of the Proxy pattern
Comparing the Façade and Proxy patterns
Frequently asked questions
Summary
6. The Observer Pattern – Keeping Objects in the Know
Introducing Behavioral patterns
Understanding the Observer design pattern
A UML class diagram for the Observer pattern
The Observer pattern in the real world
The Observer pattern methods
The pull model
The push model
Loose coupling and the Observer pattern
The Observer pattern – advantages and disadvantages
Frequently asked questions
Summary
7. The Command Pattern – Encapsulating Invocation
Introducing the Command pattern
Understanding the Command design pattern
A UML class diagram for the Command pattern
Implementing the Command pattern in the real world
Design considerations
Advantages and disadvantages of Command patterns
Frequently asked questions
Summary
8. The Template Method Pattern – Encapsulating Algorithm
Defining the Template Method pattern
Understanding the Template Method design pattern
A UML class diagram for the Template Method pattern
The Template Method pattern in the real world
The Template Method pattern – hooks
The Hollywood principle and the Template Method
The advantages and disadvantages of the Template Method pattern
Frequently asked questions
Summary
9. Model-View-Controller – Compound Patterns
An introduction to Compound patterns
The Model-View-Controller pattern
Model – knowledge of the application
View – the appearance
Controller – the glue
A UML class diagram for the MVC design pattern
The MVC pattern in the real world
Modules
Benefits of the MVC pattern
Frequently asked questions
Summary
10. The State Design Pattern
Defining the State design pattern
Understanding the State design pattern
Understanding the State design pattern with a UML diagram
A simple example of the State design pattern
The State design pattern with v3.5 implementation
Advantages/disadvantages of the State pattern
Summary
11. AntiPatterns
An introduction to AntiPatterns
Software development AntiPatterns
Spaghetti code
Golden Hammer
Lava Flow
Copy-and-paste or cut-and-paste programming
Software architecture AntiPatterns
Reinventing the wheel
Vendor lock-in
Design by committee
Summary
Index

Learning Python Design Patterns Second Edition

Copyright © 2016 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
First published: November 2013
Second edition: February 2016
Production reference: 1080216
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham B3 2PB, UK.
ISBN 978-1-78588-803-8
www.packtpub.com

Credits

Author
Chetan Giridhar
Reviewer
Maurice HT Ling
Commissioning Editor
Kunal Parikh
Acquisition Editor
Denim Pinto
Content Development Editor
Merint Thomas Mathew
Technical Editor
Chinmay S. Puranik
Copy Editor
Tasneem Fatehi
Project Coordinator
Suzanne Coutinho
Proofreader
Safis Editing
Indexer
Priya Sane
Graphics
Kirk D'Penha
Production Coordinator
Shantanu N. Zagade
Cover Work
Shantanu N. Zagade

Foreword

"Controlling complexity is the essence of computer programming."
--Brian Kernighan
"All problems in computer science can be solved by another level of indirection (abstraction)."
--David Wheeler
The preceding two quotes by two well known computer scientists illustr...

Inhaltsverzeichnis