Search code examples
architectureentityuse-caseclean-architecture

Entity does not exist and only use case exist on SNS according to Clean Architecture?


I've read a book Clean Architecture: A Craftsman's Guide to Software Structure and Design (Robert C. Martin).

First of all, I've only read translated version into my native tongue so words for ideas from the book might not exactly match what written in English version but how I could explain enough that people here understood what I am writing about.

Book's explanation

On Business Rule section of the book, there are explanations about

  • Most important business rule
  • Entity
  • Use case

According to the book...

"Most important business rule" exists whether a system is automated or not. For example a bank sets N% interest to a load.

"Entity" represents "Most important business rule"

"Use case" represents application specific business rule which only exists if it is automated by a system.

My question

Web base app like a SNS can only exist if there is a system unlike a bank doing loan business which can possibly be done without a system. If I apply whats written on the book "Clean Architecture", a SNS app does not have any Entity and all business logics are Use Cases.

Is my understanding correct?


Solution

  • In his article (https://blog.cleancoder.com/uncle-bob/2012/08/13/the-clean-architecture.html) and his book Uncle Bob explains that

    "Entities encapsulate Enterprise wide business rules"

    and

    "If you don’t have an enterprise, and are just writing a single application, then these entities are the business objects of the application. They encapsulate the most general and high-level rules. They are the least likely to change when something external changes."

    So if you have an enterprise with a bunch of applications the "entities" might be in central library or service while if you have just a single application the "entities" encapsulate your applications most important/central business rules. It depends on your apps context.