|
|
|
|
|
by megapoliss
1637 days ago
|
|
> The part of functional programming I hate the most is passing some new data through 10 levels of callstack to use it in a function that didn't needed it previously. It should be automated. Probably, you may restructure your code, use curried functions, and you won't need to go through all 10 levels.
Transition from imperative to functional programming may looks like untangling a ball of function calls, in order to get simple and clean design. |
|
My problem is that I'm mostly writing games in my free time (the only time when I'm allowed to use functional languages), and writing games is mostly about quick iteration and testing many small changes. So previously I had the code to handle collisions only take potentially colliding objects as inputs and outputs. Now I want to add particle effects when things collide. Pass that particle system and return particles from the function.
Then I think - what if collisions cause the screen to "shake"? Again pass new data to the function. Then I decide it looks stupid and revert it.
Then I think - what if police reacted to collisions if they are near the police station? Again - pass some new data there.
I can do this, but it's a lot of refactoring. I'd prefer if I could just use a global variable and hit a button in IDE to refactor it to a nice functional code.