Total Members Voted: 249
Blockland Forums Playing Cards???
3:30 pm
well its 3:07 so you could do it in half an hour.
Today was.forget.I had to rewrite a core service for our game, and that service is connected to every other script in the game.Naturally, my rewrites mean I now have to modify every other script.But that's a tomorrow problem.The reason for the rewrite was because, as my tech director put it, "a code smell so bad a pig would walk away."As an exampleSo, we've had a problem for a week involving a certain dictionary throwing a "KeyNotFoundException"Basically, to avoid excessive calls to the server, we have a client-side cache of both the user's data, plus any players that appear in their newsfeed/friends-list.Now, the correct way to get data about any player was to call a method which first checks the dictionary/cache, returns that data if it exists or invalidates the data if it has expired via a simple timer, and if the data is invalid/non-existant, it then calls the server and adds the returned data to the cache.Unfortunately, some chuckleforget decided to add not one, but EIGHT additional methods for DIRECTLY accessing the cache.Naturally, none of these methods check if the player data exists in the cache.Due to another issue, the cache would only ever store 1 player at a time (the user).So, the other player data was never in the cache, and every other script was trying to access a player that didn't exist inside it, since all references to this service were for those eight other redundant methods.By the wayThe main method for accessing the cache/server data?That was split into THREE method calls.Plus lambda methods.And there was technically 2 additional method calls you were supposed to make on top of that.SoOverallCompletely convoluted and ridiculous.I've simplified all of that to just three method calls; one for access any player data (the user or his friends), one for loading/saving the user's data to file for offline access, and one for updating the UI for all the player's data whenever that gets updated on the server.