Questions tagged [clean-architecture]

The Clean Architecture is a software architecture proposed by Robert C. Martin (better known as Uncle Bob). This architecture is similar to the Onion-Hexagonal-DCI-Architecture proposed by their respective authors. The base of this architecture is to follow and obey rules of the 'Dependency Rule'.

The Clean Architecture is proposed by Robert C. Martin, also known as Uncle Bob. This architecture is similar to the Onion, Hexagonal, Screaming, and DCI architectures. Though these architectures all vary somewhat in their details, they are very similar. They all have the same objective, which is the separation of concerns. They all achieve this separation by dividing the software into layers.

clean architecture diagram Robert C. Martin, The Clean Architecture, 2012

The foundation layers of The Clean Architecture are:

  • Entities (Enterprise Business Rules)
  • Use cases (Application Business Rules)
  • Interface Adapters
  • Frameworks and Drivers.

The rules are driven by The Dependency Rule, which states that:

...source code dependencies can only point inwards. Nothing in an inner circle can know anything at all about something in an outer circle. In particular, the name of something declared in an outer circle must not be mentioned by the code in the an inner circle. That includes, functions, classes. variables, or any other named software entity.

Finally, when obeying this rule and using this architecture it is proposed that:

By separating the software into layers, and conforming to The Dependency Rule, you will create a system that is intrinsically testable, with all the benefits that implies.

1110 questions
9
votes
2 answers

Blazor WebAssembly with Clean Architecture

I am working on a proof of concept project using Blazor WebAssembly. The project already has a React front end that I am hoping to replicate in Blazor. I have the following projects in my solution: Domain - contains entities and does not reference…
Newm
  • 1,313
  • 3
  • 16
  • 29
9
votes
1 answer

Entities vs use cases clarification

As far as i understand, use cases or interactors use entities to perform some action, whereas, entities holds our business rules. According to this definition: The use cases interact with and depend on the entities In what way use cases depend…
eddy
  • 193
  • 3
  • 8
9
votes
1 answer

Why does Clippy suggests passing an Arc as a reference?

I am checking Clippy findings in my code and found that the pedantic rule needless_pass_by_value might be a false positive. It says that: warning: this argument is passed by value, but not consumed in the function body help: consider taking a…
Akiner Alkan
  • 6,145
  • 3
  • 32
  • 68
9
votes
3 answers

JPA Clean Architecture

I'm refactoring a microservice according to Clean Architecture: Frameworks should be at the utmost layer. So I used the Adapter Pattern and Dependency Inversion to put org.springframework.data.repository.CrudRepository at the utmost layer. But how…
9
votes
1 answer

The Clean Architecture, usecase dependencies

Recently, I found my way to The Clean Architecture post by Uncle Bob. But when I tried to apply it to a current project, I got stuck when a usecase needed to depend on another usecase. For example, my Domain Model is Goal and Task. One Goal can have…
9
votes
1 answer

Clean Architecture Vs MVPC/MVC/MVP

I'm studing Uncle Bob Clean Architecture, and trying to get comparasion in many differents aspects about witch design pattern should I use for my IOS/Android Projects. Ok, I noticed that clean arch is very powerfull and rouboust, but at the same…
9
votes
2 answers

Combining Use Cases/Interactors in Clean Architecture

I'm developing an Android app whose architecture is based on Uncle's Bob Clean Architecture, and I've already implemented many of my UseCases/ Interactors without problems until now. I have the following use case: Search Room Main Success…
regmoraes
  • 5,329
  • 3
  • 24
  • 33
8
votes
1 answer

Clean Architecture: Cannot map PagingSource to PagingSource

My requirement is to display the notes in pages using clean architecture along with offline suppport. I am using the Paging library for pagination. And below is the clean architectural diagram for getting notes. Note: Please open the above image in…
8
votes
2 answers

Clean Architecture. UseCase usage?

I was wondering what is the exact application of UseCase in Clean Architecture. Since, nowadays when you have a remote data source or rest API, the heavy processes are done on the server-side so you don't have any logic to implement in UseCase. All…
reza
  • 1,354
  • 1
  • 7
  • 25
8
votes
2 answers

Layers in Hexagonal Architecture

I'm reading a lot about hexagonal architecture, but in all the examples that i'm looking, all folders and class ubication are different, and this looks a bit confusing to me. I've done a simple spring boot application with below folder structure.…
8
votes
1 answer

how to implement WebSocket with clean architecture and bloc library flutter?

i'm trying to implement WebSocket in flutter using clean architecture my problem is how to get data from data source cuz in the case of using rest APIs you simply request and await data and get it from the data layer but in real-time apps such as…
reza47
  • 650
  • 6
  • 16
8
votes
2 answers

Role of Input Ports in Clean Architecture

Can you explain me what are the benefits of such abstraction as Input Ports in Clean Architecture? Why not use Interactors / Use Cases directly? I understand the role of Output Ports - this way use cases don't have to know about presenters and other…
rasuru
  • 273
  • 1
  • 10
8
votes
1 answer

What is the proper way to provide Context to a DataSource with Clean Architecture, MVVM and Koin?

I am developing an Android application with Kotlin in which I need to get the current location of the mobile device. I've already found a way to do it in various examples, but I don't know how to integrate this logic according to Clean Architecture…
JoeM
  • 81
  • 2
8
votes
5 answers

Should Entities in Clean Architecture know of persistence mechanisms?

In the book 'Clean Architecture' (Robert C. Martin) p. 191, he states that "Entity is pure business logic and nothing else". I am unsure of how literal I should interpret this statement with respect to the entites knowledge of a persistence…
8
votes
1 answer

Clean Architecture and Cache Invalidation

I have an app that tries to follow the Clean Architecture and I need to do some cache invalidation but I don't know in which layer this should be done. For the sake of this example, let's say I have an OrderInteractor with 2 use cases :…
pdegand59
  • 12,776
  • 8
  • 51
  • 58