Re: TDD and Refactoring
From: Harry Erwin (herwin_at_theworld.com)
Date: 12/26/03
- Next message: Harry Erwin: "Re: TDD and Refactoring"
- Previous message: Harry Erwin: "Re: TDD and Refactoring"
- In reply to: Ron Jeffries: "Re: TDD and Refactoring"
- Next in thread: Ron Jeffries: "Re: TDD and Refactoring"
- Reply: Ron Jeffries: "Re: TDD and Refactoring"
- Reply: Ron Jeffries: "Re: TDD and Refactoring"
- Reply: Daniel T.: "Re: TDD and Refactoring"
- Reply: Harry Erwin: "Re: TDD and Refactoring"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Fri, 26 Dec 2003 09:34:26 +0000
Ron Jeffries <ronjeffries@REMOVEacm.org> wrote:
> On Wed, 24 Dec 2003 09:12:28 +0000, herwin@theworld.com (Harry Erwin) wrote:
>
> >3. The class instances that are displayed in the GUI needed to hang
> >around, so many of the polymorphism strategies had to be implemented
> >using State/Strategy patterns. This produced an inheritance hierarchy
> >explosion.
> >
> >4. Unit testing the math turned into a serious headache, especially with
> >all the special cases. The business logic test case suite looks like
> >it's headed for 100+ individual test cases. This is for a single use
> >case.
> >
> >5. Replacing temps with queries produced method explosions in the key
> >classes of the business logic.
> >
> >6. I was hoping careful refactoring would reveal some different ways of
> >organizing the design. The complexity explosions made it very difficult
> >to see the forest for the trees.
>
> It would be very interesting to see more about this, especially as the
> system evolved. As complexity increases, I'd expect that there is
> something to do about it early on, so that one doesn't get an explosion.
> So I'm wondering whether certain code smells were not detected in time.
> There are many more refactorings besides Extract Method, as you know, and
> Extract Method alone does tend to add trees to the forest.
The experiment is to create a combat results table analyzer for a
complex manual war game (World in Flames) that has been in development
since 1985. During that period, it has been extensively redesigned six
times and has accumulated lots of 'chrome'. I'm one of the beta
testers/advisors for the new computer edition (I currently teach
intelligent systems at university and have some background in game AI),
and the tool is supposed to allow me to figure out what the hell is
going on in the game. So the underlying business logic is arcane to say
the least.
>
> I'm also wondering why there were special cases in the math. I ask because
> good math seems to always be quite general, with very few special cases.
> On the other hand, 100 test cases might be a perfectly reasonable number,
> depending on what the app is. Even a thousand might be reasonable.
I'm trying to replicate the game system, which is messy, but is also
similar to a lot of systems I've worked on in industry. (e.g, Air
Traffic Control).
>
> Replacing temp with query, I would say, does not increase complexity: there's
> exactly one query per temp. Perhaps I'm missing something.
You replace an expression with a method.
>
> Also, if there are a lot of temps wanting to be around, there might be
> some classes wanting to be extracted. Did you observe that need, and
> respond to it?
The next major thing. A lot of the special cases depend on the values of
String fields. I have to preserve the containing class instances (the
GUI needs them to be final), but those are obvious places to exploit
polymorphism. I'm deferring that until I have most of the special cases
in place.
>
>
> It's entirely possible that you have ended up with the best possible
> system, but it sounds like your intuition says otherwise. Your intuition
> is probably right. So what would make the system better, and why didn't
> the refactoring approach lead you there?
The refactoring approach is causing me to consider alternative patterns,
but there are some deep gulfs that I have to cross before I can use
them.
>
> You have had an interesting experience -- it would be great to read the
> article or book that explains it all. What more have you the time to tell
> us?
Refactoring also applies to the test cases... Getting the test data set
up easily and cleanly for each test case forced a rethink of the data
initialization approach in the system under test. Thank God I had
separated the domain model from the GUI at that point.
-- Harry Erwin <http://www.theworld.com/~herwin/>
- Next message: Harry Erwin: "Re: TDD and Refactoring"
- Previous message: Harry Erwin: "Re: TDD and Refactoring"
- In reply to: Ron Jeffries: "Re: TDD and Refactoring"
- Next in thread: Ron Jeffries: "Re: TDD and Refactoring"
- Reply: Ron Jeffries: "Re: TDD and Refactoring"
- Reply: Ron Jeffries: "Re: TDD and Refactoring"
- Reply: Daniel T.: "Re: TDD and Refactoring"
- Reply: Harry Erwin: "Re: TDD and Refactoring"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|