Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

Bad Code

TJ

    We needed a system so that customers can order food. I wanted it to be designed in a way that would allow for customers to have specific meals like #1, #5, and #15 like real restaurants have. Then customers would have preferences like " #15 extra cheese, no tomato". I also wanted the orders to get progressively harder to make over time. I also wanted us devs to be able to control almost every aspect of the process. We could control the frequency of when customers add or remove ingredients from their orders. how often they order combos vs just fries or a drink.
    My function for ordering food was becoming way too big of a mess. Also having a switch case depending on what day of the week it is to help with changing the difficulty over time. There was about 10+ parameters, and the more complex I wanted the system, the more and MORE parameters I'd have to add. The body of the function was a nightmare to for complexity.

    Eventually I caved and deleted everything... Now we just have a bunch of curated orders that the customers can pick from. the higher the index in the array of orders, the more complex. So now we just select a range from 1 to whatever and the whatever determines how complex the order will be. I know it's not the most elegant solution, but it beats having the ugliest code I've ever seen in our code base. 

Support this post

Did you like this post? Tell us

Leave a comment

Log in with your itch.io account to leave a comment.