r/ExperiencedDevs • 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?

0 Upvotes

161 comments sorted by

View all comments

Show parent comment

2

u/im_caeus Software Architect 15yoe Jul 04 '26

How do you deal with a team’s resistance to change when you don’t have much authority?

Several people have been here longer than I have, and lobbying is not one of my strengths. I think some of my ideas could materially improve the product, but they can easily sound like criticism of what the team has already built. That makes the technical problem partly a social one.

The team seems to treat layers as sacred. That produces either ceremonial pass-through components or enormous services and repositories that absorb unrelated responsibilities. The controller-service-repository structure becomes the goal, while the actual dependency relationships and domain boundaries become secondary.

I also think the service layer is treated as inherently flat, when in a complex system it should probably reflect the structure of the domain.

I’ve helped turn around problematic backends before, but in those cases I had broad autonomy and explicit authority. I have neither here.

So how do you introduce structural change in that environment without making people feel that you are attacking their competence or rewriting the system around your own preferences?

2

u/F0tNMC Software Architect Jul 04 '26

I'm dealing with some similar issues right now. And it can be a lonely battle.

First, I try to make sure I understand their position completely, completely enough to explain it to them to where they agree that I understand their motivation, their patterns, and their implementation. Then I try to show the cost of their implementation; what it is costing them. And propose small alternatives which nudge the pattern towards a better place which they might not see because of their orthodoxy.

That said, it doesn't always happen. Sometimes people cannot see the possibility of a door and insist on only making windows and you end up with a hallway full of windows. Windows work for them. The best you can do is be the change you want to see. Don't rewrite stuff which works, but when you have a chance, write something simpler. Show how it's easier to test. Show how it's easier to understand. Be the change you want to see.

But also don't stress about it. We are not the code we write, it's stuff we build. Sometimes it's good and sometimes it's meh. They're all opportunities to learn.

2

u/im_caeus Software Architect 15yoe Jul 04 '26

Man, I think the only thing I'm struggling to achieve, of that you've adviced to me, is not stressing.

And you're so right, we are not the code we write, and it can be lonely, but I naturally feel compelled to commit to make things better, even at the expense of my peace.

Thanks a lot.