Does Clean Code Mean Clean Architecture?
Peter Smulovics
Distinguished Engineer at Morgan Stanley, Microsoft MVP, Vice Chair of Technical Oversight Committee, Chair of Open Source Readiness, and Emerging Technologies in The Linux Foundation, FSI Autism Hackathon organizer
When looking at some of the newer achievements around FINOS , like the introduction of https://calm.finos.org from Matthew Bain and co, I start to think about cleanliness in code, architecture, etc. But are these the same? When developers hear the term clean code, they often think of readable, maintainable, and well-structured code. On the other hand, clean architecture refers to a system’s overall design, ensuring separation of concerns and maintainability at a larger scale. But does writing clean code automatically translate into clean architecture?
Understanding Clean Code
Clean code, as popularized by Robert C. Martin (Uncle Bob), is about writing code that is:
A clean codebase is enjoyable to work with. It reduces technical debt, simplifies debugging, and improves collaboration. But can a codebase with clean code still have poor architecture? Absolutely.
Understanding Clean Architecture
Clean Architecture, also championed by Uncle Bob, is an approach to software design that ensures:
A system can have well-structured components but still contain messy, unreadable code within them. Conversely, a well-written codebase with no overarching architectural strategy may quickly become unmanageable as the system grows.
Where They Overlap and Diverge
Striking a Balance
To build robust systems, developers should aim for both clean code and clean architecture. Here’s how:
Conclusion
Clean code and clean architecture are not interchangeable. Clean code makes individual components easier to understand and maintain, while clean architecture ensures the entire system remains scalable and adaptable. Writing clean code is a step toward clean architecture, but it’s not a substitute for designing a well-structured system. To build truly maintainable software, developers must balance both.
What’s your experience with clean code and clean architecture? Do you find it challenging to maintain both? Let’s discuss!
Open Source AI for Financial Services @ FINOS
22 小时前Super interesting Peter! This is a really interesting perspective - I hadn't really thought about "clean code" as one of the drivers of AasC, but it intersects with my interests in the project of parsibility (auditability, machine readability, explainability, etc), interoperability, and repeatability. But all of these are certainly made better by clean code best practices.
Distinguished Engineer at Morgan Stanley
23 小时前Thanks for the mention Peter and an interesting article. One of the reasons we created CALM is also to understand if we can measure and therefore assure that the architecture we said we’d implement is what we built and if it remains aligned over time as the system is changed. Being able to maintain clean code and clean architecture is critical to ensuring the security of our applications as well as ensuring they function as intended.
Solutions Architect | Azure Cloud Expert | Enterprise IT Modernization | Cloud Strategy & Cost Optimization
1 天前I agree that clean code and clean architecture are related but not the same. While clean code focuses on the readability and maintainability of individual components, clean architecture looks at the overall structure and organization of the system. Writing clean code is definitely a step towards achieving clean architecture, but it also requires careful consideration of how different components interact and are organized within the system. Both are important for creating robust and maintainable software solutions.