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

RE: [XP] don't screw with the loop counter while looping (was: Ho w not to comment code)

Expand Messages
  • Dinwiddie, George
    Thanks again for the cool idea. ... From: Laurent Bossavit [mailto:laurent.bossavit@agencebless.com] Sent: Friday, March 30, 2001 10:54 AM To:
    Message 1 of 11 , Mar 30, 2001
    • 0 Attachment
      Thanks again for the cool idea.

      -----Original Message-----
      From: Laurent Bossavit [mailto:laurent.bossavit@...]
      Sent: Friday, March 30, 2001 10:54 AM
      To: extremeprogramming@yahoogroups.com
      Subject: RE: [XP] don't screw with the loop counter while looping (was:
      Ho w not to comment code)


      > That's pretty cool, but how do you use the valueFor() method? I
      > notice you didn't implement it in your example. It's curious to
      > me that perform() throws away the result.

      How embarrassing - that method should have fallen to YAGNI.
      (Hold a sec, I'll delete it from the source and run the tests... There.)

      I quoted the class code from memory yesterday, rather than
      copying actual code.

      What I had in mind originally was implementing something similar
      to Collection>> collect: aBlock, valueFor() was my translation of
      Block>>value. So the method would have run somewhat like

      public abstract class Block {
      // ...
      public Vector collect(Collection c) {
      Vector results = new Vector();
      for (Iterator elements = coll.iterator(); elements.hasNext();) {
      Object value = valueFor(elements.next());
      if (value != null) results.add(value);
      }
      return results;
      }
      }

      As it turns out, I never actually needed it. Also, my memory had it
      backwards - I had valueFor() delegate to perform() and return null.
      The idea was to override valueFor() when I needed a collecting
      block, and perform() when I needed an action block. I can't say
      whether that would have worked. ;)

      For the record, the actual code is now

      public abstract class Block {
      public void perform(Object arg) {}
      public void performOn(Collection coll) {
      for (Iterator elements = coll.iterator();
      elements.hasNext();) {
      perform(elements.next());
      }
      }
      }


      ========================================
      Bless n'a pas de modele : son ambition
      est d'en devenir un.
      ========================================
      Laurent Bossavit - Software Architect
      >>> laurent.bossavit@... <<<
      >>> 06 68 15 11 44 <<<
      >> ICQ#39281367 <<
      Agence Bless http://www.agencebless.com/
      ========================================

      To Post a message, send it to: extremeprogramming@...

      To Unsubscribe, send a blank message to:
      extremeprogramming-unsubscribe@...

      Ad-free courtesy of objectmentor.com

      Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
    Your message has been successfully submitted and would be delivered to recipients shortly.