-1

Upon using Clean Architecture for multiple Android projects, I always stumbling with a temptation on where is the best location to put the business logic. Based on my understanding Domain Model holds some business logic and value objects that solves problems like formatting or encoding, Use Cases on the other hand provides the "Screaming Architecture" concept to make actions and processes more readable in a business perspective but in abstract. There is also Repositories that are responsible for transmitting/receiving or storing data but can also have business logic in it.

My questions are:

  1. Is it possible for Use Cases to have business logic as well? If yes what kind of business logic it can have?
  2. What kind of business logic Repositories usually have aside from transmitting/receiving or storing of DTOs?
Bitwise DEVS
  • 2,858
  • 4
  • 24
  • 67

1 Answers1

2

Is it possible for Use Cases to have business logic as well?

Yes, said Robert Martin in 2012.

what kind of business logic it can have?

"The software in this layer contains application specific business rules." Note that application specific is distinct from "enterprise wide".

What kind of business logic Repositories

I would not expect business logic in repositories.

"your business rules simply don’t know anything at all about the outside world."

Would be a strange statement to make if including business logic in repository implementations was a normal/common/desirable pattern. Repositories are, for the most part, plumbing that we use to move information around.

VoiceOfUnreason
  • 52,766
  • 5
  • 49
  • 91
  • Every time I came across on a documentation related to Clean Architecture, they always mention that repositories do also cater business logic like from this one: https://developer.android.com/topic/architecture/data-layer Or maybe the word "containing" here is a different context? – Bitwise DEVS Aug 02 '23 at 17:47
  • 1
    Or maybe different ideas of "business logic", or perhaps doing it the "clean architecture" way didn't work for them, so they adapted. That's a reason I prefer to give more weight to the "primary" sources, which for clean architecture would be Robert Martin's blog and book. – VoiceOfUnreason Aug 03 '23 at 12:42