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

RE: [XP] Removing duplication in menu handlers ...

Expand Messages
  • Charlie Poole
    Ron, ... I find this happens a lot. I feel like there s something trying to get out and if I do make a change the wrong way I ll be less likely to see what
    Message 1 of 63 , Nov 30, 2002
    • 0 Attachment
      Ron,

      > I'm thinking that once I package up the grubbiness of setting the text
      > and selection separately, the idea waiting to come out won't have a
      > chance to come out. (That could be OK. Maybe that Extract Method is
      > all the idea needed.)

      I find this happens a lot. I feel like there's something trying to get
      out and if I do make a change the wrong way I'll be less likely to see
      what that is. So I live with the uncertainty for awhile.

      On the other hand, some changes feel like they clarify where I'm trying
      to go, so I do them. And some are no big deal at all, so I do them
      as well.

      > I'm thinking that one duplication is NOT
      > model.SetLines ...
      > model.SelectionStart ...
      > and ANOTHER
      > PutText ...
      >
      > I'm thinking that there is only one duplication:
      > model.SetLines ...
      > model.SelectionStart ...
      > one odd difference right in the middle
      > PutText ...

      That's what I see, and what led me to suggest something like:

      > void MenuInsertHandler( object obj, EventArgs ea )
      > {
      > someKindOfViewObject.InsertTag(
      > TagForMenuItem( obj ), textbox.Lines, textBox.SelectionStart );
      > }

      But that actually mixes two things together: translating the particular
      menu item to a function and removing the duplication. It's probably
      better to deal with one of these at a time.

      > And I don't see how to extract that yet. There's probably a really
      > clear way to do it with delegates or something, along the lines of
      > this ...
      >
      > void MenuInsertPre(object obj, EventArgs ea) {
      > TransformModel(InsertPreTag);
      > }
      >
      > void MenuInsertSection(object obj, EventArgs ea) {
      > TransformModel(InsertSectionTags);
      > }

      or maybe just

      void MenuInsertSection( object ob, EventArgs ea )
      {
      InsertTag( "section" );
      }

      as a simpler way of moving down that same road.

      > I guess I'm leaving it that way to be sure it continues to tick me
      > off, and because it's not very harmful left alone.
      >

      I'd hazard that it's not harmful to leave it _because_ it continues
      to tick you off.

      Charlie Poole
      cpoole@...
      www.pooleconsulting.com
      www.charliepoole.org
    • Ron Jeffries
      ... That s what I m hoping. But I know what point in time is referred to by the phrase we ll clean it up later . So I m really happy to have all these pair
      Message 63 of 63 , Nov 30, 2002
      • 0 Attachment
        On Saturday, November 30, 2002, at 2:53:08 PM, Charlie Poole wrote:

        >> I guess I'm leaving it that way to be sure it continues to tick me
        >> off, and because it's not very harmful left alone.
        >>

        > I'd hazard that it's not harmful to leave it _because_ it continues
        > to tick you off.

        That's what I'm hoping. But I know what point in time is referred to
        by the phrase "we'll clean it up later". So I'm really happy to have
        all these pair programmers reminding me that there's a little suction
        in this part of the code.

        Ron Jeffries
        www.XProgramming.com
        Analysis kills spontaneity.
        The grain once ground into flour germinates no more. -- Henri Amiel
      Your message has been successfully submitted and would be delivered to recipients shortly.