Archive for the 'Imperfection' 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 [...]

Two types of design
Wednesday, November 2nd, 2011

Lately, I’ve been thinking about two ways to design a system. I’m having trouble with figuring out which one I actually prefer. I’ll try to describe them below. If you would like to read through the description and leave a comment or two I would be very grateful! Feel free to just add a comment [...]

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. [...]

Fire protection
Thursday, March 24th, 2011

When you build a house you have to think about fire safety. For a small cottage it might be enough with simple smoke detector. For a large building must also have fire alarms, extinguishers, sprinklers, emergency stairways, signs of evacuation routes and much more. Exactly what is needed is adapted to house size. All this [...]

Solution: “Temporary ID hasn’t been replaced on commit” when using Cayenne
Monday, January 24th, 2011

Problem When committing changes to a Cayenne context, you get an exception like the following. org.apache.cayenne.CayenneRuntimeException: (v.3.0.1 Sep 06 2010 15:09:38) Temporary ID hasn’t been replaced on commit Cause You are trying to commit an object for which Cayenne does not know how to generate a permanent id. This in turn typically happens when the [...]

Solution: “Error generating PK : entity not supported” when using Cayenne
Thursday, January 13th, 2011

Problem When committing changes to a Cayenne context, you get an exception like the following. org.apache.cayenne.CayenneRuntimeException: (v.3.0.1 Sep 06 2010 15:09:38) Error generating PK : entity not supported: SOME_TABLE Cause A column that is part of the primary key of SOME_TABLE has no value. Therefore Cayenne tries to generate one, but does not know how [...]

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 [...]

Real world refactoring
Wednesday, June 16th, 2010

The tram stop next to my apartment has been completely rebuilt during the last few weeks. They removed every part of the old one, including the actual little shelter, the fence, the curb, the pavement — everything. A pretty major change as far as tram stop remakes go. It could be seen as a clear [...]