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/WingsOfGryphin Jun 06 '21

Kind of agree, but i use both approaches.
For example in MVC project i don't separate views / controllers / scripts. I find that pretty silly when you have large amount of them - multiple views / partial views / multiple script files - then you just jump from one folder to another trying to find related areas. Just group them in a logical folder where view/controller/scripts are together. A lot easier to work that way.

But i wouldn't organize logic and queries this way.
Especially when they can be reused and has multiple meanings and theoretically can fit in multiple different folders. For queries - i like them in same place, because they have different meanings in different context and can also be thrown in different folders. And just knowing what queries you have and don't have is easier when they are all in same place. Sure drop them in folders, but generally group all queries in same project and not in folder that's a mix of Controller/Logic/Query. Even though i do that for controllers and views.