Archive for the 'Implementation' Category

Separate class for each id type
Wednesday, December 21st, 2011

The code I’ve been looking at recently has quite some problems with managing various ids. The ids in the system are confusing on many levels, both syntactically and semantically. To begin with, there are a lot of them. They are represented using a mix of ints, longs and strings. Even the same id may be [...]

Name classes for content, not usage
Wednesday, October 26th, 2011

To make a class as universally usable as possible, name it after its content, not its intended usage. After all, the usage might change, and you may find a new area of use for the class which you didn’t foresee. Example In the project I’m working on, I had a class called SelectedInstalledBase which represented [...]

What I learned from Kent Beck
Thursday, September 8th, 2011

This is a summary of what learned from a “Mastering TDD” course with Kent Beck. Given he is the creator of JUnit, I guess his thoughts on unit testing are worth considering. In some cases I might have rewritten, changed, extended or simply misunderstood what he was saying, but these were my notes from the [...]

Private static methods might be a smell
Wednesday, May 4th, 2011

I was extracting smaller methods out of existing big ones, in a class I was working on. Some of these extracted methods became “utility methods”: they would perform some operation on the parameters given to it, but not use any of the fields in the class. These methods could just as well have been static. [...]

Two kinds of interfaces
Tuesday, November 23rd, 2010

An interface is a point of interaction between two systems and they are used extensively within the Java world. While the mechanics of interfaces always are the same, the semantics may differ. There are (at least) two rather distinct types of uses for interfaces in Java. One type of interface, which we might call separation [...]

Exception Handling Policy – Logging Exceptions
Monday, July 13th, 2009

This is the last part of my series on exception handling which will deal with logging exceptions and other noteworthy events. A summary of the series: Throwing Exceptions Using Assertions Catching Exceptions Logging Exceptions (this one) General guidelines We’ll start [...]

Exception Handling Policy – Catching Exceptions
Monday, July 6th, 2009

This is the third installment in my series on sensible exception handling and will cover when and how to catch exceptions. To quickly summarize, the series looks as follows: Throwing Exceptions Using Assertions Catching Exceptions (this one) Logging Exceptions The [...]

Exception Handling Policy – Using Assertions
Monday, June 29th, 2009

This is the second part in a series of four on exception handling and it focuses on an area related to exceptions — assertions. A quick summary of posts in this series: Throwing Exceptions Using Assertions (this one) Catching Exceptions Logging Exceptions

Exception Handling Policy – Throwing Exceptions
Monday, June 22nd, 2009

This is the first post in a series of four on exception handling. The series will cover what I think is a good and sound strategy for handling exceptions and errors in your application. It is written with Java in mind, but is applicable to most languages which feature exceptions. This first issue will go through the art of throwing exceptions.

Scope control
Thursday, June 21st, 2007

Again, the book Test-Driven Development: By Example by Kent Beck provides me with an eye-opening experience. It explains how test-driven development is useful for scope control when developing.