Skip to main content

Blog Archive for staufferjames during May 2007

I often see code like this (when using Java 1.4 or earlier): Iterator i = list.iterator(); while(i.hasNext()) { ... } but I write that as: for(Iterator i = list.iterator();i.hasNext();) { ... } because * It shorter * It keeps i in a smaller scope * It reduces the chance of confusion. (Is "i" used outside the while? Where is "i" declared?) I think code should be as simple to...
When I am in a drop down list and I press a letter to jump to the first entry that starts with that letter why does it leave that entry on the bottom of the visible entries? It should make the entry the top visable entry so that many entries that start with that letter can be seen. In more concrete terms if I am selecting a state from a drop-down list and press "w" it should make "Washington"...
I like to make my static method names start with an upper case letter. I know that isn't standard and that only class names are supposed to start with an upper case letter but I find that it is helpful because it quickly shows which methods are static. Also, I have never confused a static method with a class because the usage/syntax is different. Does this sound beneficial? Notes: I don't know...
ClassCastException didn't used to have a message but I noticed that now it has a message that includes the cast class and the object class. That extra info is very beneficial. (Note that only recently could I start using 1.5 in my main product so I am behind the times a bit.) What other common Throwables need improved messages? NullPointerException should have the name of the variable. I...
Do developers write good product documentation? Is someone who knows a product inside and out the best person to document it? Have you ever bought a product and you could obviously tell that the manual writer didn't speak the language natively? From my little knowledge of languages it seems that it works better for people to translate into their native language. I think the same principles...