Questions tagged [clean-architecture]

Clean Architecture is a book by Robert C. Martin that contains solutions to architecting software solutions. Collectively these concepts are referred to as "Clean Architecture".

Filter by
Sorted by
Tagged with
2 votes
0 answers
386 views

Clean Architecture, what are objects that does not completely fit as entities?

I'm reading chapter 20, "Business Rules", of clean architecture book, in this chapter Uncle Bob defines entities as: An Entity is an object within our computer system that embodies a small ...
0 votes
2 answers
135 views

May the left-side know the right-side when using CQRS with Hexagonal?

I'm trying to use the hexagonal architecture but I want the flexibility to make CUSTOM queries right to the database (or cache) to populate DTOs right from the left-side without passing through the ...
  • 109
6 votes
1 answer
421 views

How does Dependency Inversion solve switch cases?

I want to understand how Dependency Inversion gets rid of switch cases. Consider a service that needs to communicate with several databases. class StockUpdater { private final DataStore datastore; ...
  • 222
1 vote
3 answers
4k views

What is the responsibility of Infrastructure layer in a clean architecture?

I am trying to follow Clean Architecture by Uncle Bob. I have 3 layers: Core (Hosts business logic, and is the central layer) Application (Host application usecases, and is directly above the core) ...
-1 votes
2 answers
874 views

Clean Architecture, good approaches to avoid hard-coding the creation of entities on the Use Case

I have an Use Case that has an UseCaseInput (which is a parameter object of the use case) and an UseCaseOutput which is the output object, the UseCaseInput has lots of parameters in which will be used ...
0 votes
1 answer
57 views

API controllers modeling

I'm developing an API with ASP.NET, but I'm having some questions about the best way I should develop the controller layer for the products. I'm having these questions because each product will have ...
1 vote
1 answer
67 views

Adapt very different adapters to an Interface

I'm building a service to send push notifications to the user. At first, I designed an Interface for the push notification adapters, something like this: interface PushNotificationAdapterInterface { ...
1 vote
2 answers
220 views

Should the Use Case be responsible for transforming its primitive parameters into typed data for the Entity to use?

I'm building a Use Case for creating blog posts, this Use Case has its own "DTO", which is basically a parameter object with only primitive data, as follows: Use Case's DTO (Parameter Object)...
2 votes
2 answers
553 views

Should an Use Case method receive a "pre-filled" entity or a DTO as a parameter?

I'm building a use-case for creating blog posts, at first I thought of using an entity as a use-case parameter, and this entity would be created by the layer that calls Use Case, in my case a ...
2 votes
2 answers
805 views

If Entities, in the Clean Architecture, are enterprise wide rules how different applications consume them?

In this post, Uncle Bob writes: Entities encapsulate Enterprise wide business rules. An entity can be an object with methods, or it can be a set of data structures and functions. It doesn’t matter so ...
0 votes
1 answer
102 views

Clean Architecture - Support plugins that can add new entities? [closed]

I'm following Uncle Bob's clean architecture for my application. However, I wish my application to be extensible via plugins. More specifically, I want the plugins to be able to add new entities and ...
1 vote
2 answers
242 views

Catch "foreign" exception in adapter and convert them in own business exception is a good practice?

I am currently thinking about some design choices regarding exception handling. My current architecture looks a little like this: You can see that I have a UI where a try-catch middleware is cathing ...
4 votes
0 answers
622 views

Best practice to reuse use cases in a clean architecture

Imagine a "clean architecture" in which you have two use cases. One of them is CreateCustomerHandler, and the other SignUpCustomerByGoogleAuthHandler. So, the ...
  • 149
0 votes
0 answers
48 views

Doing the same tasks from multiple places when using Clean Architecture and CQS?

I'm working on some tooling that will help speed up the process of setting up a new computer for new developers. I want the user to be able to execute many tasks either as one task or grouped together ...
  • 129
4 votes
2 answers
242 views

How to model classes that can be extendable?

I have recently inherited a codebase which has a weird problem and I am trying to search for an extensible solution that can solve my issue. Consider I have a model class that is used as a model to ...
3 votes
2 answers
122 views

Checking the user in almost all use cases

I have a web application that has Users that belong to Companies. A User can only belong to 1 Company at a time and they can manage their own company information. I'm using java spring and I'm ...
0 votes
1 answer
334 views

How do I implement a domain entity behaviour that depends on some external infrastructure?

I am in the process of developing some software using CQRS, ES and DDD. A part of the system is writing services for controlling devices and collecting data from them. Consider a "Start" ...
  • 11
0 votes
0 answers
414 views

Job Scheduling in clean architecture

Imagine having the entity Counter and a use case that creates it. Moreover the business logic requires that every time a counter gets created a background task that increases the counter every 1s must ...
  • 43
4 votes
2 answers
972 views

Clean Architecture, how does the use case interactor generate different outputs?

I'm trying to understand how do controller and presenters work in clean architecture projects and could use some help. Specifically about generating multiple outputs from the use case. In the Clean ...
3 votes
2 answers
1k views

What naming convention should I use in Clean Architecture?

in the code base of my job, we use clean architecture standards. So we have controllers, use cases, etc. To name them, we follow this template: {name}{type}, where type is one of the following values: ...
-1 votes
3 answers
151 views

Chain of responsibility look alike but choose handler at runtime

Currently I have an structure of PopUps and I've been thinking to use Chain of Responsibility pattern, but the difference is a popup can back to previous one PopUp and also can go to any other PopUp. ...
1 vote
1 answer
214 views

Clean Architecture: Controller creates a RequestModel instance or implements RequestModel?

I have checked many articles and discussions around the web. So we have the main diagram: So we have Controller pointing directly to RequestModel. So straight to the point, should I: Create a ...
0 votes
0 answers
247 views

In what layer should API be called in Clean Architecture - in Repository or in Use Case?

I am trying to implement Clean Architecture on my Android App with standard MVVM components. Almost every example I have found deals with simple business logic, i.e. simple CRUD operations over data ...
  • 181
4 votes
1 answer
1k views

Clean Architecture - Controllers and Presenters

I am having a hard time trying to wrap my head around the relationship between Controllers and Presenters in Uncle Bob's Clean Architecture. In most of his videos, he talks too little about ...
  • 81
1 vote
1 answer
280 views

In which layer should I load views on a Clean(ish) architecture?

I am trying to organize my architecture following the clean architecture while using some common practices/frameworks. I'm writing in PHP, but have no problem with other languages. The flow of my app ...
1 vote
1 answer
87 views

Proxy / Decorator Design pattern scalability to a lot of methods

I'm trying to solve a common problem of logging each method that calls 3rd party operation and I don't understand how to scale it up. Current implementation: public class ElasticsearchClient { ...
  • 141
0 votes
4 answers
100 views

Is web application routing Enterprise or Application Business Rules from the viewpoint of Clean Architecture?

From the one side, customer can order "I need products list on /products and conversion statistics on /statistics/conversion". In this case, we need to obey in and write something like: ...
6 votes
1 answer
180 views

How does Robert Martin's "Clean Architecture" deal with Progressive Web Apps (PWAs)?

According to Robert C. Martin's "Clean Architecture" you should try to structure your system in such a way as to separate low-level concerns from high-level domain concepts. Following this ...
9 votes
4 answers
3k views

What should presenters return in Clean Architecture?

In Clean Architecture, a use-case calls a presenter, based on the agreed output object. When the presenter is called, it returns a ViewModel used by the view. That is fine until you have more than two ...
1 vote
1 answer
370 views

How to make the controller framework independent in Clean Architecture?

Recently, I've been studying Clean Architecture and I have some doubts. I want to make a REST API that adheres to this architecture. To do that, I define my entities, use-cases, etc. For each endpoint,...
4 votes
2 answers
550 views

Hexagonal/Clean Architecture - threads, locks, synchronization

All the examples across the internet try to pretend that every application is run on a single thread. There is no problem with synchronization, multithreading etc. Uncle Bob, in his "Clean ...
0 votes
2 answers
144 views

Improving dependency inversion principle

Reading a little bit about Functional core & imperative shell pattern, I am wondering if the DI principle can be improved. What happen if instead of having an Infrastructure layer depending on ...
-1 votes
2 answers
727 views

Clean Architecture - Reuse exception handling code for a specific use case or repository function

I am implementing the clean architecture. The use case should not know details about the UI because the UI is in a more outer layer. Same goes for the data layer. For the data, the use case should ...
4 votes
1 answer
2k views

Moving shared CQRS/Mediatr Request Handler logic into services and avoiding code/logic duplicity?

We recently embraced Clean Architecture and CQRS, by way of Mediatr, in several of our new applications. A similar (SPA-based) demo can be seen here. For many of our WebApi-based projects, this worked ...
  • 1,337
0 votes
2 answers
247 views

Should default settings be considered as business rules from the viewpoint of "Clean Architecture"?

The examples of default settings: Default port for server applications Default resources directory for Java Applications Default Webpack config file ("webpack.config.js") My particular ...
8 votes
3 answers
5k views

Clean Architecture Gateway layer depends on outer layer

Looking at the clean architecture layers and flow diagrams, and implemented it my self in my applications, I've always wondered which layer is supposed to contain the DB, or any 3rd Party service or ...
  • 237
0 votes
1 answer
176 views

Correct Architecture for Monolith with Go

I'm designing a monolith RESTful API that potentially sometime in the future may turn into microservices. I'm also trying following Uncle Bob's clean code as well. My question lies in structuring the ...
  • 127
-1 votes
1 answer
212 views

Understanding Clean Architecture

Below is my understanding of the projects involved .However my confusion comes from the difference between Application/Core/Domain . Is it also correct to say Core = Application + Domain because i ...
1 vote
1 answer
496 views

How do proto models in gRPC fit into Clean Architecture

I know they say that clean architecture are guidelines, and individual projects will affect implementation, but is there a general thought on the correct implementation? A lot of times I see DTO ...
  • 147
2 votes
3 answers
1k views

What is a good naming convention for Interface Adapters, Use Cases / Interactors, Entities?

I'm using MVVM + Clean Architecture in my app. And I sometimes don't have any idea if my namings are good enough for each Interface Adapters, Use Cases / Interactors, Entities. For View Models, it's ...
-1 votes
1 answer
47 views

Clean approach for designing data related dependencies between different systems

I have the following situation in my current project: There is a system A which exports data, that will be consumed by system B. System A is something like a webshop which exports data like orders to ...
  • 279
3 votes
1 answer
1k views

How to handle complex business logic permissions in the database?

I have a system in development and part of the system is how permissions are handled, business logic rules for this are very complex so after lots of trials, we couldn't fit them directly in the ...
1 vote
3 answers
867 views

Do adapters get only called by usecases?

Suppose we have a layered architecture like onion architecture or clean architecture with three modules representing each layer: domain.py usecase.py databaseadapter.py The domain layer contains the ...
  • 137
0 votes
2 answers
2k views

What is enterprise logic, business logic in clean architecture?

I had go through Jason Taylor's link. He mentioned that The Domain layer contains enterprise logic and types and the Application layer contains business logic and types. The difference is that ...
  • 127
3 votes
1 answer
1k views

Business logic on the client side of a modern web app

If we look at the typical software architecture guide, it will have the domain layer, application services, and UI, where domain layer contains the business logic. This is a nice clean separation ...
1 vote
0 answers
132 views

Socket.io behind api gateway

So the architecture I am currently working with, we have an api-gateway that gets all the requests and publishes them to our Eventsystem/ or directly to our essential services(auth, etc). Now we want ...
3 votes
1 answer
205 views

Why dependency direction is determined by levels and not by change frequency?

Clean Architecture defines level as a distance from inputs and outputs. So Entities or business-objects are the highest level. What is a practical reason to make lower level dependent on higher level? ...
1 vote
2 answers
453 views

Clean Code: How much architecture code should be written if architecture is supposed to be fluid

I watched a video series from Uncle Bob on Clean Code. He makes a few points on architecture which I both agree with but I believe could have clarification. From Uncle Bob: The Interactor is ...
2 votes
1 answer
492 views

Moving authentication outside the domain layer

In discussion about an architecture decision that we do consider wrong and how exactly to address it, some lack of understanding on the matter arose. In dealing with authentication and authorization, ...
0 votes
1 answer
97 views

Mutli tenant app with onion architecture and multiple presentations

Currently I started designing a new multi tenant SaaS application based on the onion architecture in C# Using a rest web API to expose my services and consume them on 3 platforms. Two web apps (one ...
  • 183