My thoughts as an enterprise Java developer.

Tuesday, April 19, 2005

Case of static method names

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 is different. Does this sound beneficial?

(I don't know from where I got this idea but at one time I assumed it was a standard.)

Friday, April 08, 2005

Developer Documentation

Have you ever gotten a product and you could obviously tell that the person who wrote the manual didn't speak English 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 applies to developers translating from code to documentation. I would prefer to explain how a product works to a user and have the user write the documentation because they will cover things that seem obvious to me but not the average user.
Someone not intimately familiar with the product will probably write much better documentation.

Finding duplicate code

I noticed some duplicate code in a program that I help maintain and thought "wouldn't it be nice to have a tool that found duplicate lines of code?"
After a quick chat with a co-worker we decided that we could make something that read in every source line, trimmed it, created a hash and added that hash to a List for that file. Also add that hash to a Map with a List of all of the files and lines where that hash occurs. When all files are read go through all lines with the same hash (from the Map) and look at the next lines to find if those hashes match. It wasn't a perfect design but it would probably work well enough.
Before I went any further I decided to check Google and low and behold I found PMD http://pmd.sourceforge.net/cpd.html. It is on its 3rd algorithm and "now it can process the JDK 1.4 java.* packages in about 4 seconds" and "works with Java, C, C++, and PHP code." I guess there isn't much point in writing my own version. :-) Remember to always do a quick search before coding something new.

Wednesday, April 06, 2005

Anonymous class constructor

Today I was trying to modify an anonymous class to add a parameter to the constructor. After talking to 3 other co-workers we couldn't decide if it was possible because a constructor has to be named to match the name of the class and an anonymous class does not have a name. I found the answer at http://www.developer.com/java/other/article.php/3300881 under the section titled "Anonymous classes versus local classes." I am not including the answer here so that you can think about it for a while if you desire.

Tuesday, April 05, 2005

Extra info in stack traces

I often find that when I see a stack trace I want to know the value of some variables in that stack. I created a request for enhancement (http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4857236).
Does that seem useful to you?

What was null?

When I get a NullPointerException I usually have to look at the source code to determine what might have been null. Therefore I created a feature request (http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4834738) to request that NullPointerExceptions include the name of the variable when possible. Do you think that would be useful?

Friday, April 01, 2005

del.icio.us Bookmarks

I have added most of my computer and programming related bookmarks to http://del.icio.us/Stauffer