Archive for June, 2004

Where to put ‘em constants

June 10, 2004

There’s a religious war goin on if you look this up at the sun java forums. Some say it’s a matter of preference, while some say they don’t like to use the <class>.<const> format(what!!) but clearly there seemed to be no answer. This javaworld article however seems to me the most clear one and makes me partial to putting them in a class with a private constructor. I also personally like the practice of <classname>.<const>, this generally clarifies the context of the constant :P , what this means is that if you have constants for UI and maybe you would specifically say UIConstants.MAX_MESSAGE_LENGTH and in another place you would use NetConstants.MAX_MESSAGE_LENGTH. This is just a personal preference, which I feel nice about :) .

What was the best part of this article however was this important bit

If you expose the strings, they get compiled into clients. If you then change them, it has no effect on the clients unless you recompile them. If, on the other hand, you use access methods, the new values immediately propagate to all of the clients.

I had never thought of this :D and initially dismissed this as optimization made by an older version of the compiler(the article itself was written in June 2001) but it’s still the case with the 1.4.1 compiler! Another one of those rare gotcha’s :)

Back to books

June 7, 2004

Getting back to the reading habit, picked up a copy of The Da Vinci Code by Dan Brown and got half way through yesterday. With a story like that I knew it would be controversial to say the least, so did some google’s on the topic and whoaaa :) . Whatever the truth or lore this book makes one helluva reading. Of course I looked up The Last supper (you have to you know!!).

It’s been quite sometime since my last “thriller” genre novel. Am predominantly into Oriental themed novels. Love Eric Van Lustbader. Read his entire Nicholas Linnear series :) an more. Bout 6 months ago started reading James Clavell’s series. Trying to read it all in sequence Shogun, Tai-pan, Gai-Jin. The last one was a OK, Tai-Pan being the best among ‘em. Planning on getting King Rat and Noble House (both by Clavell) when I got time to kill. But still like the Lustbader style where he fuses pat and the present oh so believably :D .