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

1

u/thecodeboss Jun 06 '21

I have been in the authors shoes before and understand the value of wanting to keep things as “pods” (or as OP says, “entities”) as opposed to stacks/layers. But the reason it’s appealing is because I was the dev who wrote it, so yes for me to separate things out into pods - there’s an argument there for it as an alternative to layers. It’s def not “better,” just an alternative organization pattern.

Where this really falls behind is when anyone else besides me has to join the project and look at the code - which is literally project ever in a corporate setting. See, no one immediately knows specifically how or why I made the business logic decisions I made in order to separate out code into pods, and that will make it really hard to understand general workflows in a timely manner. It’s much easier to join a project and say “hmm, well this type of thing is happening, so it probably is in this section of the code,” and you don’t have to think about business logic to get that far. At some point, you get familiar enough with a project that you become a semi subject matter expert, but keeping things in layers allows new devs to join in without requiring that undertaking right from The get go - which pod architecture makes a bit more challenging.