5 ms·
I don't know javascript, but in the proposed "structured" code, doesn't it execute initialization statements for every potential cases even when you call it onl
by yongjik 8y ago
I don't know javascript, but in the proposed "structured" code, doesn't it execute initialization statements for every potential cases even when you call it only once? I.e.,
const getValue = type => {
const email = () => 'myemail@gmail.com';
const password = () => '12345';
....
Now "const email = ..." will be executed every time even when you're just asking for password. Eventually, such a code "scales", become a bloated behemoth with twelve cases, called a hundred time deep inside a server, initializing everything every time it is called, with potential side effects...
...and then one day a starry-eyed new hire looks at the top-level code, thinking "Heh, this is an internal graph server, why does it need customer email addresses?", removes the top-level config line, and then suddenly all internal dashboards go blank because they can't read email addresses.
...Yeah, you can probably tell that I'm not a fan of this technique.