15 ms·
That's not the way I think, so that's not the way I program. When I'm thinking about an algorithm for solving a problem I sometimes need extra info from many o
by pontifier 7y ago
That's not the way I think, so that's not the way I program.
When I'm thinking about an algorithm for solving a problem I sometimes need extra info from many other places. I sometimes need to use globals to get around all this message passing nonsense that would otherwise clutter my function calls with 50 parameters.
I'd use GoTos if they were better supported.
I don't usually program for others, and I don't call myself a good programmer though. I usually just need to solve my own problems, then move on to the next.
- bluGill 7y agoWhen doing a tiny program of just a few thousand lines of code all by yourself you can get away with that. I do it myself at times because for a tiny program who cares - if I don't understand it I'll re-write it again. When you move t very large programs with millions of lines of code you cannot get by with that. You need strict rules of communication so all the humans can understand what is going on.
- inlined 7y agoSome tips: If your function call needs 50 parameters (I assume this is hyperbole) then you need some encapsulation. Many codebases with complex functions actually create a struct for the function call, which actually adds forwards compatibility if new struct members are optional. If you use globals to pass state then you’re probably not thread safe and you’re certainly going to have problems testing because you’ll need to “prep” global state before every test.
- stcredzero 7y agoIf your function call needs 50 parameters There's an object asking to be born!