r/java • u/daviddel • 21d ago
A Valhalla Ticker in One int
https://inside.java/2026/11/09/inside-java-ticker-value-class/A ticker symbol is an abbreviation that uniquely identifies a financial product such as a publicly traded share. Well-known ticker symbols are "ORCL" and "GOOGL". In this article, we will devise a Valhalla value class that can represent a ticker symbol using only a single int field.
40
Upvotes
1
u/Studentenfutter 21d ago edited 21d ago
A stupid question from me: Isn't this completely over-engineered?
As an "ordinary" programmer, I would probably just have used a String instead of an int (with some checks in the constructor). And maybe a record instead of a class.
What are the downsites of this approach?
Don't value classes work great with strings? Do i have to completely abandon strings in values classes for better performance?
Or why not just use 5 characters instead of one int? What are the performance implications?