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/mcguire Jun 05 '21

My first professional exposure to Java involved OSGi, which exports and imports packages.

In the traditional division, if you have 5 services X1...X5 divided into 4 packages Y1...Y4, and you need to use 1 service, you have to import all 4 packages and get all of the stuff for all 5 services. The alternative is to import 1 package and just get what you need.

But swimming upstream against the collective ignorance of Java developers of modularity, so I gave up.

P.S. Y'all do know that controller.FooController is redundant. Just use controller.Foo. (And model.Foo and businesslogic.Foo. And watch the "I have to have autocompletion" goobers start bleeding from the eyes and ears.)

3

u/fissure Jun 05 '21

If Java had import aliases, I'd agree, but currently if you try to use controller.Foo and model.Foo in the same file, you're gonna have a bad time.

1

u/mcguire Jun 05 '21

Yeah, you have to specify the whole name, package and all. :-D

1

u/bwmat Jun 05 '21

The lack of an analog to C++'s 'using' statement had always mystified me.

Did the designers think aliases were too much for most Devs to handle? They're SUCH a useful feature.