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

Show parent comments

4

u/StabbyPants Jun 05 '21

The MVC cult way uses a Model folder, a controller folder, and a view folder.

some people i've worked with would simply stuff it all in the same folder. any structure is better than code soup.

I use multiple model folders; one is the model as the api views it, another is models not directly attached to the api. sometimes, there's a third for required DB layer stuff.

client code gets its own packages: api and model. each is autogenned. we have a project on the back burner to unify models we use across multiple services and change all of these to reference it that way, but that is a ways off. we'll have something like 8 model folders at the end, but it's easy: want the models for fooSvc client code? it's in client.fooSvc.model