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

Refactoring Workbook: A subtle problem of responsibility

Expand Messages
  • Bill Wake
    In working on some ideas about balance of responsibility, I created an example where a subtle choice pushes the system in different directions: Imagine a
    Message 1 of 9 , Oct 4, 2002
    • 0 Attachment
      In working on some ideas about balance of responsibility, I created
      an example where a subtle choice pushes the system in different
      directions:

      Imagine a simple catalog of items that we'd like to query. We might
      expect that the catalog and the query have to collaborate to produce
      the answer. Should the catalog work on the query, or should the query
      work on the catalog? [And what are the third, fourth, ... ways I'm
      not yet seeing??]

      The writeup is at:
      http://www.xp123.com/rwb/ch20-MoreResp.htm

      Thanks,
      Bill Wake William.Wake@... www.xp123.com
    • Dale Emery
      Hi Bill, ... This additional possibility popped into my head: Interrogator applies Query to Catalog. (There s likely a better name than Interrogator.) Dale
      Message 2 of 9 , Oct 4, 2002
      • 0 Attachment
        Hi Bill,

        > Imagine a simple catalog of items that we'd like to query. We might
        > expect that the catalog and the query have to collaborate to produce
        > the answer. Should the catalog work on the query, or should the query
        > work on the catalog? [And what are the third, fourth, ... ways I'm
        > not yet seeing??]

        This additional possibility popped into my head: Interrogator applies
        Query to Catalog. (There's likely a better name than Interrogator.)

        Dale
      • Charlie Poole
        If you plan to be in Seattle on Thursday, October 10, the Seattle XP group meeting on that day features talks by Jim Newkirk and Martin Fowler. Jim will talk
        Message 3 of 9 , Oct 4, 2002
        • 0 Attachment
          If you plan to be in Seattle on Thursday, October 10, the
          Seattle XP group meeting on that day features talks
          by Jim Newkirk and Martin Fowler. Jim will talk about
          "Agile Development with a Distributed Development Team"
          and Martin will explore "The Role of Design in XP"

          For more info, see the wiki page at
          http://showell.westhost.com/cgi-bin/XpSeattleWiki.pl?NextMeeting

          Charlie Poole
          cpoole@...
          www.pooleconsulting.com
          www.charliepoole.org
        • Alex Chaffee / Purple Technology
          OOADvice from my site: -- Maximize Directionality I don t know much about OOAD, but one thing I do know is: maximize
          Message 4 of 9 , Oct 4, 2002
          • 0 Attachment
            OOADvice from my site: <http://www.purpletech.com/maxims.jsp>

            --
            Maximize Directionality

            I don't know much about OOAD, but one thing I do know is: maximize
            directionality; in other words, minimize bidirectionality. If
            knowledge about another object is represented by an arrow, you want to
            try as much as possible to make an object (B), when pointed to, not
            point back to the object that pointed to it (A). If you find you have
            bidirectional knowledge, you can resolve it in a few ways; to wit:

            1. Take some of the functionality out of B and put it into A;

            2. Make a new object (C) that points to (has knowledge of) both A and
            B, and then make A and B ignorant of each other;

            3. Make an interface (I) abstracting the stuff about A that B needs to
            know, and make B refer to I instead of directly to A

            --

            In your first solution, it seems to follow what Josh Kerievsky calls
            the Criteria Pattern, or something like that, I think. It should be
            in the next draft of his book Refactoring To Patterns
            <http://www.industriallogic.com/papers/>

            It seems to me to be a refinement of the Strategy pattern (but I'm a
            patterns newbie, and I often get similar patterns mixed up) -- the
            object (callback) you pass in implements a strategy for determining
            whether a particular item matches or doesn't match.

            --
            Alex Chaffee mailto:alex@...
            jGuru - Java News and FAQs http://www.jguru.com/alex/
            Creator of Gamelan http://www.gamelan.com/
            Founder of Purple Technology http://www.purpletech.com/
            Curator of Stinky Art Collective http://www.stinky.com/
          • William Wake
            Right - I shouldn t set it up A B as a false dichotomy. ... Right - I would call the first version a filter where the Query is a Strategy that decides which
            Message 5 of 9 , Oct 5, 2002
            • 0 Attachment
              Right - I shouldn't set it up A<->B as a false dichotomy.


              >From: Alex Chaffee / Purple Technology <alex@...>
              >In your first solution, it seems to follow what Josh Kerievsky calls
              >the Criteria Pattern, or something like that, I think. It should be
              >in the next draft of his book Refactoring To Patterns
              ><http://www.industriallogic.com/papers/>
              >
              >It seems to me to be a refinement of the Strategy pattern (but I'm a
              >patterns newbie, and I often get similar patterns mixed up) -- the
              >object (callback) you pass in implements a strategy for determining
              >whether a particular item matches or doesn't match.

              Right - I would call the first version a filter where the Query is a
              Strategy that decides which items are acceptable. I made Query an abstract
              class but it would probably be better to say "Extract Interface."

              The second version is basically an Interpreter pattern; the set of items
              forms the context for the evaluation of an expression. (I could probably
              bring this out more too.)

              So, this all makes me think of a third way that's a little closer to an
              independent third object: have the catalog give an enumerator of its
              contents, and then have a "FilterEnumerator" that acts as a Decorator. (It
              takes the catalog's enumerator and the query, to decide which items are in
              the result.) I don't quite see the same scope for optimization as with the
              others: it embeds a decision "we will list everything in the catalog." That
              probably means it's just pushing toward something I don't see yet. (I'll
              work on an implementation today; I do remember some rule about not
              speculating too much:)

              Thanks!
              Bill Wake William.Wake@... www.xp123.com




              _________________________________________________________________
              Chat with friends online, try MSN Messenger: http://messenger.msn.com
            • Mark Derricutt
              Will notes from this talk be available online at all? Would be interesting to read/hear it. (mp3 recording anyone?) :) --On Friday, October 04, 2002 14:43:41
              Message 6 of 9 , Oct 5, 2002
              • 0 Attachment
                Will notes from this talk be available online at all? Would be interesting
                to read/hear it. (mp3 recording anyone?) :)

                --On Friday, October 04, 2002 14:43:41 -0700 Charlie Poole
                <cpoole@...> wrote:

                > "Agile Development with a Distributed Development Team"



                "I'm the prince of f*cking darkness, Sharon, I don't do bubbles!"
                - The Ozzman Cometh
              • Bill de hÓra
                ... If you treat queries and catalogs as incoming streams and results as outgoing streams, who gets applied to who becomes an implementation detail:
                Message 7 of 9 , Oct 6, 2002
                • 0 Attachment
                  > > Imagine a simple catalog of items that we'd like to query. We might
                  > > expect that the catalog and the query have to collaborate
                  > to produce
                  > > the answer. Should the catalog work on the query, or should
                  > the query
                  > > work on the catalog? [And what are the third, fourth, ... ways I'm
                  > > not yet seeing??]

                  If you treat queries and catalogs as incoming streams and results as
                  outgoing streams, who gets applied to who becomes an implementation
                  detail:

                  eval(query, catalog) returns results

                  all the better if query and catalog and results are in the same syntax.

                  Bill de hÓra
                  --
                  Propylon
                  www.propylon.com
                • Charlie Poole
                  Our group has a spotty record of putting out summaries. We ll try. :-) Charlie Poole cpoole@pooleconsulting.com www.pooleconsulting.com www.charliepoole.org
                  Message 8 of 9 , Oct 6, 2002
                  • 0 Attachment
                    Our group has a spotty record of putting out summaries. We'll try. :-)

                    Charlie Poole
                    cpoole@...
                    www.pooleconsulting.com
                    www.charliepoole.org


                    > -----Original Message-----
                    > From: Mark Derricutt [mailto:mark@...]
                    > Sent: Saturday, October 05, 2002 9:01 PM
                    > To: extremeprogramming@yahoogroups.com
                    > Subject: Re: [XP] ANN: Seattle XP Group Meeting - October 10
                    >
                    >
                    > Will notes from this talk be available online at all? Would be
                    > interesting
                    > to read/hear it. (mp3 recording anyone?) :)
                    >
                    > --On Friday, October 04, 2002 14:43:41 -0700 Charlie Poole
                    > <cpoole@...> wrote:
                    >
                    > > "Agile Development with a Distributed Development Team"
                    >
                    >
                    >
                    > "I'm the prince of f*cking darkness, Sharon, I don't do bubbles!"
                    > - The Ozzman Cometh
                    >
                    > 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/
                    >
                    >
                    >
                    >
                  • J. B. Rainsberger
                    So said Dale Emery on 2002-10-04 ... query ... QueryExecuter. Possibly the Catalog is the QueryExecuter, but at least QueryExecuter is a role that any other
                    Message 9 of 9 , Oct 11, 2002
                    • 0 Attachment
                      So said Dale Emery on 2002-10-04

                      >Hi Bill,
                      >
                      >> Imagine a simple catalog of items that we'd like to query. We might
                      >> expect that the catalog and the query have to collaborate to produce

                      >> the answer. Should the catalog work on the query, or should the
                      query
                      >> work on the catalog? [And what are the third, fourth, ... ways I'm
                      >> not yet seeing??]
                      >
                      >This additional possibility popped into my head: Interrogator applies
                      >Query to Catalog. (There's likely a better name than Interrogator.)

                      QueryExecuter. Possibly the Catalog is the QueryExecuter, but at least
                      QueryExecuter is a role that any other class can play. An interface, in
                      other words.

                      This is a common implementation pattern for me: a separate interface
                      for the CommandExecuter. It makes it easy to move the executing
                      responsibilities around. I naturally create such an interface in the
                      course of writing any such code.

                      J. B. Rainsberger,
                      President, Diaspar Software Services
                      Let's write software that people understand.
                      http://www.diasparsoftware.com/
                      telephone: +1 416 791-8603
                      All correspondence (c) 2002 Diaspar Software Services.
                      If you want to use it, just ask; don't steal.
                    Your message has been successfully submitted and would be delivered to recipients shortly.