Learning Python Design Patterns


Learning Python Design Patterns
eBook: $14.99
Formats: PDF, PacktLib, ePub and Mobi formats
$12.74
save 15%!
Print + free eBook + free PacktLib access to the book: $39.98    Print cover: $24.99
$24.99
save 37%!
Free Shipping!
UK, US, Europe and selected countries in Asia.
Also available on:
Overview
Table of Contents
Author
Support
Sample Chapters
  • Explore the Model-View-Controller pattern and learn how to build a URL shortening service
  • All design patterns use a real-world example that can be modified and applied in your software
  • No unnecessary theory! The book consists of only the fundamental knowledge that you need to know

Book Details

Language : English
Paperback : 100 pages [ 235mm x 191mm ]
Release Date : November 2013
ISBN : 1783283378
ISBN 13 : 9781783283378
Author(s) : Gennadiy Zlobin
Topics and Technologies : All Books, Application Development, Open Source

Table of Contents

Preface
Chapter 1: Model-View-Controller
Chapter 2: Creating Only One Object with the Singleton Pattern
Chapter 3: Building Factories to Create Objects
Chapter 4: The Facade Design Pattern
Chapter 5: Facilitating Object Communication with Proxy and Observer Patterns
Chapter 6: Encapsulating Calls with the Command Pattern
Chapter 7: Redefining Algorithms with the Template Method
Index
  • Chapter 1: Model-View-Controller
    • Model – the knowledge of the application
    • View – the appearance of knowledge
    • Controller – the glue between the model and view
    • Benefits of using the MVC
    • Implementation in Python
    • Summary
      • Chapter 3: Building Factories to Create Objects
        • The Factory Method
          • Advantages of using the Factory Method pattern
          • The Factory Method implementation
        • Abstract Factory
          • Advantages of using the Abstract Factory pattern
          • Abstract Factory implementation
        • Abstract Factory versus Factory Method
        • Summary
        • Chapter 4: The Facade Design Pattern
          • The Facade design pattern
            • Problems solved by the Facade pattern
            • Advantages of the Facade design pattern
          • Facades in Python's standard library
          • Implementation in Python
          • Summary
          • Chapter 5: Facilitating Object Communication with Proxy and Observer Patterns
            • Proxy design pattern
              • Problems solved by the Proxy pattern
              • The use of the Proxy pattern
              • Advantages and disadvantages of the Proxy design pattern
              • Implementation in Python
            • Observer design pattern
              • Problems solved by the Observer pattern
              • Use of the Observer pattern
              • Advantages of the Observer pattern
              • Implementation in Python
            • Summary

                Gennadiy Zlobin

                Gennadiy Zlobin works as Lead Software Engineer and Technical Leader in the Russian music service, Zvooq.ru. His current employer is Zvooq Ltd. He has been using Python as the primary language for more than 4 years, enjoying its elegance and power every day. His professional interests include high-load software architectures, good engineering practices, Android OS, and natural language processing. Previously, he worked for the company that had the first search engine in Russia, called Rambler. He was engaged in airline tickets' meta search service and Rambler's index page.
                Sorry, we don't have any reviews for this title yet.

                Code Downloads

                Download the code and support files for this book.


                Submit Errata

                Please let us know if you have found any errors not listed on this list by completing our errata submission form. Our editors will check them and add them to this list. Thank you.


                Errata

                - 7 submitted: last submission 12 Mar 2014

                Errata type: Code | Page number: 18

                import single tone
                Should be:
                import singletone

                Errata type: Layout | Page 11

                class Url(object):

                   @classmethod

                  def shorten(cls, full_url):

                 

                Should be:

                 

                class Url(object):

                  @classmethod

                  def shorten(cls, full_url):

                Errata type: Layout | Page 19

                  >>> child = Child()

                >>> child is singleton

                >>> False

                Should be:

                 

                >>> child = Child()

                >>> child is singleton

                >>> False

                Errata type: Layout | Page 21

                The $ in the following line is in difefrent font:

                $  sudo pip install BeautifulSoup httplib2 

                It's layout issue. Should be in the same font.

                Errata type: Code related | Page 14

                Line number 5 and 6 of the code are:

                # from flask import redirect, render_template, request, Flask

                # from werkzeug.exceptions import BadRequest, NotFound

                Should be replaced by:

                from flask import redirect, render_template, request, Flask

                from werkzeug.exceptions import BadRequest, NotFound

                Errata type: Code related | Page 14

                In the shorten function ( def shorten(): ), there is the following part:

                # Model returns object with short_url property

                url_model = models.Url.shorten(full_url)

                url_model.short_url

                Should be replaced by:

                # Model returns object with short_url property

                url_model = models.Url.shorten(full_url)

                Errata Type: Technical | Page: 31

                The sentence, "This abstract class does not know which port and protocol to use for the connection because the standard port for HTTP is 80 and for FTP is 22, and the protocol for HTTP is http or https,and the protocol for FTP is ftp." has a correction. 

                Please note: The default FTP port is 21.

                Errata Type: Technical | Page: 82

                First paragraph's first line is:

                In the preceding code, we left get_raw_content and parse_content as not implemented to let subclasses implement them.

                It should be:

                In the preceding code, we left get_url and parse_content as not implemented to let subclasses implement them.

                Sample chapters

                You can view our sample chapters and prefaces of this title on PacktLib or download sample chapters in PDF format.

                Frequently bought together

                Learning Python Design Patterns +    Pentaho Data Integration Cookbook - Second Edition =
                50% Off
                the second eBook
                Price for both: £20.65

                Buy both these recommended eBooks together and get 50% off the cheapest eBook.

                What you will learn from this book

                • Create different implementations of the same algorithm with the least modifications
                • Implement the publisher-subscriber pattern
                • Create an object when only one instance of it is needed
                • Create a simple interface using the Facade design pattern
                • Increase the functionality while leaving the interface unchanged

                In Detail

                Design pattern is a well-known approach to solve some specific problems which each software developer comes across during his work. Design patterns capture higher-level constructs that commonly appear in programs. If you know how to implement the design pattern in one language, typically you will be able to port and use it in another object-oriented programming language.

                The choice of implementation language affects the use of design patterns. Naturally, some languages are more applicable for certain tasks than others. Each language has its own set of strengths and weaknesses. In this book, we introduce some of the better known design patterns in Python. You will learn when and how to use the design patterns, and implement a real-world example which you can run and examine by yourself.

                You will start with one of the most popular software architecture patterns which is the Model- View-Controller pattern. Then you will move on to learn about two creational design patterns which are Singleton and Factory, and two structural patterns which are Facade and Proxy. Finally, the book also explains three behavioural patterns which are Command, Observer, and Template.

                Approach

                This book takes a tutorial-based and user-friendly approach to covering Python design patterns. Its concise presentation means that in a short space of time, you will get a good introduction to various design patterns.

                Who this book is for

                If you are an intermediate level Python user, this book is for you. Prior knowledge of Python programming is essential. Some knowledge of UML is also required to understand the UML diagrams which are used to describe some design patterns.

                Code Download and Errata
                Packt Anytime, Anywhere
                Register Books
                Print Upgrades
                eBook Downloads
                Video Support
                Contact Us
                Awards Voting Nominations Previous Winners
                Judges Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software
                Resources
                Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software