What’s the deal with Java equals() and hashcode()?

Continue Reading January 26th, 2010 Jeff Howell

I came across this issue a couple years ago. It was surprisingly not-so-obvious to the developer, a good developer, who was sorting out a very elusive bug in a large Java application.

The symptom was that a Map of objects sometimes returned null when queried. The developer ran the code in a debugger and could see that the object was put into the Map. Yet, when the map was asked to retrieve the object, it was not found (even though it could be seen by inspection in the debugger).

Other objects were successfully stored and retrieved from the same Map.

Continue Reading Add comment

Using Code Metrics with Purpose

Continue Reading November 30th, 2009 Ben Northrop

I know plenty of developers who, at a tactical level, have had success with static source code analysis tools, using them to help find and root out bad code smells. When PMD tells us there’s an empty catch block at line 207, for instance, we know exactly what to do.

At an aggregate level, however, code metrics are seldom so helpful or straight-forward. When seeing that a source tree has 160,000 lines of code or an average cyclomatic complexity of 4.12, our first thought is usually “interesting!”…followed shortly by “well, now what?”.

The problem is, in my experience, we often look at our code metrics in isolation, without good comparison points, leaving us to wonder whether the numbers we see are big or small, typical or abnormal, good or bad. In the end, it’s not clear what to do, if anything.

Continue Reading Add comment

Motivating Beautiful Code

Continue Reading January 9th, 2009 Jeff Howell

A developer asked “How to convince someone [an IT manager] of the value proposition of great/beautiful code? (Or at least the value of code smell eradication.)”

This is a very real problem and is especially prevalent (in my experience) in larger, older programs that have met with some success, especially when the management are non-coder folk.

Beautiful Code is not an aesthetic pursuit; the Beauty lies in the fact that the code is well structured, concise, and obvious. This kind of beauty has high business value because it requires less effort and cost to extend with new features and to track down bugs.

Continue Reading 5 comments


Pages

Categories

Most Recent Posts

Feeds

  Subscribe in a reader

Calendar

March 2010
M T W T F S S
« Feb    
1234567
891011121314
15161718192021
22232425262728
293031  

Tags

Calendar

March 2010
M T W T F S S
« Feb    
1234567
891011121314
15161718192021
22232425262728
293031  

Posts by Month

Posts by Category