Bad smells in code

Every now and then I’m surprised at the cruft I find whern digging about in old code. This particular piece of loveliness isn’t of my doing but it’s certainly … interesting.

public TheObjectInQuestion(int a, String b, String c, String d, String e, long f, String g, String h, String i, String j, String k, String l, String m, String n, String u, String v, String w) { }

That’s 17 arguments, most of which are just Strings holding various special meanings such as status flags. You can guess what the javadocs tell you about this constructor… Yep, nothing.

But not to worry, TheObjectInQuestion has another constructor:

public TheObjectInQuestion(int a, String b, String c, String d, String e, long f, String g, String h, String i, String j, String k, String l, String m, String n, String u, String v) { }

Now that looks like You’ve just removed w from the parameters right? Wrong! The argument i from the original constructor was removed. So the compiler won’t pick up on your error, and eventually the app will do something stupid, in this case it’ll confuse the middleware to the extent that it ignores all requests from the app server.

Does anyone know any good books (short, easy to read) that explain to people without OO experience, how to think in OO terms. What I’d like is to have them use lots of small objects to represent data, but they don’t seem able to do it.

Posted on March 19th, 2003 | 2 comments | Commenting Closed
Lance

Lance March 20th, 2003 @ 02:31 AM

There was a book that came with Objective-C that was an excellent primer on OO. I think it was called something like “Object Oriented Programming For Managers”.

Dmitry

Dmitry March 20th, 2003 @ 04:07 PM

Give this a try. It helped me get two of new people on the team (MUMPS programmers before that) into OO and Java with minimal pain http://www.amazon.com/exec/obidos/tg/detail/-/0672318539/ref=lib_rd_btb/002-4698965-9938449?v=glance&s=books

Sponsors

Hosted excellently by RailsMachine