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
65
votes
3 answers

Clean Architecture vs Onion Architecture

I have been reading up on the Onion Architecture and today I found out about Uncle Bob's Clean Architecture. For the life of me I cannot see any differences between them, they look identical (other than the naming convention). Is there any…
user3373870
  • 1,406
  • 2
  • 13
  • 17
49
votes
3 answers

How do you use transactions in the Clean Architecture?

No implementations of it that I can find online actually give you a framework agnostic and practical way of implementing it. I've seen several subpar suggestions towards solving it: make Repository methods atomic make Use Cases atomic Neither of…
aetheus
  • 671
  • 1
  • 7
  • 13
42
votes
6 answers

Clean Architecture: Combining Interactors

I've recently stumbled upon Clean Architecture, by Uncle Bob, and I'm curious to know whether Interactors can execute other Interactors. For example, these are my Interactors as of now: getEmptyAlbums, getOtherAlbums. Both have Callbacks that return…
Chris Rohit Brendan
  • 893
  • 1
  • 9
  • 20
40
votes
7 answers

What is difference between mvvm with clean architecture and mvvm without clean architecture in Android?

I'm learning about MVVM and Clean Architecture. Then I found some articles present about MVVM + Clean Architecture, but I still didn't get it about the difference between mvvm with clean architecture and mvvm without clean architecture. Any summary…
Stefanus Anggara
  • 2,333
  • 2
  • 11
  • 7
40
votes
3 answers

Questions about VIPER - Clean Architecture

I've been reading about Clean Architecture from Robert Martin and more specifically about VIPER. Then I ran into this article/post Brigade’s Experience Using an MVC Alternative which describes pretty much what I'm currently doing. After actually…
31
votes
5 answers

Nestjs Dependency Injection and DDD / Clean Architecture

I'm experimenting with Nestjs by trying to implement a clean-architecture structure and I'd like to validate my solution because I'm not sure I understand the best way to do it. Please note that the example is almost pseudo-code and a lot of types…
30
votes
3 answers

Clean architecture - where to put input validation logic?

Perhaps in the app I have a feature allowing users to send feedback using a form with some validation logic: name can be empty feedback message should be at least 5 characters Where would you put these validation logic, either in domain layer as…
Duy Pham
  • 1,179
  • 1
  • 14
  • 19
28
votes
1 answer

Android paging library with clean architecture

I was trying the paging library from Android Architecture Component but I have doubts integrating it in a clean architecture based project. Generally I have 3 modules: Main Module (App) Data Module (Android module with network and db…
27
votes
3 answers

Where i should put my DTOs in clean architecture?

Need to implement the clean architecture and struggling with DTO concept. As I understand, i can't use my domain objects in presentation layer (asp mvc) instead i should use DTO or viewmodel. I'm not sure where these DTOs should go. I have two…
Emad Ali
  • 447
  • 1
  • 6
  • 11
25
votes
6 answers

Confusing term Interactors in Clean Architecture

As per clean architecture, design Interactor is part which contains all business logic. The term Interactor is quite confusing to me. Interactor seems to me like interacting between two different layers like data and presenter. Is it the right term…
25
votes
2 answers

Clean Architecture: How to reflect the data layer's changes in the UI

I'm trying to make a design based on the Uncle Bob's Clean Architecture in Android. The problem: I'd like to solve is how to make the changes generated in one repository to be reflected in other parts of the app, like other repositories or…
Addev
  • 31,819
  • 51
  • 183
  • 302
25
votes
2 answers

Clean architecture clarification

I've been reading this from Uncle Bob: http://blog.8thlight.com/uncle-bob/2012/08/13/the-clean-architecture.html I have several questions to clarify: Can outer circles refer inwards crossing multiple boundaries. For example can Controllers access…
0xdeadbeef
  • 4,090
  • 8
  • 33
  • 37
22
votes
2 answers

Clean Architecture and authentication. Correct way?

I'm working on an Android app based on Clean Architecture pattern and I have doubts how to implement user authentication in a clean way. Is the following solution clean in terms of clean architecture? I would create use cases like below (executed…
Derek K
  • 2,756
  • 1
  • 21
  • 37
22
votes
2 answers

Clean Architecture: Use different model classes for different data sources?

I am currently developing a news feed android app. I try to design my app according to the principles of clean architecture. In the data layer I am using the repository pattern as a facade for the diferent data sources: remote data from an API…
Elias
  • 563
  • 4
  • 18
20
votes
3 answers

How can Hilt be used effectively in multi-module apps following CLEAN architecture principles?

I am building an Android app following the Clean Architecture Principles. Here is what I've got: app module: Contains all the Android dependencies. Uses MVVM with ViewModel from the arch components. ViewModels only communicate with UseCases, which…
1
2 3
73 74