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 ...
candied_orange's user avatar
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 ...
amon's user avatar
  • 134k
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 ...
candied_orange's user avatar
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, ...
Robert Harvey's user avatar
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) ...
Euphoric's user avatar
  • 37k
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 ...
candied_orange's user avatar
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 ...
jflaga's user avatar
  • 351
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() ...
candied_orange's user avatar
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 ...
Filip Milovanović's user avatar
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"...
just me's user avatar
  • 653
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 ...
candied_orange's user avatar
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 ...
candied_orange's user avatar
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 ...
candied_orange's user avatar
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 ...
amon's user avatar
  • 134k
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 ...
Greg Burghardt's user avatar
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 ...
Doc Brown's user avatar
  • 203k
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 ...
amon's user avatar
  • 134k
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 ...
candied_orange's user avatar
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 ...
candied_orange's user avatar
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 ...
Pierre Criulanscy's user avatar
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 ...
Robert Bräutigam's user avatar
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'...
R. Schmitz's user avatar
  • 2,608
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 ...
candied_orange's user avatar
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 ...
doubleYou's user avatar
  • 2,767
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 ...
Filip Milovanović's user avatar
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 ...
ClemC's user avatar
  • 401
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 ...
Bernhard Hiller's user avatar
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 ...
Kain0_0's user avatar
  • 16k
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 ...
candied_orange's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible