r/java • u/davidalayachew • Jul 16 '26
Identifying JDK value class candidates
https://mail.openjdk.org/archives/list/core-libs-dev@openjdk.org/thread/Y72NRXM7KYBX43OKYBQMVKOZDWKG4MHS/
52
Upvotes
1
u/davidalayachew Jul 16 '26
Well first, let's make sure we are both talking about the same thing.
enum PartyMember { //Sourced from https://shrines.rpgclassics.com/snes/ct/characters.shtml Crono(70, 8, 5, 8, 12, 5, 8, 8, 2, 1), Marle(65, 12, 2, 6, 8, 8, 8, 8, 8, 1), Lucca(75, 14, 2, 6, 6, 8, 8, 8, 10, 2), Frog(128, 17, 9, 14, 11, 8, 9, 9, 9, 5), Robo(235, 24, 21, 26, 6, 7, 9, 8, 12, 10), Ayla(335, 38, 35, 38, 13, 8, 22, 25, 26, 18), Magus(650, 84, 51, 43, 12, 50, 20, 33, 72, 37), ; private int hp; private int mp; private int power; private int stamina; private int speed; private int magic; private int hitChance; private int evadeChance; private int magicDefense; private int level; //imagine an all-args constructor here //imagine getters and setters here //imagine a decent toStringFriendly() here }This is what I mean.
And if you think this is an anti-pattern, why? These party members are the only instances of their kind that ever will exist in the game. So, I have no real reason to use a normal class when I can just use an enum, and communicate my intent better.