Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

In his blog post The Clean Architecture Uncle Bob suggests a 4-layer architecture. I understand the separation between business rules, interfaces and infrastructure, but I wonder if/when it's necessary to have separate layers for domain objects and use cases. What added value will it bring, compared to just having the uses cases as "domain services" in the domain layer?

The only useful info I've found on the web about a use case layer is an article by Martin Fowler, who seems to contradict Uncle Bob about its necessity:

At some point I may run into the problems, and then I'll make a Use Case Controller - but only then. And even when I do that I rarely consider the Use Case Controllers to occupy a separate layer in the system architecture.

Edit:

I stumbled upon a video of Uncle Bob's Architecture: The Lost Years keynote, in which he explains this architecture in depth. Very informative.

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

I disagree with Uncle Bob's use of the term "use case" but I understand what he's getting at. I don't really want to quibble over the semantics of the term in any case.

For the sake of this question, use cases are application specific business rules.

Your question is really "when are separate layers needed for both enterprise business rules and application specific business rules?" And the quick answer is you need them when your application grows large enough to justify it.

If there are a small number of rules from either set, then it's just as easy to keep the implementation of those rules within a single application layer. If there are lots of rules for both sets, then you'll want to break them out to specific layers.

Uncle Bob lays out a rule that the inner circles shouldn't know of the outer circles in his architectural diagram. And that's ultimately the answer to your question. As the rules evolve and have clear delineation from the others then you'll need to isolate them out to separate layers.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.