mardi 7 septembre 2021

Hashmap key inside value object paradigm

I have this design pattern that occurs whenever I use maps. I find myself having the key of the map also inside of the value. For example:

private Map<UUID, PlayerData> allPlayerData = new HashMap<>();

Within this example, I have UUID is the key, and I also have the UUID inside of the PlayerData object.

My question is, is this an acceptable pattern of design or is there a better way to accomplish this?

Aucun commentaire:

Enregistrer un commentaire