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".
263 questions
2
votes
2
answers
154
views
When using Clean Code with Ports and Mappers: which layer declares the Entity (Aggregate) factory interface and which one implements it?
So I was reading Eric Evans DDD book and one point that was not clear to me is which Layer (in case of using Clean Code) should be reponsible to:
define the interface contract for an Entity (...
0
votes
0
answers
62
views
Extending a complex codebase without breaking things [duplicate]
I have to extend a complex piece software and I wonder if I should make the changes directly "where they belong", or if I should try to not touch existing stuff and "plug-in" the ...
0
votes
1
answer
168
views
How do I encapsulate domain logic and preserve state in DDD+Clean Architecture?
(For context I am developing in Angular)
Historically my applications have tended towards the layered architecture that the Angular fraemwork leads you into.
However I feel that the next application I ...
0
votes
2
answers
338
views
C# - Entity handler correct use clean code
I have a question about setting up my service. My main concern is if the design is clean and in order. Whether it meets the SOLID principles and does not spill out on me.
I have entities like order ...
5
votes
2
answers
1k
views
Repository and Service Interfaces in an Accounting Software in Go with Uncle Bob's Clean Architecture
I'm trying to get hands-on experience with Uncle Bob's Clean Architecture in Go, but I'm running into some issues. Also, I'm not yet familiar with all of Go's idioms.
For testing purposes, I'm ...
2
votes
2
answers
2k
views
Refactoring a legacy codebase with a god Repository and incomplete Clean Architecture [duplicate]
I'm currently working on a large legacy project that tried to implement Clean Architecture combined with MVVM, but unfortunately didn't fully adhere to the principles.
One major problem:
The ...
4
votes
1
answer
255
views
How do I handle polymorphic domain models in a Clean Architecture data access layer?
Let's say I'm making a space 4X game (because I am!) and I have an ISpaceObject interface in my domain layer, with a number of classes such as Ship, Starbase, Planet, Wormhole, etc. implementing it. I ...
1
vote
2
answers
219
views
Split single repository/service into pieces in clean architecture?
I'm curious to know your opinion on how to organize code in services and repositories in the context of a three-layer architecture (controllers - services - repositories).
Let's say there is a User ...
0
votes
3
answers
776
views
Repository interfaces returning DTO in clean architecture used by query handlers
Repository interfaces are often defined in the Domain layer. This makes sense for command handlers, which call repository methods and return nothing. But what about query handlers that call repository ...
2
votes
2
answers
450
views
How to handle pagination logic in a layered architecture without making premature decisions?
I'm working with a layered architecture and I'm unsure where to place the pagination logic. This answer suggests that it's not a domain concern, which I think makes sense. In most cases, pagination ...
2
votes
2
answers
785
views
How should I implement data access with jpa to meet Clean Architecture/DDD
For the last few days I'm searching any information about compatibility of JPA and Clean Architecture/DDD. I found next ideas for decoupling application from hibernate.
Do not use @ManyToMany or @...
4
votes
5
answers
369
views
Clean Architecture - Chapter 23: Presenters and Views
Everyone!
While reading Chapter 23 of the book Clean Architecture, specifically the Presenters and Views section, I came across something rather unexpected where Uncle Bob states:
Every button on the ...
2
votes
2
answers
328
views
Clean Architecture Chapter 8 - Financial Data Mapper
I’m studying Clean Architecture, and I came across a technical concept in the diagram from chapter 8. In this chapter, the author states that the Financial Data Mapper implements the Financial Data ...
3
votes
1
answer
440
views
Clean Architecture using interfaces or Mediator approach?
I'm starting a new project and I want to follow a Clean Architecture(ish) approach.
I've modeled my projects in that manner (attached diagram).
For the API I'm using FastEndpoint since I like it, it'...
0
votes
1
answer
443
views
Should I create interfaces for each entity, or should I use plain classes?
I’m currently creating a class diagram to develop an application following the “Clean Architecture” guidelines by Robert C. Martin. I’m unsure about how to structure the “Entity” component, ...
2
votes
1
answer
157
views
Should our api-response-to-domain-entity transform functions be in the API/Infrastructure layer, or the Domain layer?
Should our api-response-to-domain-entity transform functions be in the API/Infrastructure layer, or the Domain layer?
We have a react-native mobile application written in TypeScript.
We have separated ...
2
votes
2
answers
528
views
Advanced Scenarios in Clean Architecture
We have a very complex and mature ASP.NET web application that is about 20 years old and has 5 million lines of code spread across roughly 30 project in a single monolithic solution.
It's running on ....
1
vote
2
answers
251
views
How to handle data-intensive functionality of domain objects in Clean Architecture?
I'm going to ask this question using a concrete example. An optimal answer would take into account that this is just an example for the general problem.
I'd like to implement a user management system ...
0
votes
1
answer
239
views
SQLAlchemy (ORM) details in service layer in Clean Architecture?
I'm trying to decide how to hide data layer details (joinedload of sqlalchemy) in clean architecture.
I have some dilemma about clean architecture. Please look at the code of some api endpoint (full ...
-1
votes
3
answers
729
views
Moving from 3-tier architecture to clean architecture
Generally, for a simple project: how do you move from 3-tier architecture to clean architecture? What I'm trying to do here is to get a feedback on how would the developer which understands 3-tier ...
1
vote
3
answers
353
views
Where to handle Validation Errors in Business logic layer?
I'm currently designing a multi-layered application and am trying to figure out the best practice for error handling within the Business Logic Layer (BLL).
Should I handle errors directly within the ...
1
vote
1
answer
359
views
Separation of concerns between business layer, data layer and presentation layer without losing information
I'm developing an api in Fast API using sqlalchemy to manage my ORM classes and operations with the database.
I'm dealing with some design decisions to have my classes as little coupled as possible ...
0
votes
1
answer
421
views
Clean Architecture: Why are the request (input)/response(output) data structures not consider dependencies of the interface?
In Uncle Bob's Clean Architecture, he provides the following diagram:
This diagram is used for discussing the Open-Closed Principle (OCP). I understand that the interface Financial Report (FR) ...
0
votes
0
answers
107
views
Is it really difficult to test these “Service” methods in this Rust Clean Architecture proposal? Is there some other catch I'm not considering?
I reproduced a small example of kerkour's Rust Clean Architecture on the Rust Playground.
The code is just an example and the methods code makes no sense at all.
This architecture leaks DB information ...
1
vote
1
answer
155
views
Need help on Clean Architecture with Service/Manager/Controller
I am developing an Android application trying to comply with Uncle Bob's clean architecture.
User interface has a text and a button. Button triggers a usecase (TextToSpeechUseCase) from viewmodel.
...
0
votes
1
answer
317
views
Is IRepository allowed to know about database entities?
I am trying to apply Robert Martin's Clean Architecture on my .NET project. In one of chapters about boundary, it talks about that database interface should reside in business logic component rather ...
3
votes
2
answers
751
views
What value does the mediator pattern add beyond dependency injection?
Does the mediator pattern add any value beyond dependency injection? I am encountering the mediator pattern for the first time in context of this sample application, which is meant to demonstrate how ...
1
vote
2
answers
300
views
CQRS: Multiple entry points for a single command
I’m trying to follow the Clean Architecture and CQRS within an application that, let’s say, create a product.
To achieve this, the application has 3 adapters, one for reading a file, another for ...
0
votes
0
answers
178
views
DDD - Managing Relationships between Domain Aggregates
To understand DDD better, I am trying to create the Domain Layer of an online class application. I have a concept of a Student, Tutor and Session.
I thought of having one aggregate called Session and ...
5
votes
4
answers
973
views
Clean architecture and components
I'm reading the book "Clean Architecture" from Robert C. Martin and there is something that has been puzzling me in most parts of the book.
When the author introduces the term "...
0
votes
1
answer
237
views
Where to put the reference to Application Insights in an application designed with the Clean Architecture template?
We are implementing an application by trying to follow the Clean Architecture template for C#.
Our application is an ASP.NET core web api and we want to implement the observability for that ...
1
vote
1
answer
521
views
Onion Architecture: Where to put Hangfire specific logic
We have a .net core app with the following folder / onion structure:
WidgetApp -> Core -> Application -> JobAutoStarter -> JobAutoStarter.cs
WidgetApp -> Core -> Domain -> ...
1
vote
1
answer
141
views
Clean architecture in webapp : how to compose a page which needs to call many use cases?
I'm writing a pretty common Symfony web application, in which HTML is server side rendered (it's not an SPA application).
To illustrate my question, let's take a pretty common fictional eshop ...
-3
votes
1
answer
303
views
How should I architect a cricket scoring app?
Cricket scoring is complex and I want to build an app in part to practice good design principles/patterns and develop a clean solution.
A few high level classes I have in mind are:
Match | Innings | ...
3
votes
4
answers
2k
views
Is validation part of presentation layer or business logic? [duplicate]
We're working on a new project (backend, API), following the "clean code" and "clean architecture" principles (described in Robert Martin's books), dividing our application into ...
1
vote
2
answers
231
views
Entities can move from one Clean Architecture use case to another using the controller?
I'm working on a project with the task of creating a route to checkout ticket purchases for events. In this scenario, I have a controller that receives the request with order data, client information, ...
0
votes
1
answer
455
views
How choose between Clean Arch and Hexagonal Arch(Ports And Adapters)?
I'm studying architecture patterns and I don't understand which type of scenario is more preferable to use clean architecture or hexagonal architecture. Is there something like that? For example, &...
6
votes
2
answers
4k
views
Where to define the interfaces of the infrastructure in a clean architecture and DDD?
I have been reading about clean architecture and following Domain-Driven Design. In all the examples I have found, the interfaces of the repository are defined in the domain.
However, it is in the ...
0
votes
2
answers
699
views
Should entities always be simple and mapped?
I am told everywhere that entities are only to represent the data structure, then entities should be mapped to a model and then the model possibly to a DTO.
The other way is similar, DTO -> model -&...
-1
votes
2
answers
1k
views
Best Practice for Integrating Domain Services with Infrastructure Layer in Clean Architecture [closed]
I'm currently implementing clean architecture in my project.
My application includes various types of communication protocols (TCP, HTTPS, etc.) implemented in the infrastructure layer.
These ...
2
votes
2
answers
595
views
Clean Arch: Where to put HTTP request inputs handling logic (dto) before calling the service layer
I'm refactoring a common web app (not spa but traditional server side html rendering).
The design/code organization follows more or the less the Clean architecture concepts (ie:
controller calls a use ...
3
votes
2
answers
761
views
Components in Clean Architecture
I'm a novice in architecture. Now I’m reading Clean Architecture and I don’t understand one thing. I'm wondering at what stage should I create components? Before any design or when I already have some ...
1
vote
3
answers
483
views
Is low code quality and lack of testing the norm in B2B software development?
I've been working at this company for about a year now. it's a growth company working in B2B. I'm one year out of university, with a major in computer science. I work in the web team, using an Angular ...
0
votes
1
answer
145
views
How to balance "Draft capabilities" in Clean Architecture: handling Partial Models and Database Integration
I have an app with "clean architecture" classic layers:
Ports (such as HTTP, GRPC, GRAPHQL resolvers)
Services (CRUD methods and others)
Adapters
Domain
My app has of course multiple &...
2
votes
3
answers
946
views
Streams and clean architecture
I am pretty new to async programming and the whole stream stuff, since i have a web programming background with php, where async programming and streams isn't really a big topic most time.
I try to ...
0
votes
1
answer
185
views
Validation logic dependencies and separation of concerns
I am going back and forth on an aspect of our FluentValidation and MediatR pipeline behavior implementation. We receive requests which, in a Mediator pattern, are mapped to command or query objects, ...
-2
votes
1
answer
124
views
Clean code: formatting rules, dependent functions, multiple calls [closed]
About formatting
Here are two scenarios in which the details of the formatting are described.
How should in the clean code way, this be formatted
Scenario 1: Dependent functions of dependent functions
...
13
votes
4
answers
5k
views
Is there a clean way to model methods that only make sense depending on the current state of the object?
Let's say that I have a class called Mission. This class is intended to represent a mission requested by a professor working in a faculty. Mission has a private enum field representing whether the ...
0
votes
2
answers
642
views
Clean Architecture with Microservices
I'm fairly new at system architecting and I'm looking for some advice. My company is revamping its order management system. Currently is a monolith system that scales very poorly and is difficult for ...
1
vote
1
answer
673
views
Designing Clean Architecture(Hexagonal) for a Spring Boot Application : Project Layout and Class Organization
I'm currently in the process of integrating Clean Architecture into my Spring Boot project and I'm seeking advice on the ideal project structure and the types of classes and projects that should be ...