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

Re: XP or design patterns?

Expand Messages
  • gorowitch
    ... better ... [lot of text snipped away] If you re really studying design patterns and XP. Consider reading Design Paterns and eXtreme programming
    Message 1 of 12 , Feb 1, 2002
      --- In extremeprogramming@y..., "hepabolu" <hepabolu@h...> wrote:
      > Hi all,
      >
      > I'm studying design patterns and Java and XP in order to write
      better
      > software for my research project. I hope some of you can help me
      > decide on the best way to handle this.
      >
      > The situation is this:
      [lot of text snipped away]

      If you're really studying design patterns and XP. Consider reading
      "Design Paterns" and "eXtreme programming eXplained" before you start
      designing or writing source code.

      >
      > Question:
      > What kind of pattern do I have to use to handle different objects
      > with the same kind of algorithm?
      >
      > E.g. I could have a PersonSearcher that can pass on a PersonQuery to
      > a PersonDatabaseConnection and retrieve Person objects that are
      > returned as a PersonResult. Then I'd have to duplicate all this for
      > Items. This doesn't seem right.
      >

      The short anwer is to "program to an interface and not to an
      implementation". You'll probably end up having a Searcher, a Query, a
      Connection, a Result (all interfaces). Then write your classes to that
      interface. But read Design Patterns first, things will clear up.

      Also consider reading the following article:

      http://www.objectmentor.com/resources/articles/ocp.pdf

      Dig into javadoc and check out the java.util package, especially the
      interfaces and how they are used.

      Kind Regards,
      Sven
    • Joshua Kerievsky
      ... Helma, Why not test-first program something that works first? Once you do that, it ll be easier to see which design patterns, if any, could help improve
      Message 2 of 12 , Feb 1, 2002
        >I'm studying design patterns and Java and XP in order to write better
        >software for my research project. I hope some of you can help me
        >decide on the best way to handle this.

        Helma,

        Why not test-first program something that works first? Once you do that,
        it'll be easier to see which design patterns, if any, could help improve
        your design. Refactoring as you go may also make it easier to see where a
        pattern could help.

        regards
        jk

        I n d u s t r i a l L o g i c , I n c .
        Joshua Kerievsky
        Founder, Extreme Programmer & Coach
        http://industriallogic.com
        510-540-8336
      • Laurent Bossavit
        ... Wanting to write better software is commendable, whatever the approach you take toward it. ... The simplest that can possibly work ? ... Why would you
        Message 3 of 12 , Feb 1, 2002
          > I'm studying design patterns and Java and XP in order to write better
          > software for my research project.

          Wanting to write better software is commendable, whatever the
          approach you take toward it.

          > What kind of pattern do I have to use to handle different objects
          > with the same kind of algorithm?

          The simplest that can possibly work ?

          > E.g. I could have a PersonSearcher that can pass on a PersonQuery to a
          > PersonDatabaseConnection and retrieve Person objects that are returned
          > as a PersonResult. Then I'd have to duplicate all this for Items.

          Why would you "have to" duplicate "all this" ?

          Is there a simplification you could apply to the existing structure
          to make your new task easier ?

          When you look at the existing code, do you see much duplication ?
          Looking for ways to eliminate that duplication

          The above question assumes there *is* existing code, in addition to
          the design.

          If there is no code yet, I suggest starting from what the software is
          supposed to *do* and code it up bit by bit, never writing one line of
          code unless you have a failing unit test that forces you to.

          If there is some existing code already, what kind of tests is it
          currently equipped with ?

          -[Morendil]-
          Tried to play my shoehorn... all I got was footnotes!
        • alex@jguru.com
          ... Look up polymorphism in the index of any Introduction To OOP textbook or Web site. If you re using Java, RTFM for the extends and implements
          Message 4 of 12 , Feb 3, 2002
            On Fri, Feb 01, 2002 at 03:11:28PM -0000, hepabolu wrote:
            > Question:
            > What kind of pattern do I have to use to handle different objects
            > with the same kind of algorithm?

            Look up "polymorphism" in the index of any Introduction To OOP
            textbook or Web site. If you're using Java, RTFM for the "extends"
            and "implements" keywords.

            This question has nothing to do with Extreme Programming. You may
            find more help on a different list.

            Good luck -

            - Alex


            --
            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/
          • hepabolu
            Hello guys, thanks for the advices. I suppose I should have elaborated more: I started off with a situation where I had only a connection to a Person database.
            Message 5 of 12 , Feb 4, 2002
              Hello guys,

              thanks for the advices. I suppose I should have elaborated more:
              I started off with a situation where I had only a connection to a
              Person database. I liked the idea (I got from this list) to separate
              into Searcher, Query and Result to be able to add mock up classes for
              testing.
              All this worked fine and only asked for minor changes to add the
              second database connection. However, when I had to add the connection
              to the Item database with it's own Search/Query/Result classes I felt
              I had to change too much code in places that weren't even related. So
              this calls for refactoring and I thought I'd need design patterns.
              I've studied the GoF book, but I can't decide on the correct pattern
              to use. Interfaces sound fine, but how to handle the situation where
              I end up with methods that only differ in return type (i.e.
              PersonResult vs. ItemResult). I don't want to return Objects that
              have to be casted to either Person or Item, unless that's the only
              way to do it.

              Bye, Helma


              --- In extremeprogramming@y..., Joshua Kerievsky <joshua@i...> wrote:
              >
              > >I'm studying design patterns and Java and XP in order to write
              better
              > >software for my research project. I hope some of you can help me
              > >decide on the best way to handle this.
              >
              > Helma,
              >
              > Why not test-first program something that works first? Once you do
              that,
              > it'll be easier to see which design patterns, if any, could help
              improve
              > your design. Refactoring as you go may also make it easier to see
              where a
              > pattern could help.
              >
              > regards
              > jk
              >
              > I n d u s t r i a l L o g i c , I n c .
              > Joshua Kerievsky
              > Founder, Extreme Programmer & Coach
              > http://industriallogic.com
              > 510-540-8336
            • Bill Tozier
              The new contender for Most Evil Corporation in America, Comcast, has eliminated all support for usenet and does not offer any nntp servers. In addition to the
              Message 6 of 12 , Feb 4, 2002
                The new contender for Most Evil Corporation in America, Comcast, has
                eliminated all support for usenet and does not offer any nntp
                servers. In addition to the loss of convenient and voluminous mp3
                downloads, I would like to browse the comp.xp newsgroups now and
                then. Can anybody recommend a source for a browseable version of the
                newsgroup comp.programming.extremeprogramming? I am somewhat aware of
                Google's deja archives; is there a possibility that somebody might
                also be archiving the newsgroup in a Yahoo group?

                Thanks,
                Tozier
                --
                William Tozier
                bill@...

                "Unlike Playstation2 games, Linux will not run on standard televisions."
                -- from an Ananova story, 2002
              • jeffgrigg63132
                ... televisions. ... I bet we could make it do so, if we really wanted to. 40 columns by 25 text lines is about all the standard television signal is good
                Message 7 of 12 , Feb 4, 2002
                  --- Bill Tozier <bill@w...> wrote:
                  > "Unlike Playstation2 games, Linux will not run on standard
                  televisions."
                  > -- from an Ananova story, 2002

                  I bet we could make it do so, if we really wanted to. 40 columns by
                  25 text lines is about all the standard television signal is good
                  for, but if that's good enough for you, *GO FOR IT!!!* ;->

                  I connected my original IBM PC to a color television, to complement
                  my black and white monitor. But that was a few years ago. ;->
                • jeffgrigg63132
                  ... the ... of ... For convenience, here s the Google URL: http://groups.google.com/groups?hl=en&group=comp.software.extreme- programming
                  Message 8 of 12 , Feb 4, 2002
                    --- Bill Tozier <bill@w...> wrote:
                    > [...] Can anybody recommend a source for a browseable version of
                    the
                    > newsgroup comp.programming.extremeprogramming? I am somewhat aware
                    of
                    > Google's deja archives; is there a possibility that somebody might
                    > also be archiving the newsgroup in a Yahoo group?

                    For convenience, here's the Google URL:
                    http://groups.google.com/groups?hl=en&group=comp.software.extreme-
                    programming
                  • Bill Tozier
                    ... The quote was from an article discussing the very real (and immanent) release of Linux FOR Playstation2, by the way. Truth is stranger than we can imagine,
                    Message 9 of 12 , Feb 4, 2002
                      On or about 2/5/02, jeffgrigg63132 wrote something like:

                      >--- Bill Tozier <bill@w...> wrote:
                      >> "Unlike Playstation2 games, Linux will not run on standard
                      >televisions."
                      >> -- from an Ananova story, 2002
                      >
                      >I bet we could make it do so, if we really wanted to. 40 columns by
                      >25 text lines is about all the standard television signal is good
                      >for, but if that's good enough for you, *GO FOR IT!!!* ;->
                      >
                      >I connected my original IBM PC to a color television, to complement
                      >my black and white monitor. But that was a few years ago. ;->

                      The quote was from an article discussing the very real (and immanent)
                      release of Linux FOR Playstation2, by the way. Truth is stranger than
                      we can imagine, more times than not....
                      --
                      Bill Tozier
                      bill@...

                      "Devote each day to the object then in time, and every evening will
                      find something done."
                      -- Johann von Goethe
                    • alex@jguru.com
                      ... Totally OT from XP, BTW: That quote is actually mistaken: according to /., and Sony s FAQ, you need a sync on green monitor to install it, but
                      Message 10 of 12 , Feb 4, 2002
                        > >--- Bill Tozier <bill@w...> wrote:
                        > >> "Unlike Playstation2 games, Linux will not run on standard
                        > >televisions."
                        > >> -- from an Ananova story, 2002
                        >
                        > The quote was from an article discussing the very real (and immanent)
                        > release of Linux FOR Playstation2, by the way. Truth is stranger than
                        > we can imagine, more times than not....

                        Totally OT from XP, BTW:

                        That quote is actually mistaken: according to /., and Sony's FAQ, you
                        need a "sync on green" monitor to install it, but afterwards, it will
                        run just fine using a standard TV as a monitor. You could also buy a
                        sync-on-green-to-VGA converter for ~$100 (if you can find one).


                        --
                        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/
                      Your message has been successfully submitted and would be delivered to recipients shortly.