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
8
votes
2 answers

FCMMessagingService in clean architecture?

I am developing an app where I am using Firebase Cloud Messaging. And I am using clean architecture for my app. I want to know where(in which layer:data, domain, presentation) is the best solution to put my classes which are called…
user6450105
8
votes
1 answer

Clean Architecture: UseCase Output Port

I have a question regarding the "Use Case Output Port" in Uncle Bob´s Clean Architecture. In the image, Uncle Bob describes the port as an interface. I am wondering if it has to be that way or if the invoked Use Case Interactor could also return a…
8
votes
2 answers

Clean Architecture - Robert Martin - Use Case Granularity

I am considering implementing Robert Martin's Clean Architecture in a project and I am trying to find out how to handle non-trivial use cases. I am finding it difficult to scale the architecture to complex/composed use cases, especially use cases…
8
votes
1 answer

Where to put REST API Calls in Uncle Bob's Clean Architecture?

I'm trying to use Uncle Bob's clean architecture in my android app. So, I followed this guy's great implementation based on RxAndroid, Dagger 2 for DI. I know that to get data from data stores (Cloud or local db or disk), the Interactors (Use Case…
Rami Jemli
  • 2,550
  • 18
  • 31
7
votes
2 answers

Right place to map to Domain in Android clean architecture

Me and my colleague are having a debate as to where would be the right place to map our entity objects or remote dto objects to plain simple domain objects. Our structure looks like this. source(includes dao) > repo(includes source) >…
ThanosFisherman
  • 5,626
  • 12
  • 38
  • 63
7
votes
1 answer

Where to perform state changes with Clean Architecture in Flutter?

When using Clean Architecture with flutter we see a diagram similar to this: (I wrote MobX package as an example, but it could be anything like BLoC, Redux...) I may have a problem with this diagram since the Store resides in presentation layer and…
Sxndrome
  • 360
  • 2
  • 11
7
votes
1 answer

Jetpack Paging 3 inside java/kotlin module

I'm developing an app with clean architecture principles. I've a domain module which is a Java/Kotlin module and it hasn't android dependencies and a domainImpl module which is an Android module and has dependencies to local, remote and domain…
7
votes
2 answers

Clean Architecture and Asp.Net Core Identity

I'm trying to abstract Asp.Net Core Identity from my Application in order to respect a Clean Architecture. Currently, my project is divided into 4 projects : WebApi, Infrastructure, Application and Core. I want all configuration of Asp.Net EF Core…
7
votes
1 answer

Android specific code in clean architecture

I've read multiple clean architecture tutorials for android, but all of them had very basic structure with simple network calls which leaves me wondering. What I want to know is where should I put code that handles accelerometer, geofencing,…
SMGhost
  • 3,867
  • 6
  • 38
  • 68
7
votes
3 answers

Clean architecture UseCases vs Controller with functions

I just started reading about clean architecture and I'm confused on the definitions of usecase implementations. Consider a controller class having set of functions that accepts T and returns R after executing some logic interface IController { …
Jegan Babu
  • 1,286
  • 1
  • 15
  • 19
7
votes
1 answer

How to implement Asp Identity in Clean Architecture with Asp net core

is there any code or docs about implement asp identity in clean architecture and how to apply CRUD operation in Application Layer with User Entity that inherit from IdentityUser in Domain Layer I implement Asp identity in Domain Layer any ideas…
ahmedlight
  • 83
  • 2
  • 7
7
votes
3 answers

Logger in Clean Architecture

I'm trying to apply Clean Architecture in my PHP application. At the moment I have my business logic entity User and service UsersService. UsersService collects all of the use cases related to the User entity. UsersService->createUser(someData)…
7
votes
1 answer

Android app clean architecture: Should data layer have its own model classes?

What´s the best approach when developing an Android app and trying to follow clean architecture guidelines (but not extremely strict - cause that may be overkill for smaller projects). In my case, I am unsure which approach is the best (if there is…
Elias
  • 563
  • 4
  • 18
7
votes
2 answers

Android clean architecture's Layered structure

I'm building an android app with clean architecture using MVP pattern, and repository pattern at the data layer. I'm a little confused about the business objects. Should there be an object to use in the presentation and another type of same object…
stav elmashally
  • 193
  • 2
  • 8
7
votes
0 answers

Android clean architecture - where to put googleApiClient calls?

i plan to use clean architecture with MVP. I am beginning a android project using the clean architecture approach that uncle bob endorses. i've downloaded a template project that is kind of like a starter template to kickstart you when using clean…
j2emanue
  • 60,549
  • 65
  • 286
  • 456