Yep, that's pretty much how I write code. My own project, Yazz Pilot is pretty much held together by duct tape too!
w
Wouter
01/14/2020, 3:47 PM
yes, that switch statement probably never needed to be maintainable. He just used a new number incrementally to just add an event to a level, moved on, and never returned. How could that code even be be better? use an enum? but then in the level data the number would not necessarily be an enum, so it's actually worse if he ever had to look it up.
👍 3
the "professional programmer" would have wanted to factor out all repeating behaviors, and then make each game event a list of parametrized behaviors, no doubt specified in JSON to be "data driven". And seeing or debugging what happens for one particular event would have been horrible.
👍 3
g
Garth Goldwater
01/16/2020, 12:40 AM
it feels like programming these kinds of magic switch statements are a real boundary condition for text-based programming: in something like photoshop, you don’t have to interface with a wild abstraction to eg add another layer and you usually wouldn’t want to. but having to be able to abstract over text leaves us with the sophie’s choice of boiling spaghetti and using ctrl f to edit it later or turning your code into a TPS report with sound semantics but a corrupt and inefficient bureaucracy
w
Wouter
01/16/2020, 2:14 AM
@Garth Goldwater if his level data and his code were all in the same "language", then it would be easy, since all he wants to do is associate some code with some thing in a level.. he wouldn't even need to switch to hold it.