Peace For All

June 3, 2007

For once, I want good integer subtyping!

Filed under: Java, Programming — Devlin Bentley @ 6:00 pm

I am using an integer ID in parts of my program, I want to ensure that the ID is an actual ID that I have returned.  In a strongly typed language that also has a well fleshed out subtyping system, this would be trivial!

subtype AlbumID is long

The benefit of course would be that I could keep track of my AlbumID types and not have to worry about anything else!

Now the proper Java way is to make a new class called AlbumID that has a single long field and…  bleck!  I just want compile time checking darnit, I don’t need anything instantiated.

I just had an orthogonalization epiphany

Filed under: Life in general — Devlin Bentley @ 5:18 pm

My Album class is now making a call to the AlbumManager class, because I cannot ensure that users of the library will always call the correct function from AlbumManager.

Now, remembering back, I realize I have seen the Java API do this before on occasion.

Blog at