ruby-on-railsarchitecturemulti-tier

What is the difference between the clean and the n-tier architectures?


What is the difference between the clean and the n-tier architectures?


Solution

  • Both architecture styles apply layers to separate concerns, however they do that in a different way.

    So I think the clean architecture is a better choice.

    After 5+ years:

    As far as I can tell, the n-tier is about layering: presentation, application, business, data access below each other and each layer depends on the layer below it. You can do top to bottom or bottom to top development this way. I liked top to bottom. In the case of clean architecture and other related domain centric architectures everything depends on the domain. For example I define a repository interface in the domain and implement it in the data access and not the other way around that I do something in the data access and adjust the domain to be able to use it. My SQLs might be suboptimal this way, but it would be premature optimization if I would care about it and change the domain because of it. I can even write an in-memory repository for the domain tests and finish the SQL repository later, because it is not as important. Finding the right domain model is the hard part, many times you need a domain expert or become a quasi domain expert to know what classes describe your domain properly.