126
votes
Accepted
Clean Architecture: Use case containing the presenter or returning data?
The Clean Architecture suggests to let a use case interactor call the actual implementation of the presenter (which is injected, following the DIP) to handle the response/display. However, I see ...
81
votes
Accepted
Is "Clean Architecture" by Bob Martin a rule of thumb for all architectures or is it just one of the options?
While the “Clean Architecture” is fine and has many advantages, it is important to remember that:
The Clean Architecture is largely Robert C. Martin's re-branding and evolution of related approaches ...
52
votes
Using a "Pass-through (God) Service" is bad, right?
This is not a God object.
It seems like it is because there is so much here, but, in a way, it's doing nothing at all. There is no behavior code here. This isn't an omnipotent God that does ...
43
votes
Accepted
Clean Architecture - Too many Use Case Classes
Do I really have to make 24 use cases?
Only if everything you write is CRUD.
Refer to the diagram below:
Your assertion is that you will have six different entities, and 4 methods (Create, Read, ...
43
votes
Accepted
Difference between Domain Driven Design and Clean Architecture
You are correct that both focus on separating the domain code from the application and infrastructure code. But that is where the similarities end.
In Clean/Hexagonal/Onion (or CHO in short) ...
36
votes
Is "Clean Architecture" by Bob Martin a rule of thumb for all architectures or is it just one of the options?
I really liked the concepts in the video The Principles of Clean Architecture by Uncle Bob Martin. But I feel like this pattern is like a combination of Abstract Factory and Builder patterns at its ...
25
votes
Clean Architecture: Use case containing the presenter or returning data?
In a discussion related to your question, Uncle Bob explains the purpose of the presenter in his Clean Architecture:
Given this code sample:
namespace Some\Controller;
class UserController ...
21
votes
Accepted
Is there a clean way to model methods that only make sense depending on the current state of the object?
What you've done here has a name. This is an internal Domain Specific Language (iDSL). It can be used like this:
void execute(PlannedMission plannedMission) {
plannedMission
.start()
...
17
votes
What should presenters return in Clean Architecture?
Let me try and complement the other answers by taking a slightly different perspective.
I think what you may be finding confusing is that there are (seemingly) a lot of "moving parts" in ...
16
votes
Accepted
Should business logic be in the app or in the backend?
It should be on a case-by-case basis but I would expect most of the logic to go in the backend.
Your interactor might still contain several methods ("Check ticket availability", "Add ticket to basket"...
15
votes
Accepted
Implementing clean architecture
I just read the book 'clean architecture' by Uncle Bob and really like the approach. But the big disappointment came when I tried to implement it in C#. I really hope you can help me with some ...
14
votes
Accepted
Clean Architecture: Should each view have its own presenter and viewmodel?
Is this correct? Did I understand the clean architecture?
If you want to create a solution consistent with clean architecture you have a number of issues.
Dependencies should only cross boundaries ...
14
votes
Accepted
Is it okay to have misleading struct and function names for the sake of encapsulation?
This is why we invented the word meta. You're packing the result structure with meta info that isn't strictly part of what you're returning. But the info is about what you're returning.
Just carve out ...
13
votes
Accepted
Interface Segregation Principle in Clean Architecture
In that particular example the use of Java as compared to C++ does indeed hide the benefit of interfaces. Interfaces (or more generally, late binding) are useful to break direct dependencies.
Direct ...
11
votes
Accepted
How does Dependency Inversion solve switch cases?
Dependency Inversion does not remove the need for if-else or switch statements. If these statements get removed, it is a side effect of using dependency inversion, not the goal. There are two main ...
10
votes
Accepted
Clean Architecture: Dependency Rule and Libraries/Frameworks
Your observation is correct. However, that does not mean the "Clean Architecture" approach is wrong in general.
One major technique to decouple things from "outer rings" like the database layer or ...
10
votes
Accepted
Clean Architecture and Microservices
The Clean/Onion/Hexagonal architecture applies most clearly to microservices when viewing each microservice in isolation. Each MS has its own model and its own use cases and defines its own external ...
10
votes
Accepted
Clean Architecture: May the Controller talk to the Presenter directly?
If the controller talks directly to the presenter you lose the ability to independently swap out controllers and presenters. They are now entangled. They know about each other.
If the controller ...
10
votes
Accepted
Clean Architecture - Controllers and Presenters
Is my first assumption right? Presenters implements/extends controllers?
Nope.
Lets read some text from the same page as Fig. 8.2
Open arrowheads are using relationships. Closed arrowheads are ...
9
votes
In Clean Architecture, aren't Entities another type of Boundary?
If you're only holding data in your Entities your domain model will become anemic, because the encapsulation is broken and the behaviors are all defined outside the entity, far from where the data are ...
8
votes
Is "Clean Architecture" by Bob Martin a rule of thumb for all architectures or is it just one of the options?
"Clean Architecture" is definitely "only" one of the options. I would argue it is one of the bad options for most projects, especially for object-oriented projects.
Here is a sentence-by-sentence ...
8
votes
Accepted
How to adapt Clean Architecture to a rich desktop application
I am using Clean Architecture for a rich desktop application since about a year now and it works well for GUI-heavy, event-based applications. It's not a good fit for a "real-time" game like a jump'n'...
8
votes
How to adapt Clean Architecture to a rich desktop application
ViewModel Architecture and
Clean Architecture are not the same.
In some ways they are incompatible. Please don't mix them carelessly.
The number one thing that separates them is cycles. ViewModel ...
8
votes
Accepted
Doesn't repository pattern in clean architecture violate Dependency inversion principle?
The central idea of the DIP is to eliminate any direct dependencies between higher-level modules and lower-level modules. To achieve this, an abstract, stable interface is placed between them, upon ...
8
votes
Accepted
Clean Architecture: Use case spanning multiple UI elements
OK, I think you you have a few misconceptions about the architecture itself and that this is tripping you up, so let me try to sort that out.
So, domain behavior (the business logic of the ...
7
votes
Clean Architecture: Use case containing the presenter or returning data?
Use case containing the presenter or returning data?
So, is any of these two alternatives the "correct" interpretation of the Use Case Output Port according to the Clean Architecture? Are ...
7
votes
C# WPF : Clean Architecture
Model-View-Presenter architectures try to uncouple the User Interface (view) from the application logic (presenter) and from the business logic (model). The "interactor" typically pulls data from the ...
7
votes
Accepted
Clean architecture, CQRS, and authentication?
Looks to me like your issue is:
I have a thread acting on behalf of a user. I don't wish to pollute my nice clean business logic with authorisation details. But my data store needs authorisation ...
7
votes
Accepted
Clean Architecture use case testing
or is it just Unit Testing?
There is nothing "just" about Unit Testing.
The distinction between Integration Testing and Unit Testing seems to be different in every shop. However, the most ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
clean-architecture × 221architecture × 54
domain-driven-design × 37
clean-code × 34
use-case × 23
design × 17
onion-architecture × 14
c# × 13
object-oriented × 13
java × 11
design-patterns × 10
enterprise-architecture × 10
hexagonal-architecture × 10
architectural-patterns × 9
dependency-injection × 8
android × 8
repository-pattern × 8
javascript × 6
object-oriented-design × 6
api-design × 6
microservices × 6
solid × 6
typescript × 6
domain-model × 5
layers × 5