Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Clean architecture clarification

I've been reading this from Uncle Bob:

http://blog.8thlight.com/uncle-bob/2012/08/13/the-clean-architecture.html enter image description here

I have several questions to clarify:

  1. Can outer circles refer inwards crossing multiple boundaries. For example can Controllers access data structures in Entities?
  2. What are differences between Enterprise Business Rules vs Application Business Rules. For example what are the differences for something like stackoverflow? What would stackoverflow's Application Business Rules and Enterprise Business Rules be?
  3. Are there example code that I can refer to, mainly focusing on web applications.

Thanks

like image 808
0xdeadbeef Avatar asked Mar 16 '14 20:03

0xdeadbeef


People also ask

What are the four layers of clean architecture?

Clean architecture vs. The logical layers of this style are as follows: Presentation layer ( accounts for the presentation to the user) Business logic layer (contains the business rules) Data access layer (processes the communication with the database)

How many layers are there in clean architecture?

At the stage of business idea validation, we can use a three-layer architecture. It will give us development speed for some time, which should be used to find product/market fit. After that, we can move to a Clean Architecture to be able to support functional enhancement.

Which is a principle that unique to clean architecture?

The most important one is the dependancy inversion principle which is the pillar of the clean architecture. It will become the Dependancy Rule. The second one is Single Responsibility Principle which will become the Common Closure Principle at architectural level.

What are business rules in clean architecture?

Strictly speaking, business rules are rules or procedures that make or save the business money. Very strictly speaking, these rules would make or save the business money, irrespective of whether they were implemented on a computer. They would make or save money even if they were executed manually.


2 Answers

  1. It's best if the circles don't cross multiple boundaries. Knowledge should be limited.
  2. Enterprise rules are rules that apply to more than one application. Application rules are specific to one application. There are many application based on the stack overflow idea, and they share many of the same business rules. Those rules would be enterprise rules. But there's only one stack overflow. The rules that make it unique are application rules.
  3. Yes, there are many examples. Just search for "Clean Architecture Examples". If you have a copy of either of my two books: "Agile Software Development: Principles, Patterns, and Practices" or "Agile Prinicples, Patterns, and Practices in C#", then the payroll case study is a good example of this architecture.
like image 52
Robert Martin Avatar answered Oct 19 '22 22:10

Robert Martin


In addition to Robert Martin's answer, I'd like to add.

  1. It's best if you can keep your dependency graph as flat as possible. If you're crossing multiple boundaries, the aren't really boundaries.

  2. (See Robert Martin's answer)

  3. In Addition to Robert Martin's books, you may also want to refer to my book Dependency Injection in .NET, which follows the same principles, and comes with extensive (.NET) sample code.

like image 36
Mark Seemann Avatar answered Oct 19 '22 23:10

Mark Seemann