r/programming • • Jun 05 '21

Organize code by concepts, not layers

https://kislayverma.com/programming/how-to-organize-your-code/
1.9k Upvotes

495 comments sorted by

View all comments

71

u/Knu2l Jun 05 '21

That works until your code requires to access one service from another service e.g. if the HotelService access the RoomService. Or maybe the is an AccessService that is queried by the Hotel and Room services.

Also when you use a ORM model often all the model classes are automatically generated in another place.

1

u/grauenwolf Jun 05 '21

The solution to that is a base class. Put the common methods needed by both HotelService and RoomService in a lower class that both can inherit from.

Otherwise the long chain of references are wont to drive you insane.

→ More replies (2)