Loading ...
Sorry, an error occurred while loading the content.

62429RE: [XP] Final Wizard Article

Expand Messages
  • Charlie Poole
    Sep 30, 2002
      Edmund,

      Thanks for the feedback. Comments below.

      > Charlie Poole wrote:
      > >
      > > Hi All,
      > >
      > > The last article in my series on writing a wizard is now posted.
      > > I'd appreciate any comments or corrections.
      > >
      > > The three are all linked from my articles page at
      > > http:charliepoole.org/cp.php?p=articles
      >
      > A couple of (minor?) nits:
      >
      > Are the pages *supposed* to have blank <TITLE> tags?

      It's an artifact of how I create the pages - I could
      put one in that says "CharliePoole.org - Article" but
      ultimately I'd prefer it to have a real title. That
      may not happen till I convert to XML for the articles.

      > In the new Execute() method, the code looks roughly like:
      >
      > int step = 0;
      > int nsteps = 2;
      > Form[] form = { new TestFixtureTypeForm( this ),
      > new TestFixtureOptionsForm( this ) };
      > while ( step >=0 && step < nsteps ) {
      > form[step].ShowDialog();
      >
      > etc.
      > Doesn't C# support some way to get array lengths easily, along the lines
      > of Java's .length property? A separate nsteps variable is duplication;
      > and of course, not following DRY means you're all wet!

      Your right... it's form.Length. Shows I'm still thinking in terms
      of C++ arrays, I guess.

      > You've got a couple of switch statements in there - any thoughts towards
      > refactoring them out along the lines of Fowler's Replace Conditional
      > With Polymorphism?

      I actually like them as they are, at least for now.

      There's one in the wizard itself that handles different result codes,
      of which there are only four possible. I do think the code that
      contains it - the form sequencing code - has a bit of an impulse
      toward being a separate class, in which case the switch will get
      encapsulated.

      The other switch is in the test generator, where it directs output
      to one of three kinds of tests. Again, I'd feel I was being premature
      if I made that polymorphic right now. It would also be slightly
      inconsistent, since everything that happens below the Generate()
      function is written in a fairly linear, procedural style.

      I also don't think I'd gain much in either case. I'd eliminate
      a switch by creating one abstract and three concrete classes.
      I'd have to decide which one to create, probably using a new
      switch. If either switch was repeated in multiple places, I'd
      be more inclined toward the refactoring.

      I do think that some of this code is asking to be changed - some
      day. I'm just not quite sure what it wants to be.

      > > There's a little commentary at the end of the third article
      > > titled "What's It Good For?" which might be an interesting
      > > subject of discussion on this list.
      >
      > Hmmmm. Is it a useful tool? Perhaps, as you say, it would be useful for
      > quickly generating empty tests for big chunks of legacy code.
      >
      > I don't think it's that useful for folks doing TDD, though, since you
      > need the class before the tool can generate tests. In TDD, you are
      > expected to write the test first, then get it to compile, then get it to
      > pass.

      I agree.

      I chose this as an example for two reasons.
      1. It's a feature request for NUnit.
      2. I couldn't think of another one.

      Now I do have one other idea - a wizard to generate wizards that use
      C# and Windows Forms. But I'll want to do a few others by hand first.

      Any suggestions?

      Charlie Poole
      cpoole@...
      www.pooleconsulting.com
      www.charliepoole.org
    • Show all 4 messages in this topic