3 ms·
I'd say obfuscation is creating a level of indirection just to look modular. Moving things complex dependent side effects into separate functions just hides wh
by lowercase1 6y ago
I'd say obfuscation is creating a level of indirection just to look modular. Moving things complex dependent side effects into separate functions just hides what is going on instead of clarifying it.
void MajorFunction( void ) {
MinorFunction1();
MinorFunction2();
MinorFunction3();
}
This can often be better inlined because then the complexity is obvious.
- karmakaze 6y agoNaming and shares use can make this one or the other. If it is a specific sequence of things that are commonly done, then putting it in one place so an update will keep all call sites in-sync. A small and simple function can sometimes be worth it, as opposed to that which 'mechanically' done (by humans) not with semantic significance but rather 'I can dedup this'. The litmus test is if a reader sees the function name called somewhere and presumes what that does. If there's high confidence (across all people) in that presumption being correct and if they were to look at the body would see it do precisely what they thought. It doesn't matter if it does it differently as long as it has the same result as the expectation. Also don't name it one thing and do two things in there.