×
Login Register an account
Top Submissions Explore Upgoat Search Random Subverse Random Post Colorize! Site Rules
4

to nest, or not to nest

submitted by AugustineOfHippo2 to programming 11 monthsMay 18, 2023 13:17:41 ago (+4/-0)     (youtu.be)

https://youtu.be/CFRhGnuXG-4

i'm 50/50 on this. i like some of his points, but i don't there is a one-size-fits-all rule.
what's your take?


3 comments block


[ - ] GrayDragon 0 points 11 monthsMay 19, 2023 10:05:09 ago (+0/-0)

This is a great video. After 35+ years of programming and being told "never leave a function until the end" which changed when nodeJS came out to "always leave a function as quick as possible."

Yeah, the "unhappy" bails at the top of a function is how I write. I also support everything of the other thing. Unfortunately, I am a maintenance programmer, and the disasters I have seen our beyond @Master_Foo s comprehension. Just reading his shit makes me sad.

[ - ] Master_Foo 0 points 11 monthsMay 19, 2023 15:08:46 ago (+0/-0)

GD, You write ColdFusion. Anything you have to "maintain" is due to "retards who write in ColdFusion".

[ - ] Master_Foo 0 points 11 monthsMay 18, 2023 14:49:56 ago (+0/-0)

I'm almost 100% on this barring the inevitable edge case.

My rule is, "code should be modularization into 1 namespace/classe per file and should fit into one page of code.

If you need more than one page / file, then it's probably not in it's simplest form and you probably need to decomplexify the code using inheritance or other integration method.

Then you break the rule and use as much space as needed for unit testing under the fold.

But the functionality of the code ALWAYS fits in the top of the file. You can read it all as soon as you open it.

Break the rule when there is a good reason.

Also:
Function names ARE the documentation
Nested code is code that needs to be simplified.