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

Chaining multiple use cases

I use Clean Architecture pattern in my app together with MVVM architecture. So I have UseCases for single operations, like for example, LoginUseCase, DownloadAttachmentUseCase etc. What I am curious about is, what if I want to chain multiple…
Ana Koridze
  • 1,532
  • 2
  • 18
  • 28
6
votes
3 answers

Single Responsibility Principle in Clean Architecture, Aggregating UseCases in one UseCaseManager which can provide UseCase based on In & Out Object

I want to implement Single Responsibility principle in my projects Domain layer (Clean MVVM). I've approximately 200 different use-cases which are being very hectic to manage. Now I'm thinking to create one UseCaseManager which can provide me…
6
votes
2 answers

Why is disposing DisposableObserver is important in this case

I working on android project with clean architecture. I have the below class: public abstract class RxBaseInteractor { private final CompositeDisposable disposables; public RxBaseInteractor() { this.disposables = new…
Marzouk
  • 2,650
  • 3
  • 25
  • 56
6
votes
1 answer

Can hibernate business objects be used as entities in a clean architecture?

In our project we use classes generated by eclipse hibernate plugin for persistence. The generated classes have following structure. MyClass extends BaseMyClass //POJO's, that are refenced in the hbm files MyClassDAO extends BaseMyClassDAO //DAO…
6
votes
1 answer

Rx-Swift Clean architecture

I want to design my swift app using clean architecture. I have read the link below on clean architecture for swift http://clean-swift.com/blog/ I have used these templates to create the app. I wanted to ask if this is the best architecture to use as…
A.S
  • 798
  • 1
  • 10
  • 32
6
votes
2 answers

What is the best practice of managing realm instance in Clean Architecture?

My project using clean architecture. In this situation, the UI layer is separate from Domain layer. So I think it would be better the UI layer doesn't own realm instance. As realm's doc recommend managing the realm instance in Activity's lifecycle,…
Zeatual Chang
  • 163
  • 1
  • 8
6
votes
4 answers

Clean architecture pattern Android

I have read several documents over clean architecture in general and Android specific as well. I totally like the idea of creating a separate module for each new feature but my concern is how do I organize my data layer objects ? As I want them to…
geekoraul
  • 2,623
  • 2
  • 21
  • 33
5
votes
3 answers

Can you share models between features with clean architecture?

I have the following folder structure for my application app core features feature1 domain entities entity1 entity2 entity3 …
anonymous-dev
  • 2,897
  • 9
  • 48
  • 112
5
votes
1 answer

Clean Architecture with paging3 and compose passing PagingData to domain layer

I am using clean architecture with paging 3 and trying to populate a lazyColumn. I have the following class in my data layer module and I don't want to pass the PagingData to the domain layer as I want to keep the domain free of any Android…
ant2009
  • 27,094
  • 154
  • 411
  • 609
5
votes
0 answers

Where I should put Excel/PDF generator class or function in Onion/Clean Architecture?

I want to add Excel and PDF generator in my new Solution in dotnet core 6. I following this…
yozawiratama
  • 4,209
  • 12
  • 58
  • 106
5
votes
0 answers

Not able to print debug message while unit testing in Flutter

I am testing a pretty straightforward use-case in Flutter. Inside the use-case class, I have a function that I'm invoking from my test. And I want to add some debug print statements to print the value of some variables inside the function of…
5
votes
2 answers

MVVM - Having a hard time understanding how to create the Domain layer in Clean Architecture

I'm trying to learn MVVM to make my app's architecture more clean. But I'm having a hard time grasping how to create a "Domain" layer for my app. Currently this is how the structure of my project is looking: My View is the activity. My ViewModel has…
DIRTY DAVE
  • 2,523
  • 2
  • 20
  • 83
5
votes
5 answers

'Null' is not a subtype of type 'Future>'

I am implementing the flutter project in TDD Clean Architecture by following this video: https://www.youtube.com/watch?v=lPkWX8xFthE&t=1s my code: class MockNumberTriviaRepository extends Mock implements NumberTriviaRepository {} void main() { …
Akila Ishan
  • 147
  • 2
  • 12
5
votes
1 answer

How Do I Define One-to-Zero-Or-One Relationships in EF Core with Identity and Clean Architecture?

I'm developing an ASP.NET Core Razor Pages application in .NET 5.0 using EF Core 5 with Identity for authentication/authorisation and I'm attempting to do this with a 'Clean Architecture'. The application implements 3 'types' of user: Supervisors,…
5
votes
1 answer

EF Core entity classes and Clean architecture

I am building a new ASP.NET Core 5 MVC app. I want to use clean architecture as outlined in Microsoft's web app architecture ebook. I am also studying eShopOnWeb sample application available here…