Skip to main content
14 events
when toggle format what by license comment
Apr 17, 2018 at 15:50 history tweeted twitter.com/StackSoftEng/status/986270786376912897
Apr 17, 2018 at 12:59 history bumped CommunityBot This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
Mar 18, 2018 at 12:18 history bumped CommunityBot This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
Feb 16, 2018 at 11:33 answer added Flater timeline score: 2
Oct 31, 2016 at 11:35 history migrated from stackoverflow.com (revisions)
Sep 28, 2016 at 20:08 comment added Gasper @FlaringAfro The idea is for some game object (like, DataController) that operates on your SaveData to be able to reconstruct itself from it ('load') and return the prepared to save object ('save'). This object also has to know how to (de)serialize itself. SaveController then will only trigger the (de)serialization and handle the (de)serialized data further into pipeline (e.g., to the DataController on load and to disk IO on save).
Sep 28, 2016 at 19:08 comment added Ed Plunkett I meant "protected setters". Protected getters with public setters would be whimsical.
Sep 28, 2016 at 18:55 comment added Ed Plunkett Maybe you want protected getters or something, but this is a case where you're keeping the instances private. Nobody who shouldn't be touching it needs any access at all. Private access is for cases where, say, you want a lot of other classes to have access to the public-facing parts of a TextBox, but its internal state is in a delicate balance that outsiders can't be trusted to respect and shouldn't need to worry about. Or imagine a linked list class with a private list structure, and a count. Public access to the count must be read-only.
Sep 28, 2016 at 18:49 comment added Flaring Afro @Ed Plunkett I've always been taught that making things private if possible is a better design. I definitely know the get/set methods are important for adding features from real world experience.
Sep 28, 2016 at 18:44 comment added Flaring Afro @CompuChip (1) I assumed the whole class was saved and that's very good to know. I probably will combine DataController and SavedData. (2) Yeah, the SaveController locks the SavedData that's passed to it, makes a copy, releases the lock and uses the copy. Thanks for the advice though. I suppose it might make more sense to send a copy as you would not have to use lock then, I think. I'd have to think it over more before being sure about that since multiple copies could be sent at once.
Sep 28, 2016 at 17:12 comment added Gasper Seems like you want to use Memento pattern.
Sep 28, 2016 at 17:07 comment added Ed Plunkett Everything turned to fog for me pretty early in your explanation, but I can address this: "then it has to be public, with all of its variables being public as well... which just seems like a bad design" -- Not to me it doesn't. Serialize a class. Have other classes do stuff with it. Obviously its properties are public. So what? Who or what are you hiding them from? Elves? Don't hand out an instance to somebody who has no business seeing it, that's all.
Sep 28, 2016 at 17:06 comment added CompuChip Two quick comments: (1) Get and set methods are not saved to disk, even with automatic serialization, so it shouldn't matter how many you have - it's a good idea to have a lean data type that omits any calculated values though; (2) consider passing in a copy of your current game state and pumping that into your stored data object - especially if you are doing this on a separate thread you don't want your game modifying something in the middle of a save.
Sep 28, 2016 at 17:02 history asked Flaring Afro CC BY-SA 3.0