factory methods.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Aman

    factory methods.

    why should factory methods be virtual in C++ ?
    what would be the impact if they were not ?


    --
    Posted via Mailgate.ORG Server - http://www.Mailgate.ORG
  • Gianni Mariani

    #2
    Re: factory methods.

    Aman wrote:[color=blue]
    > why should factory methods be virtual in C++ ?
    > what would be the impact if they were not ?[/color]

    Why do you think you need a factory ?

    Factories are usually used when you want to separate the implementation
    from the interface.

    Can you fill in the dots from there ?



    Comment

    • jeffc

      #3
      Re: factory methods.


      "Aman " <aman@techie.co m> wrote in message
      news:881dcb270e 2dc67e03b01625e 41cacd8.26421@m ygate.mailgate. org...[color=blue]
      > why should factory methods be virtual in C++ ?[/color]

      So the correct subclass of object is created.
      [color=blue]
      > what would be the impact if they were not ?[/color]

      The correct subclass of object might not be created.


      Comment

      • Chris Theis

        #4
        Re: factory methods.


        "Aman " <aman@techie.co m> wrote in message
        news:881dcb270e 2dc67e03b01625e 41cacd8.26421@m ygate.mailgate. org...[color=blue]
        > why should factory methods be virtual in C++ ?[/color]

        Because a factory should be able to create different types of objects.
        Probably you should think about the reason of using a factory once again.
        [color=blue]
        > what would be the impact if they were not ?
        >[/color]
        You'd have some more worries in your life....

        Chris


        Comment

        • jeffc

          #5
          Re: factory methods.


          "Chris Theis" <Christian.Thei s@nospam.cern.c h> wrote in message
          news:bjqd9q$jh6 $1@sunnews.cern .ch...[color=blue]
          >
          > "Aman " <aman@techie.co m> wrote in message
          > news:881dcb270e 2dc67e03b01625e 41cacd8.26421@m ygate.mailgate. org...[color=green]
          > > why should factory methods be virtual in C++ ?[/color]
          >
          > Because a factory should be able to create different types of objects.
          > Probably you should think about the reason of using a factory once again.
          >[color=green]
          > > what would be the impact if they were not ?
          > >[/color]
          > You'd have some more worries in your life....[/color]

          I'm starting to think this was a homework question, verbatim.


          Comment

          • Jason Spashett

            #6
            Re: factory methods.

            "Gianni Mariani" <gi2nospam@mari ani.ws> wrote in message
            news:bjq683$oig @dispatch.conce ntric.net...[color=blue]
            > Aman wrote:[color=green]
            > > why should factory methods be virtual in C++ ?
            > > what would be the impact if they were not ?[/color]
            >
            > Why do you think you need a factory ?
            >
            > Factories are usually used when you want to separate the implementation
            > from the interface.
            >
            > Can you fill in the dots from there ?
            >[/color]
            No, what about static factory methods? They can't be virtual.


            Comment

            • Aman Angrish

              #7
              Re: factory methods.

              heh heh,
              no it's not a homework question !! (i'm lucky i don't get homework ).
              just read this statement in Gamma (design patterns ) ,wanted to know
              why.
              Thanks for your inputs.
              regards,
              Aman.



              "jeffc" <nobody@nowhere .com> wrote in message
              news:3f60cb82_4 @news1.prserv.n et
              [color=blue]
              >
              > "Chris Theis" <Christian.Thei s@nospam.cern.c h> wrote in message
              > news:bjqd9q$jh6 $1@sunnews.cern .ch...[color=green]
              > >
              > > "Aman " <aman@techie.co m> wrote in message
              > > news:881dcb270e 2dc67e03b01625e 41cacd8.26421@m ygate.mailgate. org...[color=darkred]
              > > > why should factory methods be virtual in C++ ?[/color]
              > >
              > > Because a factory should be able to create different types of objects.
              > > Probably you should think about the reason of using a factory once again.
              > >[color=darkred]
              > > > what would be the impact if they were not ?
              > > >[/color]
              > > You'd have some more worries in your life....[/color]
              >
              > I'm starting to think this was a homework question, verbatim.[/color]




              --
              Posted via Mailgate.ORG Server - http://www.Mailgate.ORG

              Comment

              • Gianni Mariani

                #8
                Re: factory methods.

                Jason Spashett wrote:[color=blue]
                > "Gianni Mariani" <gi2nospam@mari ani.ws> wrote in message[/color]
                ....[color=blue][color=green]
                >>
                >>Can you fill in the dots from there ?
                >>[/color]
                >
                > No, what about static factory methods? They can't be virtual.[/color]

                What part of the fill-in-the-dots are you missing ?

                Comment

                Working...