"Hello World" Layered Architecture vs Clean Architecture

September 12 · 5 mins read

Many weeks ago, I read an article which says this:

the best way to learn a field is to know the overall structure, but not many single isolated points

I think I’m very inclined to finding articles like that one because my mother is a preschool teacher and I might have gotten from her this inclination or desire of wanting to find a way to make things understandable to beginners or children. :smile:

That thing aside…

The article is saying that in learning something it’s best to have a bird’s eye view of what we want to learn before delving into the details (and maybe constantly review the bird’s eye view while learning about the details).

And that’s what this article is about. It just contains a bird’s eye view diagram of the Clean Architecture (with sample code), and its comparison to the Layered Architecture which many programmers are already familiar with:

(Layered Architecture on the left, Clean Architecture on the right)

Notice that in the Clean Architecture diagram, the Presentation and Data layers are pointing towards the Domain layer. And that the Domain layer owns the interface for the data repository (because as what Uncle Bob Martin said, “the client is the owner of the abstract interface”).

And of course, the object construction will be done in the main or the entry point of the application, also called the composition root:

static void Main(string[] args)
    var greetingsController = 
        new GreetingsController(
            new GreetingsService(
                new GreetingsRepository()));


If you want code you can execute, go here.

If you want to read an artistic way of describing the Clean Architecture, to go Uncle Bob Martin’s article, titled “A Little Architecture”, here.