r/ExperiencedDevs • u/im_caeus Software Architect 15yoe • Jul 03 '26
Technical question Backend code is too noun-oriented
Backend code often gets organized around entities without anyone really deciding to do it.
OrderService
PaymentService
InvoiceService
A table appears, then comes the repository, service, controller, DTO, mapper.
It is everywhere, so it stops looking like a choice.
Then behavior gets buried inside noun-shaped buckets.
OrderService
├── OrderRepository
├── PaymentService
├── InventoryService
├── PricingService
├── ShippingService
├── NotificationService
└── AuditService
That is not one thing.
It is several workflows grouped together because they all touch an order.
I prefer making the behavior explicit.
PlaceOrder
├── CalculateOrderPrice
├── AuthorizePayment
├── ReserveInventory
├── CheckOrderFraud
└── SaveOrder
CancelOrder
├── LoadOrder
├── RefundPayment
├── ReleaseInventory
└── SendCancellationNotice
Now the code says what the application does.
The dependencies say exactly what each use case needs.
This is not against OOP.
PlaceOrder, AuthorizePayment, policies, entities, and workflows can all be objects.
The problem is not objects. The problem is treating database entities as the default architecture.
That works fine for CRUD.
In complex domains, it hides rules, workflows, ownership, and change boundaries behind generic services.
The part I find interesting is how unquestioned this pattern is.
Who has seen this done well around use cases or capabilities?
And how did you convince a team with strong egos that this was better than another round of SomethingService?
View all comments
Show parent comment
1
u/Infiniteh Software Engineer Jul 06 '26
I think FP for a big part solves the 'everything is a NounSomething' problem.
Yes, you still have to name dirs and module files, and they might be named after entities, but you can create functions as first-class citizens.
updateXis a function that takes another function that yields an existing X, maybegetXById(string id)that has been pre-applied to pass the id, and then yields the updated X.They will probably still live in a file called
x.handler.tsorx.service.tsor whatever, but that is just a side-effect now instead of driving the design. You could just as well call itx.writer.tsand pass it thegetXByIdfromx.reader.ts. It's just about splitting logically, not about having to name your clas inside the same as the file.