4 ms·
function names tells you exactly what it does according to reasonable expectations. You can just skip over it, if your not interested in its work. I understand
by dagw 6y ago
function names tells you exactly what it does according to reasonable expectations. You can just skip over it, if your not interested in its work.
I understand the argument to be that by breaking everything out into functions it makes it too easy to hide what is actually going on and you can miss a lot of fine detail. If your code looks like
x=doA();
y=doB(x);
z=doC(y);
then it becomes very hard to spot for example that both functions doA and doC recomputed the same intermediate value that you could just compute once and reuse or that doB validates its input, but in this case you know it's unnecessary to do so, since you know that doA can only return data that is valid for doB. If everything was inline then these things would jump out at you a lot quicker.
Of course in many cases this doesn't matter and recomputing that intermediate value twice costs so little in the grand scheme of things that the extra readability is worth it.
- UK-Al05 6y agoYes, but these about micro optimisation for video games. People here are complaining about this in standard situations. Where being able quickly grasp what function is doing is far more important then identifying recomputed work.