Find your next favorite book

Become a member today and read free for 30 days
Learning Python Design Patterns

Learning Python Design Patterns

Read preview

Learning Python Design Patterns

ratings:
4.5/5 (3 ratings)
Length:
169 pages
1 hour
Released:
Nov 25, 2013
ISBN:
9781783283385
Format:
Book

Description

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.

Released:
Nov 25, 2013
ISBN:
9781783283385
Format:
Book

About the author

Gennadiy Zlobin works as a lead software engineer in a Russian music service, Zvooq.ru. He has been using Python as primary language for more than four years, enjoying its elegance and power on a daily basis. His professional interests include highload software architectures, good engineering practices, Android OS, and natural language processing.He previously worked for a company who had the first search engine in Russia, Rambler. He was involved in an airline tickets meta search service and Rambler’s index page.


Related to Learning Python Design Patterns

Related Books

Related Articles

Book Preview

Learning Python Design Patterns - Gennadiy Zlobin

Table of Contents

Learning Python Design Patterns

Credits

About the Author

About the Reviewers

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. 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

2. Creating Only One Object with the Singleton Pattern

A module-level singleton

A classic singleton

The borg singleton

Implementation in Python

Summary

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

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

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

6. Encapsulating Calls with the Command Pattern

Command Pattern terminology

Use cases of the Command design pattern

Advantages and disadvantages of the Command design pattern

Implementation in Python

Summary

7. Redefining Algorithms with the Template Method

The Template Method design pattern

The benefits of the Template Method design pattern

Using hooks

Implementation in Python

Summary

Index

Learning Python Design Patterns


Learning Python Design Patterns

Copyright © 2013 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

Production Reference: 1181113

Published by Packt Publishing Ltd.

Livery Place

35 Livery Street

Birmingham B3 2PB, UK.

ISBN 978-1-78328-337-8

www.packtpub.com

Cover Image by Aniket Sawant (<aniket_sawant_photography@hotmail.com>)

Credits

Author

Gennadiy Zlobin

Reviewers

David Corne

Kamilla Holanda Crozara

Sakis Kasampalis

Acquisition Editors

Kunal Parikh

Llewellyn Rozario

Commissioning Editor

Sruthi Kutty

Technical Editors

Vrinda Nitesh Bhosale

Rohit Kumar Singh

Copy Editors

Alisha Aranha

Sarang Chari

Janbal Dharmaraj

Dipti Kapadia

Gladson Monteiro

Karuna Narayanan

Project Coordinator

Suraj Bist

Proofreader

Simran Bhogal

Indexer

Hemangini Bari

Graphics

Abhinash Sahu

Production Coordinator

Nitesh Thakur

Cover Work

Nitesh Thakur

About the Author

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.

I would like to thank my wife, Jane, for her patience and support. I really appreciate it.

I am also grateful to my parents, Galina and Vitaliy for believing in me. I love all of you.

About the Reviewers

David Corne is a professional Software Engineer based in Birmingham, UK. He works for an engineering company that makes CAD/CAM software. The application he is working on is written in C++ with a C# view layer in order to use WPF.

However, he has a keen interest in Python. He has made many varied applications in Python. These range from a real-time updating editor for Markdown, to a utility for dice rolling, and PDF reading.

Kamilla Holanda Crozara is in her last year of college and is studying Software Engineering and works at National Institute of Standards and Technology as a Guest Researcher. She started to learn Python around two years ago, and it's her favorite language although she has some experience with C, Java, and Perl languages. She's a Linux user and has a special interest in contributing towards open source projects.

Sakis Kasampalis is based in the Netherlands, where he currently works as a Software Engineer for a location-based content B2B provider. When he is not writing C++ and Rails code for a living, Sakis enjoys playing with his mbed microcontroller and studying about programming, software engineering, and operating systems.

He is not dogmatic about particular programming languages and tools; his principle is that the right tool should be used for the right job. One of his favorite tools is Python because he finds it very productive.

Among his FOSS activities is maintaining a GitHub repository related to implementing design patterns in Python, which is available at https://github.com/faif/python-patterns.

www.PacktPub.com

Support files, eBooks, discount offers

You've reached the end of this preview. Sign up to read more!
Page 1 of 1

Reviews

What people think about Learning Python Design Patterns

4.3
3 ratings / 1 Reviews
What did you think?
Rating: 0 out of 5 stars

Reader reviews

  • (5/5)
    great book