What should I use as a stable and safe unique object identifier for serialization purposes?












0















In my game, I have a bunch of objects of the type 'Area' which are always different from each other. They store data such as the spawn points for characters, resources that can be found, the name, etc.



Sometimes I wan't to store the area that the player is currently up to. I don't need to store the whole area, just some kind of key that indicates what area.



At the moment I'm using an enum, however it's annoying to have to add a new enum for every area. I was wondering, is there some more safe, self-managing way of tackling this problem? I could use the name string, however if I ever decide I want to change the name of an area during release, it has the potential to ruin peoples save data.



Is there a technique to this of some sort?










share|improve this question


















  • 3





    GUIDs were designed for this.

    – Dour High Arch
    Nov 23 '18 at 0:12











  • @DourHighArch Hi Dour, cheers for the reply. Correct me if I'm wrong, but wouldn't I still have to assign the GUID for every object every time I decide to add a new one?

    – Sebastian King
    Nov 23 '18 at 0:45











  • Yes; if that is a problem you need to update your question to explain why.

    – Dour High Arch
    Nov 23 '18 at 0:54











  • @DourHighArch It's okay, it's not a problem, I just thought maybe there was some way for objects to create it for themselves, but it makes sense to me why this isn't possible.

    – Sebastian King
    Nov 23 '18 at 1:08











  • Your class could in fact create it for itself. If you already have one, pass it in the ctor or just replace it.

    – Make StackOverflow Good Again
    Nov 23 '18 at 1:54
















0















In my game, I have a bunch of objects of the type 'Area' which are always different from each other. They store data such as the spawn points for characters, resources that can be found, the name, etc.



Sometimes I wan't to store the area that the player is currently up to. I don't need to store the whole area, just some kind of key that indicates what area.



At the moment I'm using an enum, however it's annoying to have to add a new enum for every area. I was wondering, is there some more safe, self-managing way of tackling this problem? I could use the name string, however if I ever decide I want to change the name of an area during release, it has the potential to ruin peoples save data.



Is there a technique to this of some sort?










share|improve this question


















  • 3





    GUIDs were designed for this.

    – Dour High Arch
    Nov 23 '18 at 0:12











  • @DourHighArch Hi Dour, cheers for the reply. Correct me if I'm wrong, but wouldn't I still have to assign the GUID for every object every time I decide to add a new one?

    – Sebastian King
    Nov 23 '18 at 0:45











  • Yes; if that is a problem you need to update your question to explain why.

    – Dour High Arch
    Nov 23 '18 at 0:54











  • @DourHighArch It's okay, it's not a problem, I just thought maybe there was some way for objects to create it for themselves, but it makes sense to me why this isn't possible.

    – Sebastian King
    Nov 23 '18 at 1:08











  • Your class could in fact create it for itself. If you already have one, pass it in the ctor or just replace it.

    – Make StackOverflow Good Again
    Nov 23 '18 at 1:54














0












0








0








In my game, I have a bunch of objects of the type 'Area' which are always different from each other. They store data such as the spawn points for characters, resources that can be found, the name, etc.



Sometimes I wan't to store the area that the player is currently up to. I don't need to store the whole area, just some kind of key that indicates what area.



At the moment I'm using an enum, however it's annoying to have to add a new enum for every area. I was wondering, is there some more safe, self-managing way of tackling this problem? I could use the name string, however if I ever decide I want to change the name of an area during release, it has the potential to ruin peoples save data.



Is there a technique to this of some sort?










share|improve this question














In my game, I have a bunch of objects of the type 'Area' which are always different from each other. They store data such as the spawn points for characters, resources that can be found, the name, etc.



Sometimes I wan't to store the area that the player is currently up to. I don't need to store the whole area, just some kind of key that indicates what area.



At the moment I'm using an enum, however it's annoying to have to add a new enum for every area. I was wondering, is there some more safe, self-managing way of tackling this problem? I could use the name string, however if I ever decide I want to change the name of an area during release, it has the potential to ruin peoples save data.



Is there a technique to this of some sort?







c# object serialization






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 22 '18 at 23:59









Sebastian KingSebastian King

646




646








  • 3





    GUIDs were designed for this.

    – Dour High Arch
    Nov 23 '18 at 0:12











  • @DourHighArch Hi Dour, cheers for the reply. Correct me if I'm wrong, but wouldn't I still have to assign the GUID for every object every time I decide to add a new one?

    – Sebastian King
    Nov 23 '18 at 0:45











  • Yes; if that is a problem you need to update your question to explain why.

    – Dour High Arch
    Nov 23 '18 at 0:54











  • @DourHighArch It's okay, it's not a problem, I just thought maybe there was some way for objects to create it for themselves, but it makes sense to me why this isn't possible.

    – Sebastian King
    Nov 23 '18 at 1:08











  • Your class could in fact create it for itself. If you already have one, pass it in the ctor or just replace it.

    – Make StackOverflow Good Again
    Nov 23 '18 at 1:54














  • 3





    GUIDs were designed for this.

    – Dour High Arch
    Nov 23 '18 at 0:12











  • @DourHighArch Hi Dour, cheers for the reply. Correct me if I'm wrong, but wouldn't I still have to assign the GUID for every object every time I decide to add a new one?

    – Sebastian King
    Nov 23 '18 at 0:45











  • Yes; if that is a problem you need to update your question to explain why.

    – Dour High Arch
    Nov 23 '18 at 0:54











  • @DourHighArch It's okay, it's not a problem, I just thought maybe there was some way for objects to create it for themselves, but it makes sense to me why this isn't possible.

    – Sebastian King
    Nov 23 '18 at 1:08











  • Your class could in fact create it for itself. If you already have one, pass it in the ctor or just replace it.

    – Make StackOverflow Good Again
    Nov 23 '18 at 1:54








3




3





GUIDs were designed for this.

– Dour High Arch
Nov 23 '18 at 0:12





GUIDs were designed for this.

– Dour High Arch
Nov 23 '18 at 0:12













@DourHighArch Hi Dour, cheers for the reply. Correct me if I'm wrong, but wouldn't I still have to assign the GUID for every object every time I decide to add a new one?

– Sebastian King
Nov 23 '18 at 0:45





@DourHighArch Hi Dour, cheers for the reply. Correct me if I'm wrong, but wouldn't I still have to assign the GUID for every object every time I decide to add a new one?

– Sebastian King
Nov 23 '18 at 0:45













Yes; if that is a problem you need to update your question to explain why.

– Dour High Arch
Nov 23 '18 at 0:54





Yes; if that is a problem you need to update your question to explain why.

– Dour High Arch
Nov 23 '18 at 0:54













@DourHighArch It's okay, it's not a problem, I just thought maybe there was some way for objects to create it for themselves, but it makes sense to me why this isn't possible.

– Sebastian King
Nov 23 '18 at 1:08





@DourHighArch It's okay, it's not a problem, I just thought maybe there was some way for objects to create it for themselves, but it makes sense to me why this isn't possible.

– Sebastian King
Nov 23 '18 at 1:08













Your class could in fact create it for itself. If you already have one, pass it in the ctor or just replace it.

– Make StackOverflow Good Again
Nov 23 '18 at 1:54





Your class could in fact create it for itself. If you already have one, pass it in the ctor or just replace it.

– Make StackOverflow Good Again
Nov 23 '18 at 1:54












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53439244%2fwhat-should-i-use-as-a-stable-and-safe-unique-object-identifier-for-serializatio%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53439244%2fwhat-should-i-use-as-a-stable-and-safe-unique-object-identifier-for-serializatio%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

"Incorrect syntax near the keyword 'ON'. (on update cascade, on delete cascade,)

Alcedinidae

RAC Tourist Trophy