4 ms·
So kids, how would we refactor this? https://github.com/LemonHaze420/DCPopulous/blob/master/populous_peeps.cpp https://github.com/LemonHaze420/DCPopulous/blob/
by thom 4y ago
So kids, how would we refactor this?
https://github.com/LemonHaze420/DCPopulous/blob/master/populous_peeps.cpp https://github.com/LemonHaze420/DCPopulous/blob/master/popul...
- bluedino 4y agoStuff like this would be great for a computer science class. Algorithms, performance, software engineering.
- glass-z13 4y agoIt's almost a perfect wave of brackets
- mappu 4y agoMost of the bracket lines are space-indented and most of the if lines are tab-indented - likely GitHub rendering with 8-space instead of 4-space tabs is making it look worse than intended,
- deleted 4y ago[deleted]
- deleted 4y ago[deleted]
- britneybitch 4y agoWell first off it needs to be rewritten in Rust, obviously. I just can't enjoy playing a game if I don't know for sure it's memory safe.
- RajT88 4y agoThe most HN comment ever.
- MrYellowP 4y agoHow did we get this far before people went insane?
- astrange 4y agoWell some PC games (Bethesda for one) are known for constantly crashing and being more bug than game. Maybe if their engine actually was memory safe they’d have more time to polish the game? On the other hand, it doesn’t seem to matter since people will buy Skyrim for their fridge for the 40th time over. (For me personally, AlephOne for Marathon has some mysterious crashes every few days and it’s pretty annoying.)
- MrYellowP 4y ago> Maybe if their engine actually was memory safe they’d have more time to polish the game? Maybe if they had programmers who didn't suck* Fixed for accuracy.
- viraptor 4y agoI'd look at the "systems" idea from ECS design. See for example bevy https://bevy-cheatbook.github.io/patterns/generic-systems.html https://bevy-cheatbook.github.io/patterns/generic-systems.ht... which will also satisfy RiiR for the sibling comment ; ) The main idea is to have a callback and iteration over entities you have (that match some condition/interface). This would refactor the code to .add_system(reduce_size).add_system(handle_magnet_carrier).add_system(...)..., where each section is a separate behaviour which can be tested in isolation.
- Cockbrand 4y agoI heard the term "Tour de France coding" for this style, as the indentation resembles a TdF stage elevation profile rotated by 90°.
- unwind 4y agoNo need to, look it's all commented and nice: /* if either paple magnet carrier is a knight make them drop the pm*/
- noduerme 4y ago>> if(life >= CITY_FOOD) I mean, why refactor when something is so eminently readable?