Menu

A Rough Guide to Entities, Value Objects, Services, and UseCases
πŸ“°

A Rough Guide to Entities, Value Objects, Services, and UseCases

DEV Community: railsΒ·KaziuΒ·about 6 hours ago
#MIJeoyUU
#devtorails#devto#dev#value#user
Reading 0:00
15s threshold

Well, this is less about Rails and more DDD (Domain-Driven Design) and Clean Architecture territory, but hey

At a glance

Term In a nutshell Examples

Entity Something you tell apart by ID User, deal, order

Value object Something you tell apart by its contents Amount of money, phone number, address, period

Service object A box for putting procedures in Calculating tax, uploading to S3

UseCase One thing the user wants to do Registering a deal, confirming an order

Entity ─ something you tell apart by ID

A person is the same person even if they change their last name or move. On the flip side, two people with the same name and the same age are still different people .

Like this, an entity is something you tell apart by its ID (the fact that it's that one) , not by its contents.

user = User . find ( 1 ) user . update! ( name : 'Suzuki' ) # Even if the name changes, it's still id: 1.…

Continue reading β€” create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.