« Your Code.. it's Alive.. | Main | Speaking Dates »

March 13, 2007

Comments

Nat

I'd like all the power of the Refactoring browser at my fingertips when I *do* want to change code.

Why do we have these powerful, structure-aware editing tools and then only allow ourselves to use them for part of the time we're coding?

To quote Ralph Johnson: all software development is program transformation.

Brandon

WRT Move, if you're only moving up or down a couple of lines, doesn't Eclipse's Alt+Up Arrow/Alt+Down Arrow hit the spot? It doesn't have the common sense to know that the code will break, but you've got that covered with your tests anyway.

Tim

parameter object. Hmm...

I'm never sure if this is a pattern or an antipattern. I worry that it is actually pushing more requirements on the callers of a method. If you look at how some framework writers do it, it actually pollutes the users of the class. Now they have to not only give the values, they have to construct an object to hold them. If this is done it a constructor, it is no easier for the caller to construct the object to pass it than to call a difficult method. If it has to be done via setters, then it requires more code on the caller's side.

I know it's a tough game, and you make tradeoffs, but I consider a data object that holds parameters to be worse than a parameter list.

Calling a method should be as easy as possible, not just as small as possible. I shouldn't have to do setup to call the method. My principle is that a polite class has the absolute minimum burden on its callers. Having to create an object and fill it in is setup, and will occur (roughly repeated) in all of the callers (DRY). It will make the class less attractive to use, and will detract from the clarity of the caller.

If, on the other hand, the group of parameters recurs in calls to various methods of various classes (possibly out of order sometimes), then it's an easy guess that it ought to be a class with its own behavior and a defined lifetime.

I suppose you've already considered all of that, but you brought it up, and it's been bothering me a long time. And I'm in a ranting mood (not your fault).

Tim

Michael Feathers

Brandon wrote: "WRT Move, if you're only moving up or down a couple of lines, doesn't Eclipse's Alt+Up Arrow/Alt+Down Arrow hit the spot? It doesn't have the common sense to know that the code will break, but you've got that covered with your tests anyway."

I keep wishing for that but I spend a lot of time visiting people who aren't converted yet. :-). I think a tool which did some real analysis could help people recover when they don't have tests. It would help us too. It think it's nice that the better IDEs do some real analysis for things like Extract Method

Michael Feathers

Tim, yes, it's all judgment. The thing I notice though is that when you do notice values that hang around together in a couple of places and make a class, you often discover behavior that should go on that class over time so, the data object is just an intermediate state.

The comments to this entry are closed.