Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Design and Architecture
  4. class XXX and class XXXImpl

class XXX and class XXXImpl

Scheduled Pinned Locked Moved Design and Architecture
question
16 Posts 7 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Shog9 0

    Scott Dorman wrote:

    there are other ways to handle this in .NET with the use of the partial keyword

    AFAIK, that really only lets you split class definitions across source files, somewhat akin to using macros or #includes in C++. The final, compiled type still contains everything. And since .NET doesn't use header files, you aren't really accomplishing anything by splitting up the source (well, you are, but nothing that matters to clients who shouldn't care about the source anyway). FWIW, Microsoft used the technique (usually by way of a public bare-bones type and a sealed, internal implementation) all over the place in the framework itself, often for no apparent reason (what, a MIME parser isn't generally useful?!). IMHO, it's a technique that should be used sparingly when at all.

    Citizen 20.1.01

    'The question is,' said Humpty Dumpty, 'which is to be master - that's all.'

    S Offline
    S Offline
    Scott Dorman
    wrote on last edited by
    #7

    You are correct, you can only split the definition up across source files not compiled binaries. Microsoft did use that technique in a lot of places within the framework, probably a hold-over from older habits.

    Scott. —In just two days, tomorrow will be yesterday. —Hey, hey, hey. Don't be mean. We don't have to be mean because, remember, no matter where you go, there you are. - Buckaroo Banzai


    [Forum Guidelines] [Articles] [Blog]

    A 1 Reply Last reply
    0
    • P Pete OHanlon

      I would suspect that what you are looking at is a case of having an abstract base class and a concrete implementation class. This is one of the most over abused uses of OO you can find. Basically what happens here is somebody creates a base class for something that they are only going to do once and then creates a concrete implementation of it. For some reason, they think this is going to aid them in reuse.

      Deja View - the feeling that you've seen this post before.

      My blog | My articles

      S Offline
      S Offline
      Stephen Hewitt
      wrote on last edited by
      #8

      Pete O'Hanlon wrote:

      For some reason, they think this is going to aid them in reuse.

      Probably the reason for this is because it does.

      Steve

      A P 2 Replies Last reply
      0
      • S Stephen Hewitt

        Pete O'Hanlon wrote:

        For some reason, they think this is going to aid them in reuse.

        Probably the reason for this is because it does.

        Steve

        A Offline
        A Offline
        Ahmed Charfeddine
        wrote on last edited by
        #9

        thank you all for your precious interventions. indeed the recent example I found and which prompted me to post a question here was the MFC feature Pack. OK the source code is not written by Microsoft, but there was the new FrameWnd class along with another FrameImpl class, in separate files. the frame class holds an object of the Impl type,( and visversa I the Impl object holds a pointer to its corresponding Frame window object): at least for example you can notice the following : BOOL IsMenuBarAvailable () const { return m_Impl.GetMenuBar () != NULL; } this is a member function of the FrameWnd. not all members are encapsulated like this, and also some memebers are public visavis the consumer of the FrameWnd class.

        1 Reply Last reply
        0
        • S Scott Dorman

          You are correct, you can only split the definition up across source files not compiled binaries. Microsoft did use that technique in a lot of places within the framework, probably a hold-over from older habits.

          Scott. —In just two days, tomorrow will be yesterday. —Hey, hey, hey. Don't be mean. We don't have to be mean because, remember, no matter where you go, there you are. - Buckaroo Banzai


          [Forum Guidelines] [Articles] [Blog]

          A Offline
          A Offline
          Ahmed Charfeddine
          wrote on last edited by
          #10

          thank you all for your precious interventions. indeed the recent example I found and which prompted me to post a question here was the MFC feature Pack. OK the source code is not written by Microsoft, but there was the new FrameWnd class along with another FrameImpl class, in separate files. the frame class holds an object of the Impl type,( and visversa I the Impl object holds a pointer to its corresponding Frame window object): at least for example you can notice the following :

          BOOL IsMenuBarAvailable () const
          {
          return m_Impl.GetMenuBar () != NULL;
          }

          this is a member function of the FrameWnd. not all members are encapsulated like this, and also some memebers are public visavis the consumer of the FrameWnd class.

          1 Reply Last reply
          0
          • S Stephen Hewitt

            Pete O'Hanlon wrote:

            For some reason, they think this is going to aid them in reuse.

            Probably the reason for this is because it does.

            Steve

            P Offline
            P Offline
            Pete OHanlon
            wrote on last edited by
            #11

            Stephen Hewitt wrote:

            Probably the reason for this is because it does.

            You what? Why does separating a class out into an abstract and concrete implementation aid reuse? Read what I said and you'll find I'm talking about somebody splitting a class up into an abstract/concrete implementation where there is no need because it's never going to be reused. Sorry but there you go - reuse only applies if you have proper design.

            Deja View - the feeling that you've seen this post before.

            My blog | My articles

            L 1 Reply Last reply
            0
            • P Pete OHanlon

              Stephen Hewitt wrote:

              Probably the reason for this is because it does.

              You what? Why does separating a class out into an abstract and concrete implementation aid reuse? Read what I said and you'll find I'm talking about somebody splitting a class up into an abstract/concrete implementation where there is no need because it's never going to be reused. Sorry but there you go - reuse only applies if you have proper design.

              Deja View - the feeling that you've seen this post before.

              My blog | My articles

              L Offline
              L Offline
              led mike
              wrote on last edited by
              #12

              Pete O'Hanlon wrote:

              Read what I said and you'll find I'm talking about somebody splitting a class up into an abstract/concrete implementation where there is no need because it's never going to be reused. Sorry but there you go - reuse only applies if you have proper design.

              Yes but to be fair, you are making an assumption about the OP where there is no information suggesting this has occurred because, well there is no information at all about the project in the OP.

              led mike

              P 1 Reply Last reply
              0
              • L led mike

                Pete O'Hanlon wrote:

                Read what I said and you'll find I'm talking about somebody splitting a class up into an abstract/concrete implementation where there is no need because it's never going to be reused. Sorry but there you go - reuse only applies if you have proper design.

                Yes but to be fair, you are making an assumption about the OP where there is no information suggesting this has occurred because, well there is no information at all about the project in the OP.

                led mike

                P Offline
                P Offline
                Pete OHanlon
                wrote on last edited by
                #13

                led mike wrote:

                Yes but to be fair, you are making an assumption about the OP where there is no information suggesting this has occurred because, well there is no information at all about the project in the OP.

                Actually, I was making a generalisation. Let's not get our assumptions confused with our generalisations - that way madness lies.

                Deja View - the feeling that you've seen this post before.

                My blog | My articles

                L 1 Reply Last reply
                0
                • P Pete OHanlon

                  led mike wrote:

                  Yes but to be fair, you are making an assumption about the OP where there is no information suggesting this has occurred because, well there is no information at all about the project in the OP.

                  Actually, I was making a generalisation. Let's not get our assumptions confused with our generalisations - that way madness lies.

                  Deja View - the feeling that you've seen this post before.

                  My blog | My articles

                  L Offline
                  L Offline
                  led mike
                  wrote on last edited by
                  #14

                  Pete O'Hanlon wrote:

                  Actually, I was making a generalisation

                  I won't argue since trying to re-read it while looking for the distinction is making me dizzy :-D

                  Pete O'Hanlon wrote:

                  I would suspect that what you are looking at is a case of

                  led mike

                  1 Reply Last reply
                  0
                  • S Shog9 0

                    Scott Dorman wrote:

                    there are other ways to handle this in .NET with the use of the partial keyword

                    AFAIK, that really only lets you split class definitions across source files, somewhat akin to using macros or #includes in C++. The final, compiled type still contains everything. And since .NET doesn't use header files, you aren't really accomplishing anything by splitting up the source (well, you are, but nothing that matters to clients who shouldn't care about the source anyway). FWIW, Microsoft used the technique (usually by way of a public bare-bones type and a sealed, internal implementation) all over the place in the framework itself, often for no apparent reason (what, a MIME parser isn't generally useful?!). IMHO, it's a technique that should be used sparingly when at all.

                    Citizen 20.1.01

                    'The question is,' said Humpty Dumpty, 'which is to be master - that's all.'

                    M Offline
                    M Offline
                    Mark Churchill
                    wrote on last edited by
                    #15

                    MS does things like that a lot to avoid supporting them. A MIME parser would be useful - but the one they have may be crap. Better to not give your clients a MIME parser at all, if you suspect its quality might be a bit suspect.

                    Mark Churchill Director Dunn & Churchill Free Download:
                    Diamond Binding: The simple, powerful, reliable, and effective data layer toolkit for Visual Studio.

                    1 Reply Last reply
                    0
                    • P Pete OHanlon

                      I would suspect that what you are looking at is a case of having an abstract base class and a concrete implementation class. This is one of the most over abused uses of OO you can find. Basically what happens here is somebody creates a base class for something that they are only going to do once and then creates a concrete implementation of it. For some reason, they think this is going to aid them in reuse.

                      Deja View - the feeling that you've seen this post before.

                      My blog | My articles

                      M Offline
                      M Offline
                      Mark Churchill
                      wrote on last edited by
                      #16

                      Yep, its a sister pattern to the far too common Foo/IFoo pairing.

                      Mark Churchill Director Dunn & Churchill Free Download:
                      Diamond Binding: The simple, powerful, reliable, and effective data layer toolkit for Visual Studio.

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups