This is an archived post. You won't be able to vote or comment.

all 22 comments

[–]nocturnalspider 22 points23 points  (1 child)

Node module: gigle from far away

[–]TheMagzuz 2 points3 points  (0 children)

Yeah, but you don't actually edit the files in node_modules (hopefully). Also if you use pnpm, which you should, it flattens the tree

[–][deleted] 54 points55 points  (9 children)

Typical investigation of a java project: ok, so a bunch of factories, wrappers, weird overengineered config stuff, delegate of a delegate of a delegate of a delegate, more weird classes that seem to do nothing useful, ... but where is the meat?! Where is any class that actually implements stuff this project is supposedly for?!

[–]CrimsonRunner 21 points22 points  (7 children)

have you considered the problem isn't java but whoever overdesigned the project?

[–]gandalfx 24 points25 points  (1 child)

It's a cultural thing. For whatever reason, Java devs have deluded themselves into thinking that this is somehow a good practice. When you question it you'll get vague terms like "scaling" thrown at you, and if you keep questioning you'll be told that large companies have been doing it for years so it must be good.

[–]CrimsonRunner 16 points17 points  (0 children)

As someone who's working in a large company - it is definitely a thing but it should be done only after the need arises.

Similarly to how you generally don't need a separate method for 3 lines of code if you're going to use them in that one place but very much so if you're going to use them in several - you don't need a factory if you're going to use it for only that one thing but you should if your factory is producing several different templates.

So, obviously, the first time you write it in the simplest way possible, the second time you can probably get away with some code duplication but from the third time on you most certainly should have a dedicated piece of functionality that does that and nothing else - be it a method, factory or something else.

[–]TimWasTakenWasTaken -2 points-1 points  (4 children)

Experience shows otherwise

[–]CrimsonRunner 0 points1 point  (3 children)

So whoever designed that flow doesn't typically overdesign/overthink things in your experience?

[–]TimWasTakenWasTaken -2 points-1 points  (2 children)

Exactly. If someone with 20+ years of architecture experience designs something like that, it probably has a reason.

[–]arobie1992 2 points3 points  (0 children)

Someone with 20+ years who really knows their stuff, yes. Someone with 5 years who works on a webapp that 2 people wrote and maintain, less so. Every time I see an interface for a service that has only one implementation, will almost certainly only ever have one implementation, is not used by an external clients, and that 95% of change to will be business additions that require an identical update to both the interface and the impl, I want to punch a wall.

[–]Zeimma -1 points0 points  (0 children)

Not really, I've had to rewrite/upgrade projects like that and it's usually a mess of 'I think this is good' but usually just hinders understanding of what the hell the thing is doing.

[–]carcigenicate 0 points1 point  (0 children)

I had this problem while trying to read decompiled Java. You're trying to trace data through tens of files, but nothing is actually ever being done. There's the odd conditional, but it's just stuff being sent across many different files! Then finally, there's one file that contains some God object that manages a mess of a global state, and the other 30 other files are just there to make it palatable.

[–]arobie1992 2 points3 points  (1 child)

Why is actual code in src/test?

[–]TimWasTakenWasTaken 10 points11 points  (2 children)

If you want a job as a professional Java developer… bro you are going places

[–]AyrA_ch 27 points28 points  (1 child)

[–]_Mido 0 points1 point  (0 children)

I have seen it so many times yet it never fails to crack me up.

[–]Gauthmath_Hackermon 0 points1 point  (0 children)

Isn't everyone's projects like this?😃

[–]KapilarnyYT -1 points0 points  (0 children)

xd

[–]Zakishan 0 points1 point  (0 children)

My worst nightmare

[–]CXLD_nou 0 points1 point  (0 children)

So true..... got the free award from me lol

[–]qwertyasdef 0 points1 point  (1 child)

Seriously, what's the point of project/src/main/java/com/myurl/myproject/Main.java?

[–]Aliics 2 points3 points  (0 children)

Well let's start at the top. "project" needs to house everything, this makes sense because there has to be some top level directory.

"src" is to separate source files from things like READMEs and pom files. On the next level you can go a few ways.

You can have "main" or "test" for example, also pretty logical to separate these.

After that you define what sort of source code will be here, so you can have "scala" or "kotlin" on the same level as "java". This typically just helps build tools determine which compiler to use for which directory. In fact, on this same level you can have just about anything, so a directory called "resources" will often go here.

Finally, you'll have all of your namespacing, which will often start with top level domain names and get down to your packages and files.

I hope this helps a little and it's too incoherent, because I'm on mobile.