2
  • I am reading "Clean Code" and "Clean Architecture" by Robert C. Martin but I don't understand if I have clean code, do I have clean architecture too?
  • If I have clean code and clean architecture, do I have good project structure? What is the difference between them?
  • Clean code, clean architecture, and good project structure, what is the correlation between them or how are they related?
  • How can I get good project structure, clean architecture, and clean code?
user4157124
  • 2,809
  • 13
  • 27
  • 42
dev-x
  • 897
  • 3
  • 15
  • 30

2 Answers2

7

"Clean Architecture" is about boundaries and dependencies between "sub systems" and components of your software system. It helps structuring your code for changeability. By that following "Clean Architecture" will give you a "good" project structure.

For further details on how "Clean Architecture" makes your project structure "scream" pls refer to my blog series: http://www.plainionist.net/Implementing-Clean-Architecture-Scream/

"Clean Code" is about the implementation of your "sub systems", components, classes and functions. It helps in structuring your code for readability and maintainability.

plainionist
  • 2,950
  • 1
  • 15
  • 27
1

If I have clean code, do I have clean architecture too?

Let's go to the primary source, here is what Uncle Bob says regarding your question:

Good software systems begin with clean code. On the one hand, if the bricks aren’t well made, the architecture of the building doesn’t matter much. On the other hand, you can make a substantial mess with well-made bricks.

A component is a grouping of related functionality behind a nice clean interface, which resides inside an execution environment like an application. If the SOLID principles tell us how to arrange the bricks into walls and rooms, then the component principles tell us how to arrange the rooms into buildings. Large software systems, like large buildings, are built out of smaller components.

I guess you see here, that the answer is "NO. If you have clean code, you do not have clean architecture yet", the same as if you have good bricks, you do not have a good building yet.

Next question.

If I have clean code and clean architecture, do I have a good project structure?

Looking at what Uncle Bob says:

This book describes what good clean architectures and designs look like so that software developers can build systems that will have long profitable lifetimes.

I would say "Yes if you follow everything that is advised in the book, that would be an amazing project"

Next question:

So, what is the difference between them? The clean code, clean architecture, and good project structure.

Clean code and clean architecture like "bricks and rooms", that we established. "Clean architecture" includes "good project structure", and also it includes the way different components communicate with each other.

Next question:

What is the correlation between them or how they are three related, how can I get good project structure, clean architecture, and clean code?

So you already know, that "good project structure" is a part of "clean architecture", let's not separate them. How can you get clean architecture and clean code? Just code. There is no other way. You write a code, then you let people read your code, if they do not make facepalm, that is a clean code. I am joking of course, after reading the book, you will know some good practices, that are better to follow, that will help you.

Here is my concentrated information from that book, from my opinion, all you need to know from the "Clean Code" book https://www.slideshare.net/DmytroTurskyi/clean-code-256238273

To build a clean architecture, you need to build an app, which would use database or web services. And for that of course you need an idea, like what kind of useful service my software will provide. If you do not have an idea, think about, what kind of app would be useful for you. If it will make your life better and easier, then this is a good app, and a good start to build a clean architecture, with the best attempts to apply everything you learned from the book.

Here is my kind of "notes" of the most important information from the "Clean Architecture" book https://www.slideshare.net/DmytroTurskyi/the-clean-architecturepptx.

enter image description here

Dmytro T
  • 111
  • 2
  • 5