Read on, and you will learn:
- why it is essential to understand software architecture
- how to improve understanding of a software architecture
- how to design and sustain good software architecture
Poor architecture can show in many ways. The code is hard to test, change and debug. The system is fragile. It’s also prone to security and performance issues. And no one fully understands it.
The codebase is first the place to look, but it’s best to start by asking someone familiar with the system to draw a few boxes and arrows to visualize the main components of the system. Then you can find those components in the codebase and go from there.
One of the best ways to figure out how a system works is to use a debugger.
Find a line in the codebase. Then place a breakpoint and execute the code. A debugger will generate a stack trace.
The stack trace can show all major components that were involved in producing a response to the request. When studying those components, focus on their purpose and not implementation details.
It’s a good idea to write things down as you learn. Otherwise, it’s too easy to forget important details. Once you document your knowledge, you can present it to a group for feedback.
Before trying to create a good architecture let’s define what it means.
- it expresses its purpose and responsibilities
- it is relatively easy to make additions and adjustments
- it is technology/framework agnostic
Use the following to help you create good architecture.
1. Follow principles of clean architecture
Uncle Bob is a software development veteran. His advice comes from decades of experience.
Requirements should dictate the architecture of a system. Therefore it is highly beneficial to figure out why and what you are trying to build. This idea leads to the next point.
Scaffold main classes/services and their interfaces before diving into code. You can even stub methods/endpoints with mocked data and build the first proof of concept.
Domain Driven Design is a methodology that bridges business domain and system implementation. It helps to ensure that the core of the system architecture is entirely dedicated to its business purpose.
TDD helps you in creating better interfaces. Classes end up having better-defined roles and are easier to reuse. And this is just one of many benefits of TDD.
SOLID is a set of principles promoted by Uncle Bob. Learn more at butunclebob.com/ArticleS.UncleBob.PrinciplesOfOod.
Lastly, the only constant in software is a change. So design your architecture to be flexible.