Java Anti-Pattern

I was doing some Java programming today, and I noticed an anti-pattern that was in an existing code base. It went something like the following:

public Class Klass {
    ...

    public Klass(int foo, boolean flag, String s1, String s2, String s3, String s4) {
        initialize(foo, flag, s1, s2, s3, s4);
    }

    public Klass(int foo, boolean flag, String s1, String s2, String s3) {
        initialize(foo, flag, s1, s2, s3, null);
    }

    public Klass(int foo, boolean flag, String s1, String s2) {
        initialize(foo, flag, s1, s2, null, null);
    }

    public Klass(int foo, boolean flag, String s1) {
        initialize(foo, flag, s1, null, null, null);
    }

    public Klass(int foo, boolean flag) {
        initialize(foo, flag, null, null, null, null);
    }

    private initialize(int foo, boolean flag, String s1, String s2, String s3, String s4) {
        _foo = foo;
        _flag = flag;
        _s1 = s1;
        _s2 = s2;
        _s3 = s3;
        _s4 = s4;
    }

    ...
}

Immediately, my Don't Repeat Yourself sensor went off. It felt like the previous coder was essentially trying to use some default values for a method. You can do something like this in other languages, even other statically typed ones. In Ruby, it would be pretty simple:

Read on →

22 idea street

I have a variety of interests and opinions, so as you might imagine, I struggled to come up with a name that would represent my true hopes for this blog. It seems like a permanent enough thing, being on the web and all. I took an unorthodox approach to generating the name that seems to have had significant positive effects. I took all of my personal writings for the last year or so, coded up a Ruby script that would calculate and sort the word frequencies, read through the list, and then took a nap.

My subconscious worked on it for awhile, and when I woke up, I asked myself what the correct name should be. A couple of strange hazy names came to mind, and then in literally a flash of insight, '22 idea street' popped into my head. It immediately seemed correct, although I didn't necessarily understand why. I excitedly woke up and wrote it down.

After thinking about it for a few minutes, each of the parts actually represents something that is deeply important to me.

Read on →