Have you encountered code that are just a blob of code? Its just logic everywhere, and there are a ton of logic that should have been in a file, found randomly out of place in another. It is like finding random chopping board and spatula in your bed. No, it does not belong to the bedroom. It belongs in the kitchen. That is the same idea as clean architecture. The right logic, objects, and code should be at the right place doing their job there. While you can do your cooking in your bedroom, you know shouldn’t be else your mum or spouse will make sure thats the last time you’ll ever do on earth.
So in this article, we will talk about the simple idea of clean software architecture and clean architecture are screaming architecture.
Good architecture screams out the business use-cases
It is time to clean up our coding practices and start writing clean code.
Image src photosbymuddog
What is a good architecture
Your software architecture should scream about the use cases of the application. Just like the architecture of a house or a library, all that you see in this architecture should revolve around the use cases of a house or a library.
Your software architecture should not be about frameworks. It should not be supplied by frameworks. Frameworks are merely tools to be used, not architectures to be conformed to. If your architecture is based on framework, then it cannot be based on use cases.
Good architectures are framework, tools and environment agnostic. You still want your library regardless of what shelf brands there are in the market. Good architecture revoles around use-cases so that architects can safely describe these structures that support the use-cases without having to commit to any of these framework, tools, or environment. Such an architecture help us to refocus and recenter ourselves onto the most important part of the entire ‘project’, to ensure that the use-cases of the application can be met and supported by the architecture.
Getting the architecture separated away from the tools and framework allows the architect to decide the bricks, stones, or cedar later in the development phase after ensuring that the structure meets all the use-cases at hand.
A good software architecture allows decisions about frameworks, databases, web-servers, and other environmental issues and tools, to be deferred and delayed.
A good architecture allows you to decide on the tool, and framework much later in the project. A good architecture also allows you to change your mind on these decisions easily as well. Good architecture decouples use-cases with the implementation.
Good architecture is testable
Good architectures that revolves around use-cases allow you to test your use-cases without having to run your server. You don’t need the database to be running to run your test.
Your business objects should just be plain old objects with no dependencies on frameworks or databases. The use-cases objects should be based off your business objects. All can be tested without any considerations of framework.
A screaming architecture is an architecture that will scream out what is this architecture’s use cases. If it is about healthcare, then we can see how the use-cases related to patients, care managers or doctors can be visibly seen. The use-cases will stand out, where as the views and controllers can be deferred and you as a developer can understand what this project is possibly about.
As a software engineer, we have to ensure that we are generating good quality code; code that works (definitely), tested, easy to maintain, and will segregated based on its concerns. The end goal is for you to be the most productive to churn out good quality code. We are problem solvers and we will solve problems. Not hindered by the curses of spaghetti code (not clean and full of dependencies which makes it almost impossible to test).
Technology essentially can only solve problems if it’s working and well maintained. So this is one common issue that is not spoken about but can have huge dividend in the long haul. Let the interest compound from henceforth.
I find this youtube video about clean architecture super useful for people getting started with Clean Architecture