Questions tagged [clean-architecture]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
71
votes
7answers
36k views

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 ...
46
votes
3answers
7k views

Using a “Pass-through (God) Service” is bad, right? [duplicate]

My team has developed a new service layer in our application. They created a bunch of services that implement their interfaces (E.g., ICustomerService, IUserService, etc). That's pretty good so far. ...
27
votes
5answers
13k views

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 ...
13
votes
1answer
5k views

Clean Architecture: Should each view have its own presenter and viewmodel?

I am still thinking about clean architecture and just ran into a question regarding the higher levels (Views and Presenters) I am posting Uncle Bobs picture first here that you remember what I am ...
7
votes
3answers
3k views

Difference between Domain Driven Design and Clean Architecture

I have been studying Clean Architecture (CA) by Robert C. Martin and have found it quite useful in promoting architectural standards for large applications. Through implementation of a case study, I ...
7
votes
2answers
3k views

Clean Architecture: Dependency Rule and Libraries/Frameworks

In Clean Architecture by Robert C. Martin the dependency rule points strictly from the outermost layer/ring to the innermost. As an example a Dependency Injection Framework should lie on the ...
7
votes
2answers
282 views

Why can't Entities leave the inner layers in the Clean Architecture?

I was reading about the clean architecture, and I don't get this part: Don't use your Entity objects as data structures to pass around in the outer layers. Make separate data model objects for that. ...
6
votes
2answers
603 views

Interface Segregation Principle in Clean Architecture

In Chapter 10 of Clean Architecture, Martin gives an example for the Interface Segregation Principle. I have some trouble understanding that example and his explanations. In this example we have ...
6
votes
2answers
266 views

What could be a good pattern for a code base that does a lot of A/B testing?

I develop in an environment where we tend to do a lot of A/B testing. I am curious to learn from others on how A/B testing code is managed in your code base? Do you mix your A/B testing code with ...
6
votes
3answers
202 views

Where to convert primitive types in meaningful types in Clean Architecture / Onion Architecture

The book "Implementing Domain Driven Design" (page 361) suggests to use special types to distinguish several kinds of IDs, e. g. using BookId(1) instead of just 1 of type Int or Long. In my Clean ...
6
votes
2answers
4k views

Doesn't repository pattern in clean architecture violate Dependency inversion principle?

From what I have read and seen clean architecture assumes that you have some entities which know nothing about persistence though at the same layer as they reside there might be an interface which has ...
6
votes
2answers
3k views

In Clean Architecture, aren't Entities another type of Boundary?

In the Clean Architecture, Uncle Bob defines Entities as enterprise-wide business rules and Interactors (Use Cases) as application-specific business rules. Also, he describes that Interactors are ...
5
votes
4answers
1k views

How to adapt Clean Architecture to a rich desktop application

I'm just learning about clean architecture and I'm trying to design a proof of concept for an application I want to build soon. In the Clean Architecture the Presentation layer and the Domain Model ...
5
votes
3answers
4k views

Should business logic be in the app or in the backend?

I've recently started applying the Clean Architecture while developing an Android application. And so I divided my application in 4 different parts. Data layer Contains the implementation of ...
5
votes
1answer
1k views

Clean Architecture: May the Controller talk to the Presenter directly?

From what I understand from the 'Clean Architecture', the controller determines which usecase to execute dependent on the input of the user. If the input from the CLI for example is invalid, the ...
5
votes
1answer
4k views

Clean Architecture and Microservices

Our team is in the planning stages of creating an enterprise solution for our back office. Our goal is to have one singular entry point for common tasks, such as changing an address or reprojecting a ...
5
votes
2answers
334 views

Inject package protected (internal) classes at runtime

I am referring to Robert C. Martins book "Clean Architecture" on the top of page 318. There he states: In the ports and adapters approach, the OrdersService and Orders interfaces have inbound ...
4
votes
3answers
691 views

Clean Architecture: Use case spanning multiple UI elements

So I'm currently trying to write a project using Clean Architecture. Its a Unity Engine project which doesn't make the task any easier. The Issue I'm running into however is much more basic and has ...
4
votes
2answers
3k views

Clean architecture, CQRS, and authentication?

I'm working on implementing my first clean architecture and CQRS application, I've stumbled across a bit of logic that's leaving me a bit stumped. I'm working on integrating authorization and ...
3
votes
3answers
2k views

Clean Architecture - Where to put business calculations when entities are autogenerated db first efcore?

I'm trying to switch to clean architecture from a traditional layered architecture approach and trying to figure out where to put business logic. Please consider the below scenario - Employee class (...
3
votes
1answer
163 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 ...
3
votes
1answer
250 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 ...
3
votes
1answer
360 views

Clean Architecture - Should you inject all entity dependencies?

According to "Clean Architecture", should you inject all entity dependencies (should you inject core business logic)? For example, if I have a vector entity, should that entity be injected into all ...
3
votes
2answers
227 views

Architecture for real time updates from the data in file system

I am trying to revamp my legacy application to make it scalable and performant. Its current architecture is something like this Consider a short-lived script that gets invocated 500k+ times a day, ...
3
votes
1answer
141 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? ...
3
votes
1answer
642 views

Clean Architecture use case testing

Use case interactors in the Clean Architecture consists of the application specific business rules. Interactors uses the Data Access Interface to fetch the required data from the data access layer. ...
3
votes
3answers
697 views

Should an interface be defined in the infrastructure layer if it's only used by an implementing class in that layer?

Overview If an application is being developed following a clean architecture / DDD approach, my understanding is that the application core or domain layer should contain classes and interfaces that ...
3
votes
0answers
105 views

data transfer objects between abstraction layers

I want to create an Express REST API and want to try following the clean architecture ideas. I was reading about it but didn't get the idea of the communication between the abstraction layers. Let's ...
3
votes
1answer
195 views

DDD: Type hierarchy of entities' property

Say I have an Delivery class which should have a Destination property (among many others). Destination can be an Address (country, city, address line, post code) or a Port (international code, name). ...
2
votes
1answer
861 views

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 ...
2
votes
2answers
157 views

How to create useful error messages in a JSON REST API without leaking implementation details across layers?

We're implementing a REST service with three main layers: Controller, Domain, Repository. The REST API is supposed to respond to error conditions with meaningful error messages. Suppose the general ...
2
votes
2answers
1k views

Clean Architecture: Is the Input Boundary necessary?

In Clean Architecture boundaries are interfaces, which I model in Python with abstract classes. The input boundary, which is between the controller and the interactor/use case does not need an ...
2
votes
1answer
1k views

Clean architecture and Repository pattern

I'm working in a new project and I'm trying to use the Clean Architecture approach with Repository pattern. I'm using .net core 3, C#, Automapper, MediatR and Dapper. I have these layers: Domain (in ...
2
votes
3answers
2k views

How to split up use cases in Clean Architecture? (Dealing with use case dependencies)

I am trying to understand Clean Architecture as explained by Uncle Bob. My application requires a user to do a test. A test consists of a collection of questions that a user needs to answer. A audio ...
2
votes
2answers
699 views

Clean Architecture - How to pass request data towards inner, domain level Use Cases?

Use Case Interactor: We can see it in this picture how does a request cross the layers until it reaches the Use Case Interactor. How does the controller pass the request towards the Use Case ...
2
votes
2answers
358 views

Clean Architecture and Persistence Annotations

If one wants to comply with the clean architecture principle 100%, they must not annotate the entities in the entities layer with database-specific annotations (like Hibernate, Neo4j, etc.). So, two ...
2
votes
1answer
1k views

Use case interactions in clean architecture

I'm experimenting with Clean Architecture for my turn-based strategy game project. I have use cases that form hierarchies and need to be coordinated with each other. I would like some advice on how to ...
2
votes
2answers
437 views

Uncle Bob's Clean Architecture - Dealing with anemic interactors, tiering, and front-end MVVM

Background In Uncle Bob's Clean Architecture, use case interactors are responsible for the orchestration of business objects to accomplish some user goal. As an easy example, an e-commerce application ...
2
votes
2answers
78 views

Mantain same entity data in different layers

I'm trying to split the use of a business entity (e.g. a post) thought an application uses, trying to obtain a clean architecture So I will likely have: A class model, where the business logic lives ...
2
votes
1answer
92 views

Is it good approach to create new viewModel class for every new Ui(Fragment/Activity)?

I am working on a project in which I am following clean Architecture from Google ... and for making code testable I am following an approach in which,I am creating a new ViewModel Class ViewModel ...
2
votes
2answers
493 views

What do I misunderstand about the mediator pattern?

I decided to use Mediator Pattern (with Mediatr) to call my application layer. It's cool and I got how to work with it sometimes, but sometimes I get confused. For example, when we publish a document ...
2
votes
2answers
64 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 ...
2
votes
0answers
814 views

How & Should we use Clean Architecture in Front-end?

Just a little explanation: "I'm used to be a solo front-end developer in my company and using default folder-structure and way of coding which vue-cli provided, it is good for a solo developer and ...
2
votes
2answers
307 views

Clean Architecture - What is the difference between Use Cases and Core Services?

I'm trying to apply Clean Architecture to a simple ASP.NET MVC Core app by following Microsoft's ASP.NET architecture guidelines and their eShopOnWeb sample project. In the standard Clean ...
2
votes
0answers
277 views

Clean architecture - how can a component become a micro service?

I've read and enjoyed the "Clean Architecture" book. So the first thing I tried to do is to implement my project with it. Where I work we follow a design method called IDesign in which the ...
2
votes
0answers
208 views

Clean Architecture Python Example: How to implement a Usecase/Interactor saving Data to a Database

I am struggling with the clean architecure. I have constructed a minimal example of how a usecase/interactor could talk to the database without being dependent on it: The use case: class ...
1
vote
2answers
129 views

How to organize database access logic for the infrastructure and application layer when avoiding ORM tools?

I'm trying create a .NET Core project and followed some guides to create a basic architecture Jason Taylor - Clean Architecture with ASP.NET Core 3.0 Sample project Clean Architecture Template I'm ...
1
vote
3answers
350 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 ...
1
vote
1answer
298 views

Domain Use Case

In my understanding of Uncle's Bob Clean Architecture, a Use Case (Interactor) is responsible for orchestrating the Entities. At the same time, it represents Application-specific rules. The business ...
1
vote
1answer
179 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 ...