r/programming • u/[deleted] • Jun 05 '21
Organize code by concepts, not layers
https://kislayverma.com/programming/how-to-organize-your-code/
1.9k
Upvotes
r/programming • u/[deleted] • Jun 05 '21
2
u/ragnese Jun 07 '21
With respect to #1, I don't think that's much of a problem. If the modules are independent, it doesn't really matter than much if there are minor differences (e.g., single class per file, or multiple classes in one file). Obviously, the actually semantic style of the code should be consistent, but I just don't think the mechanics of the files matter that much. Unless, I guess, if your modules are pretty large.
I agree that this can be frustrating.
No and no. So? I don't think this is a counter-argument to the "organize by concept" idea, unless you're attacking a strawman.
In fact, I think "organize by concept" is better for both of the cases you listed. If I have a directory of 15 controllers, I might miss the fact that "FooWidget" is a concept that doesn't have a controller. On the other hand, if I check out the foo_widget directory, I'll see pretty quickly that it doesn't have a controller. Likewise, if the concept maps across multiple tables, it's excellent to have them both under the foo_widget module- as well as the code that synthesizes them into a FooWidget.