.java

musings on java and object oriented software development

Thursday, September 14, 2006

Taxophobia: the fear of class-ification

My workplace is being overrun by taxophobics or classphobics - those who believe it to be expensive to create new classes, they fear refactoring and would rather stick all their methods in one, gigantic, manager class.

A taxophobic would rather have a single class with 5 similar sounding methods than 5 classes sharing a common interface with one method in it.

A taxophobic believes that there is some inherit cost in creating new files; they're self appointed byte-conservationists.

Taxophobics will try to convince you of their infantile designs based on an argument of "pragmatism". "Refactoring" is a dirty word. They love static methods and they hate unit-testing.

I've been facing an uphill battle trying to convince these people that that doing something like this :


Validator.validateX();
Validator.validateY();
Validator.validateZ();
Validator.validate....();


would be much better replaced with something more generic :


for(Validator v : validators){
v.validate();
}


But you know what ? I realised that you can't argue with these people because they have no sense of style. They've got no hope either because you can't be taught style.

My belief is that you can't have style forced on you, you've got to come to your own enlightenment, your own epiphany, though I hope I'm wrong.

1 Comments:

At 10:24 AM, Blogger Ricky Clarkson said...

It sounds like you have amateur programmers as team leaders.

Get them interested in being software architects. Tell them there's more money there. This will result in them wanting to introduce lots of classes, because classes look good on UML diagrams.

Hopefully, they'll be promoted beyond harm's way soon enough.

More seriously, give them two pieces of functionally identical code, but which differs in style, and ask them to perform the same modification on each, and observe closely.

One reason for fearing many classes is poor tools, or poor knowledge of tools. For example, I struggled a few years back to read Gaim's source code, because it used polymorphism (well, function pointers..), and I was using vim, probably badly, and couldn't see where the functions were defined. In contrast, XChat and xmms were easy to follow. If I looked at gaim again I would probably look for decent C tools first (or learn how to use vim properly for C code).

Two resources that might be useful - The Pragmatic Programmer - I wanted to read this but I also had Java Puzzlers on the same desk, and that looked a bit more relevant to me.

Also, http://c2.com/cgi/wiki?FearOfAddingClasses

 

Post a Comment

Links to this post:

Create a Link

<< Home