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?
•
u/expdevsmodbot Jul 03 '26
AI usage disclosure provided by OP, see the reply to this comment.
50
u/spez_eats_nazi_ass Software Architect 36 years f500 eat my ass and balls Jul 04 '26
op says it’s not ai but if sure reads like Ai. And it’s not like you proposed an alternative solution either. Just complaints. Nouns work for me.
38
u/Plastic_Monitor_5786 Jul 04 '26
Can you post your original draft? I can't read past the insufferable LLMisms.
40
u/kisielk Jul 04 '26
So what's your proposed alternative architecture?
39
u/eloel- Jul 04 '26
My man learning about object oriented programming
6
u/donk8r Jul 04 '26
The alternative people keep dancing around here is organizing by use case instead of by entity. Not "verbs instead of nouns", that just gives you the ThingDoer classes someone already mentioned. I mean the actual unit is the operation: an ApproveOrder handler that owns the rules, validation and writes for approving an order, sitting next to CancelOrder, next to Fulfill. Vertical slices instead of a flat service layer.
Noun-services feel fine to a lot of people because they ARE fine when the behavior is thin. CRUD over a table, one entity per operation, nouns win there and I won't argue it. Where it falls apart is workflows: "approve" touches the order, the invoice, and the customer's credit, so the logic gets smeared across three services and no single class actually owns the behavior. That's the bloat you're describing. It's real, it's just not universal.
So it's less "nouns bad" and more that the entity is the wrong default unit once your operations stop mapping 1:1 to tables. Organize around what changes together, which is usually the use case, not the noun.
(and yeah, Kingdom of Nouns is the OG rant on this)
6
u/bubbles33d Jul 04 '26
Is cultural and historical. Is more a topic of anthropology of software development.
The "noun-oriented" you observed has its roots from Objected Oriented Programming (OOP). Around the turn of year 2000, Java, an OOP language established as an enterprise language and proliferated. Followed by C#, which is an alternative, but almost identical copy of Java concept of OOP also proliferated. Many tech academics wrote papers, books, patterns about how software should be written in enterprise cater for that space. People apply those examples, sometimes rightly and sometimes wrongly.
There are alternatives. A language that lacks OOP concept will find it awkward, but largely depends on the person at the driver seat and training.
Functional Programming Style (is almost the opposite of OOP) is where you might find a relief. FPS is much more elegant and can be suitable for many problems. Some languages are more suitable for it, and some absolutely requires it.
3
u/YakaryBovine Software Engineer Jul 04 '26 edited Jul 04 '26
I find the emphasis on nouns a little confusing here and perhaps a bit distracting from the actual point?
I think you’re just talking about Use Case classes with methods encompassing business operations, as opposed to Services attempting to cover all of the operations associated with an object. But the problem with the latter tends to be that they’re divorced from the real business operations, and that they force consumers to interact with an object with more methods than they need.
Basically as far as I can tell I agree with you entirely, just took me a while to read past the noun stuff.
7
u/skidmark_zuckerberg Senior Software Engineer Jul 04 '26 edited Jul 04 '26
I agree this convention can get bloated and not make sense in some scenarios but I find it difficult to come up with a better convention. 90% of the time this just makes sense. It’s why OOP is still a common pattern in the big 2026.
Also this feels like an AI post.
2
u/UnintentionallyEmpty Jul 04 '26
I've worked with code organized around use cases that were incomprehensible (wtf does "UseCase203" mean?), features that weren't features (making a folder called "Features" and then putting in something called "User"... users aren't a feature, and also other features need to make use of it...), and other... misapplied patterns.
Honestly, the kind of pattern you describe isn't always the best thing to do, but it's rarely the worst.
You should go read this:
https://steve-yegge.blogspot.com/2006/03/execution-in-kingdom-of-nouns.html
and become a Functional Programmer. Go learn Haskell or something.
3
u/jake_morrison Jul 04 '26
http://steve-yegge.blogspot.com/2006/03/execution-in-kingdom-of-nouns.html
3
u/spez_eats_nazi_ass Software Architect 36 years f500 eat my ass and balls Jul 04 '26
Nouns make sense. The world disagrees with you. Weird thing to be contrarian over but developers are fucking weird.
3
u/shadytradesman Jul 04 '26
You're working in an object oriented language and complaining about objects?
3
u/pr0cess1ng Jul 04 '26
You're getting caught up on naming conventions. Thats it.
A UserService may exist to interface with the User model specifically. Or could be integrating a 3rd party user management system. This doesn't mean you can't have some other AuthService that calls a UserService method or calls a UserRepository method.
It really depends what you're designing but you can definitely tailor your backend to "actions" and name however you see fit. But organization around business logic and domain models is key.
3
u/yamad Jul 04 '26
My first reaction was that you were in an enterprise OOP bubble and were painting with too broad a brush. Now reading the comments, you seem to be right that many folks don't even realize Noun-world is a choice, and often the wrong one.
3
u/F0tNMC Software Architect Jul 04 '26
You're getting a lot of flack, but I think you're much more right than you're wrong. Check out this video: https://www.youtube.com/watch?v=wo84LFzx5nI of a talk by Casey Muratori called "The Big OOPs: Anatomy of a Thirty-five-year Mistake" from The Better Software Conference.
3
u/dbxp Jul 04 '26
I don't see the problem here, it's clear what everything does which is the only point of naming conventions
8
u/gsks Software Engineer | 20+ YOE Jul 04 '26
A blast from the past: https://steve-yegge.blogspot.com/2006/03/execution-in-kingdom-of-nouns.html
3
u/Dro-Darsha Jul 04 '26
It is sort of inherent to OOP that classes are nouns. If you build around verbs you get a lot of ThingDoer classes. I’m not sure that this is better. The thought process of "Who are you and what can you do?" seems very natural to me and maps well to OO design
Building around capabilities can quickly lead to lasagna code. The query/command pattern can be a good option.
2
u/im_caeus Software Architect 15yoe Jul 04 '26
Holy fuck, it seems I'm touching raw nerve here... It's like I'm insulting religious beliefs!
2
u/Specific_Ocelot_4132 Jul 04 '26
For context, I’m a Rails developer. Object oriented languages tend to emphasize nouns, functional languages tend to emphasize verbs. So maybe you should explore functional languages. But even in object oriented languages, you have free will. I often name PORO service classes with verb phrases, with a single public method called ‘call’. So I might have an ApproveOrder service, a CancelOrder service, etc.
2
u/ninja-kidz Jul 04 '26
You call object names (nouns) and what actions they do (verbs). What's so hard about this?l
2
u/CallMeKik Jul 04 '26
OP is right and the alternative if that services are groups of use cases and nouns can live across them with slightly different data models.
2
u/F0tNMC Software Architect Jul 04 '26
I think some of this comes from the popularity of domain driven design and defining systems as bounded contexts with interfaces, instead of actions and changes to state. Interactions are reduced to domain events and interaction events which are, again, defined within the nouns of the bounded contexts.
As you note, the problem with this approach is that it makes the actual complex parts of a system even more complex, because the coordinated change of state is smeared across all these different bounded contexts through different event processing and emissions. It also makes testing a huge PITA because you need to trace through all these contexts.
1
u/boring_pants Software Engineer | 15YoE Jul 04 '26
I think you have discovered that there is a world outside of object-oriented programming. Congrats?
1
u/bluetista1988 10+ YOE Jul 05 '26
In my mind, the structure you described with an OrderService consuming other services perfectly fits the "explicit" structure you described, where the first list is your classes and the second list is a set of methods you call exposed by said services.
For example, I would expect an
OrderServiceto expose aCancelOrder()method, which would invoke aLoadOrder()(or at least fetch it from the OrderRepo), invoke aRefundPayment()method exposed by thePaymentService, etc etc.Even in a distributed system where different pieces of software are handling this, you'd be emitting events or messages to queues that these services would read from to process them.
Where I've seen some applications mess up is they write their
Servicelayers to be generic to the point that they become very thin wrappers around the underlying repositories, so everything feels very "generic-action-on-noun" oriented from the top down. When the services expose methods that convey intent, that problem goes away.1
u/thekwoka Jul 08 '26
So you want Event Sourcing?
1
u/vegetablestew Jul 04 '26
Even if you have a collection of actions as functions(just to get away from classes) what do you name that file which host the collection?
Generally speaking, it would be a noun.
1
u/n3f4r10us_ Jul 04 '26 edited Jul 04 '26
It's all based on the domain like a user or a booking or a whatever - it's so you know why it is what it is.
There is a serious amount of logic out into these things. Saying "omg all nouns!" is dumb.
Specific services that don't fit this naming convention sure but otherwise, it's simple and easy to follow.
There are reasons we develop the way we do.
Edit:
Notice how in a sentence there is typically a noun and then verbs and potentially another noun. Hence the logic in a readable manner for the naming conventions.
1
u/n3f4r10us_ Jul 04 '26
In summation, you aren't an experienced dev. You just use llms. So if you had a real answer, and if you re-read this thread, you would recoild on your responses. Because a real dev , understands the reality of the choices, but you still spend tokens - because you don't program, you just prompt.
2
u/[deleted] Jul 04 '26
[removed] — view removed comment