Designing Modules in Python [ebook]

Designing Modules in Python is part of HashedIn’s training program for junior developers to get better at design. Today, we are making it available as a free ebook.

Download E-Book

Who is this ebook for?

This book is for people with some experience in an object oriented programming language. This book will help you get better at module/class level design. Hopefully, it will teach you to identify good design from bad.

Throughout this book, we use python to introduce various design patterns. However, knowledge of python is not required. If you understand classes and methods, you will have no problem understanding the material in this book.

How to use this book

To make the most of this book, read the requirements at the start of each chapter and write down your solution. Then read through the rest of the chapter and critique your solution.

Good design is obvious once presented. But arriving at that solution is difficult, especially if you are new to programming. Writing down your solution is the only way to realize the shortcomings of your design. If you read the chapter without writing, you will tell yourself “That was obvious. I would have solved it in a similar manner”

History of this book

At HashedIn, we run a training program for junior developers to get better at design. During one of these programs, we asked developers to design a module to send sms/text messages. We also asked them to call the sms module from 3 different client applications. They had 30 minutes to complete this activity.

After 30 minutes, we revealed a new set of requirements. Additionally, we set 2 hard rules for them to implement these requirements:

  1. Developers were not allowed to change the way client applications invoked their sms module
  2. Developers were not allowed to modify existing code. Instead, they had to write new code to address the additional requirements, without duplicating code.

20 minutes later, we again introduced a new set of requirements. And after another 20 minutes, we introduced the final set of requirements.

Initially, developers felt the problem was very simple. They were at loss to understand why design was even needed. Isn’t this a simple python function?

But as new requirements emerged, and because we gave them constraints (don’t change existing code) - they began to appreciate the various design principles. Some even developed a mental model to discern good design from bad.

Over time, we got the opportunity to review designs from several developers. We learnt how junior developers think when asked to solve a problem. Based on these patterns, we wrote a series of blogs on how to design modules in python.

This ebook is a more refined version of these blog posts.

Download E-Book

Contact Us

Learn more about our Services and Solutions