Welcome to the second post from the GRASP series. GRASP stands for General Responsibility Assignment Software Principles. It is a great aid for Object-Oriented Design (but not really exclusive for OOP!). It is all about putting responsibilities in code structures such as classes/methods/modules in such a way it “makes sense”. The challenge A couple of […]
Category: software engineering

Where to put all your utils in Python projects?
This is a follow-up post to Stop naming your Python modules “utils”. This time, let’s see different options on organizing utility code. What is utility code? It is code that is created as a side effect when working on features but does not belong to where they are implemented. It still is necessary or convenient […]

The disenchantment of Python web frameworks
tl;dr Popular Python web frameworks have less significant differences than it appears. Then, there’s Django which makes all competition look micro. Even given the rising popularity of FastAPI, I strongly believe there’s room for at least one another big framework. Comparing Python frameworks Back when I worked for a software house – STX Next I […]
GRASP Controller pattern in Python
Welcome to the first post from the GRASP series. GRASP stands for General Responsibility Assignment Software Principles. It is a great aid for Object-Oriented Design (but not really exclusive for OOP!). It is all about putting responsibilities in code structures such as classes/methods/modules in such a way it “makes sense”. Controller – what is it? […]

Modular monolith in Python
Microservices are not the only way I remember when the microservices boom started. Truth to be told, it still echoes strongly to this day. You could see conferences agendas packed with talks about microservices, articles galore, finally books and frameworks. At some point, I was afraid to open my fridge. Everyone and their dog wanted […]

@staticmethod considered a code smell
Python offers quite a few built-in decorators that can be used to give methods of classes certain superpowers. @property turning method into a read-only field-like attribute is a classic example. Or @classmethod – a method that receives a class as a first argument, not an instance. Fun fact, this kind of method is usually called […]

How to implement a service layer in Django + Rest Framework
From this article you will learn: what is the service layer? the problem solved by a service layer how to refactor to services from ModelSerializers What is the service layer? A service layer is a set of classes or functions, called services, that together form an API for a single package or application. We can […]

Encapsulation is your friend, also in Python
What is encapsulation? Encapsulation is an act of deliberate limiting access to certain software components. The most common usage is to hide certain attributes of objects from other objects that use it. The most vivid example is the usage of so-called access modifiers, private and protected in languages that support it, for example, PHP: Running […]

Beware of chicken testing! (or mocks overuse)
Need for mocking Dealing with problematic dependencies is an indispensable part of software testing. Often, we cannot or do not want to rely on 3rd party service/network communication/hard drive etc., especially in unit-tests. The reasons vary; external dependencies are usually slow, fallible and difficult to put into the expected state before the actual test. Consider […]

Stop naming your python modules “utils”
Imagine the following situation: there is a software developer that is either adding new code or refactoring existing one by extracting a class/function. They have to place code somewhere, but it does not seem to fit anywhere. So what does a developer do? They create a new module – utils.py. Why utils is a terrible […]