This book is for Python developers, of any level, that want to learn everything needed to write elegant, organised, maintainable object-oriented software.
Object-oriented programming (OOP) can be confusing for beginners. Most Python books just teach you about classes, objects, fields and methods – without teaching the crucial concepts that show why organising software in this way is so powerful.
Python developers often then go on to work on object-oriented software, such as web applications built with Django, without having any clue of how to organise their code. This leads to software that is a nightmare to maintain, as adding new features often requires you to make breaking changes to existing working and tested code.
I wrote this book with the goal to demystify OOP for Python developers. Through clear explanations and real-world examples, we will explore essential OOP concepts such as encapsulation, abstraction, polymorphism, composition, inheritance, dependency injection, UML, SOLID principles, and design patterns -- giving you everything that you need to develop great, maintainable and elegant object oriented software.
What you will learn
The first part of the book assumes that you’re a complete OOP beginner, and introduces the very fundamentals of classes and objects, attributes and methods, access modifiers, static attributes and static methods, properties vs getters and setters. By the end of this section, you’ll have the tools to write and understand object-oriented software…
But tools alone aren’t enough! Writing great software requires understanding the principles that help you organise your code effectively. The rest of the book focuses on these time-tested principles, teaching you how to think, refactor, and communicate about well-designed, maintainable, and extendable OOP software. Each concept is introduced with an example that first violates the principle, followed by a discussion of the issues and a refactored solution -- helping you to really understand the principle and its applications.
Section Two covers the foundational OOP principles you’ll use throughout the rest of your encapsulation, abstraction, inheritance, polymorphism, coupling, composition (and its advantages over inheritance), and the fragile base class problem.
Section Three introduces Unified Modelling Language (UML) to visually model classes and objects, and the relationships between them in a standardised way.
Section Four dives into the SOLID principles, building on the concepts from Section Two. This section will deepen your understanding of how to assign responsibilities to classes and manage relationships between them.
Section Five introduces the "Gang of Four" design patterns. These patterns provide proven solutions to recurring problems in software design, reinforcing everything you’ve learned in the book. You will learn six useful design State Pattern, Observer Pattern, Facade Pattern, Adapter Pattern, Prototype Pattern and Abstract Factory Pattern.
By the end of this book, you’ll have the knowledge and confidence to write OOP code that is clean, scalable, and maintainable.
Requirements
Just the very basics of variables, functions, if statements, for loops.You need no knowledge of object-oriented programming to take this course.
I enjoy writing and reading (of course), hiking, stargazing, and getting into things. I don't mind coloring inside the lines as long as I'm the one drawing the lines.
I'm the co-author of forthcoming science fiction novel A Hole in Wednesday (July 2016, Meteor House), a prequel to Philip Jose Farmer's famous Dayworld series that Farmer started but never finished.
I am also the co-author with Phil Farmer of the short science fiction novel The City Beyond Play (PS, 2007 / 2012). Some of my shorter stuff has appeared in Abyss & Apex, Appalachian Heritage, Asimov's Science Fiction, Ideomancer, Mythic Delirium, Not One Of Us, Paradox, Space & Time, Star*Line, Strange Horizons, The Worlds of Philip Jose Farmer, and even the Journal of the American Chestnut Foundation. I also review science fiction and fantasy books for Publishers Weekly.
Most of the time I live in the 21st century. Not always, but I'm easy enough to find one way or the other.