r/ProgrammerHumor • • Nov 25 '22

Meme Coding strategies

Post image
52.2k Upvotes

385 comments sorted by

View all comments

Show parent comments

67

u/vhite Nov 25 '22 edited Nov 25 '22

Yeah, I work with something like that, large codebase elegantly divided into modules and plugins. It usually works like this.

Layer 1 - General top level function handling basic logic between several components. Calls specific component functions.

Layer 2 - Component's outer interface function, has few parameters to appear simple, does pretty much nothing but some boilerplate to call internal component function.

Layer 3 - Internal component function, takes dozen parameters with mysterious meanings, and uses dozen more private states and variables and has even more boilerplate. You think you're are finally getting to the core functionality you're trying to uncover, but then...

Layer 4 - DoTheThing function. Short and simple, the only problem is that it doesn't do the thing. Instead is calls some higher communication interface with an action flag and some data, and then shoots it into the oblivion.

Layer 5 - You have finally reached the point where the flag is being processed, at least you think so because the direct path was lost in a dozens of communication interface functions and so you just searched for the flag used in DoTheThing function. You found 6 results but this one looks closest to what you want. Here the interface notifies all the members of a mysterious array.

Layer ??? - You dig trough the origins of the array, it's type, initiation, all the instances where members are added, etc., but you only keep finding more abstractions. The name of the type suggest some higher level components, but you don't know which ones are in the array at the time it's being notified, and you don't know how the abstractions are connected to the actual components. Notify only calls an abstract function, and you have no idea where and by what it's being overriden. You're lost, cold, and you just wanna go home.

41

u/shrubs311 Nov 25 '22

Layer 2 - Component's outer interface function, has few parameters to appear simple, does pretty much nothing but some boilerplate to call internal component function.

it says "layer 2" but there's probably 2-4 of these

Layer 4 - DoTheThing function. Short and simple, the only problem is that it doesn't do the thing.

me after spending two hours looking at our codebase in layer 4: i'm convinced this app literally doesn't process the data

me after spending 5 hours looking at code: oh it's actually extremely simple

me 3 days later: it wasn't simple at all but i have tamed the code to do what i want, i'm a god at software development and imposter syndrome has been defeated (for the next 16 hours)

20

u/Discount-Avocado Nov 25 '22

Jesus. So relatable.

Finally you add 300 breakpoints where you think it could be. Turns out it’s none. Then you add 50 more and find it. You relieved, but then experience the same thing again when you reverse the logic and realize how insane it is.

5

u/AlternativeAardvark6 Nov 25 '22

You want to follow the code in your editor but the genius before you used reflection for everything so clicking on the method returns no uses and you need to text search the entire codebase.

3

u/Discount-Avocado Nov 25 '22

These days I just default to text search lol. Anything else is a waste of time.

People think they are being clever when they industrial design literally everything. But in reality all they are doing is making it miserable to work on and killing employee retention because the codebase is shit.

There is a time and a place for almost everything. But if you default to the same thing nearly every time you are probably wrong.

2

u/AlarmedProf92 Nov 26 '22

Plus you have to report at the daily that you still haven't solved the bug...

Like the worst thing about this for me is that there is also management layer over my head that counts my performance so it adds for extra anxiety.

1

u/adappergentlefolk Nov 25 '22

lol at this point it’s easier to read the assembly code to figure out what’s going on