Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Mastering Python Design Patterns

You're reading from   Mastering Python Design Patterns Start learning Python programming to a better standard by mastering the art of Python design patterns

Arrow left icon
Product type Paperback
Published in Jan 2015
Publisher
ISBN-13 9781783989324
Length 212 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Sakis Kasampalis Sakis Kasampalis
Author Profile Icon Sakis Kasampalis
Sakis Kasampalis
Arrow right icon
View More author details
Toc

Table of Contents (18) Chapters Close

Preface 1. The Factory Pattern 2. The Builder Pattern FREE CHAPTER 3. The Prototype Pattern 4. The Adapter Pattern 5. The Decorator Pattern 6. The Facade Pattern 7. The Flyweight Pattern 8. The Model-View-Controller Pattern 9. The Proxy Pattern 10. The Chain of Responsibility Pattern 11. The Command Pattern 12. The Interpreter Pattern 13. The Observer Pattern 14. The State Pattern 15. The Strategy Pattern 16. The Template Pattern Index

Common misunderstandings about design patterns

There are a few misunderstandings about design patterns. One misunderstanding is that design patterns should be used right from the start when writing code. It is not unusual to see developers struggling with which pattern they should use in their code, even if they haven't first tried to solve the problem in their own way [j.mp/prsedp], [j.mp/stedp].

Not only is this wrong, but it is also against the nature of design patterns. Design patterns are discovered (in contrast to invented) as better solutions over existing solutions. If you have no existing solution, it doesn't make sense to look for a better one. Just go ahead and use your skills to solve your problem as best as you think. If your code reviewers have no objections and through time you see that your solution is smart and flexible enough, it means that you don't need to waste your time on struggling about which pattern to use. You might have even discovered a better design pattern than the existing one. Who knows? The point is do not limit your creativity in favor of forcing yourself to use existing design patterns.

A second misunderstanding is that design patterns should be used everywhere. This results in creating complex solutions with unnecessary interfaces and hierarchies, where a simpler and straightforward solution would be sufficient. Do no treat design patterns as a panacea because they are not. They must be used only if there is proof that your existing code "smells", and is hard to extend and maintain. Try thinking in terms of you aren't gonna need it (YAGNI [j.mp/c2yagni]) and Keep it simple stupid (KISS [j.mp/wikikis]). Using design patterns everywhere is as evil as premature optimization [j.mp/c2pro].

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime