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
20
votes
1 answer

How to understand the VIPER clean architecture?

I recently discovered VIPER clean architecture and I started looking for sample tutorials on applying this architecture on the Android platform. However, what I only found was sample projects which were confusing to me that is why I want to follow a…
19
votes
1 answer

create DTOs, BOs and DAOs for NestJs REST API

I would like to get into creating REST APIs with NestJs and I'm not sure how to setup scalable layer communication objects. So from the docs on how to get started I come up with a UsersController dealing with the HTTP requests and responses, a…
Question3r
  • 2,166
  • 19
  • 100
  • 200
19
votes
2 answers

Clean Architecture Design Pattern

https://8thlight.com/blog/uncle-bob/2012/08/13/the-clean-architecture.html I have some question about this pattern. The Database is at outter Layer but how would that work in reality? For example if i have a Microservices that just manges this…
18
votes
2 answers

Flutter/Dart: Subclass a freezed data class

I am using the following plugin: https://pub.dev/packages/freezed I want to subclass a freezed data class to provide additional functionality in my data layer. So I have my data class which looks like: import 'dart:ui'; import…
Marco Papula
  • 741
  • 2
  • 8
  • 18
18
votes
1 answer

What is the differece between a 'Use Case Interactor' and a 'Service' in Clean Architecture?

I don't really understand the difference between a Use Case Interactor and a Service in Clean Architecture. Is a domain service just a collection of "Use Case Interactor methods"? I want to implement the clean architecture in my ASP.net Core…
18
votes
2 answers

Uncle Bob's clean architecture approach - what is recommended package structure?

I'd like to know if I'm using Clean Architecture the right way. I am trying to lay it like this diagram: I've read that the package structure should be arranged by use case but I'm having difficulty following how that would be done. Let's take a…
j2emanue
  • 60,549
  • 65
  • 286
  • 456
17
votes
3 answers

Golang Transactional API design

I'm trying to follow Clean Architecture using Go. The application is a simple image management application. I'm wondering how to best design the interfaces for my Repository layer. I don't want to combine all repository methods into one single big…
17
votes
2 answers

Clean Architecture - Robert Martin - How to connect use cases

I'm trying to implement the Clean Architecture described by Robert Martin. More specifically I'm using VIPER which is an iOS version of Clean Architecture. The problem I have is as follows: The user starts looking at a map with places (pins) on…
Rodrigo Ruiz
  • 4,248
  • 6
  • 43
  • 75
16
votes
1 answer

What is the difference between repositories and usecases?

I'm creating a chat application using clean architecture, I want to check if the user is logged in when the app starts, and open the login screen if he is not logged in, so my questions are: What is the best way to implement that? Should I make…
Mathew Hany
  • 13,310
  • 4
  • 19
  • 16
15
votes
3 answers

How to use Clean Architecture in Microservices?

I just finished reading Uncle Bob's "Clean Architecture" and now wondering how to apply it in the context of microservices! On one hand, I think that microservices fall in the "Framework-Drivers" layer since it's an implementation on top of…
Hassen
  • 6,966
  • 13
  • 45
  • 65
15
votes
3 answers

Clean Architecture : why not using the entity as request model of the use case (interactor)

I have read the PPP book and clean code, coder and architecture books. I know that: Clean architecture is a layered architecture What is it like being open layered or close layered architecture Clean architecture books suggests that each layer can…
15
votes
2 answers

Clean Architecture, UseCases and Entities

Okay, so I just started a new Android project and wanted to try implementing the Clean Architecture by Uncle Bob. I have a nice beginning using RxJava and stuff from GitHub samples & boilerplates and Fernando Cerjas' blog (like this article), but…
w00ly
  • 455
  • 1
  • 5
  • 18
15
votes
1 answer

Clean Architecture - how to address database transactions?

In 'clean architecture' the interactors (use cases) are responsible for defining busines logic. Most of the examples define use cases in such a way: public MyUseCase() { public boolean execute(...) { int id = repository.insert(a) if(id >…
Marcin
  • 893
  • 7
  • 19
14
votes
2 answers

How to implement the presenter in Golang according to the Clean Architecture?

Proper software architecture is key to create a project that is maintainable. What proper means is 100% subjective, but lately I like and try to follow Clean Architecture by Robert C. Martin (aka Uncle Bob). Although I really like the theory, it…
mark.sagikazar
  • 1,032
  • 8
  • 19
14
votes
2 answers

Trying to fit a "clean architecture" on an iOS app

Recently I’ve been rethinking my android architecture project, trying to adapt it to a more “clean architecture”, specifically, the kind of design suggested by “Uncle Bob”. Which it involves several layers of abstractions, a nice isolation of…
Víctor Albertos
  • 8,093
  • 5
  • 43
  • 71
1
2
3
73 74