# A structure for a text messages dictionary with system notifications/errors

I would like to arrange a system messages dictionary for an application in JavaScript.

As an initial intention, I thought something about the following structure:

export const SYS_MESSAGES = Object.freeze({

fileSizeExceeded: {
code: "FILE_SIZE_EXCEEDED",
text: "The file size exceeds allowed limit"
}

});


But then I realized, the structure could be even more simple:

export const SYS_MESSAGES = Object.freeze({

FILE_SIZE_EXCEEDED: "The file size exceeds allowed limit"

});


Which option of two structures is a preferred-one from maintenance/style perspective?

• Thanks for the opinion, I also considered the second option, but then I realized that with a such structure it will be more difficult to get a code of a message. E.g. SYS_MESSAGES.FILE_SIZE_EXCEEDED returns always a text message ("The file size exceeds allowed limit"), but if I want to get the message code itself (FILE_SIZE_EXCEEDED), then I'll have to play with Object.keys() and rely on a permanent order of messages in the dictionary, which can be changed at any time day and will require adjusting the entire code base. That's why the option #1 is better, although it's more verbose. – Mike B. Jun 15 at 19:16