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. Other Discussions
  3. The Back Room
  4. WTF (.NET?)

WTF (.NET?)

Scheduled Pinned Locked Moved The Back Room
c++questioncsharp
20 Posts 11 Posters 2 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.
  • B bob16972

    I'm fine with single scope operators like a::foo(); MSXML2::IXMLDOMNodePtr pNode=NULL; MSXML2::IXMLDOMNodeListPtr pNodeList=NULL; I guess my issue is with how deep this .NET stuff gets in terms of levels in... System.Windows.Forms.DialogResult.OK Thats just excessive and overkill. The "DialogResult.OK" is potentially defined elsewhere making it an ambiguous symbol potentially in larger apps. "Using" the namespace is not really a good all around solution except in the classroom.

    -- modified at 14:18 Saturday 22nd July, 2006

    R Offline
    R Offline
    Robert Rohde
    wrote on last edited by
    #9

    bob16972 wrote:

    The "OK" is potentially defined elsewhere making it an ambiguous symbol potentially in larger apps.

    Even when using the using statement you will have to write DialogResult.OK not only OK. Thus the chance of an ambiguouty is rather small. Robert

    B 1 Reply Last reply
    0
    • R Robert Rohde

      bob16972 wrote:

      The "OK" is potentially defined elsewhere making it an ambiguous symbol potentially in larger apps.

      Even when using the using statement you will have to write DialogResult.OK not only OK. Thus the chance of an ambiguouty is rather small. Robert

      B Offline
      B Offline
      bob16972
      wrote on last edited by
      #10

      I had already changed that once, but apparently my "modify" did not stick. I saw a comment like yours coming right after I originally posted it so I thought Id modify it but technology apparently failed me. I went ahead and re-clarified it. The "DialogResult.OK" could potentially be valid in other namespaces so my statement should bear some weight. For what it's worth...

      J 1 Reply Last reply
      0
      • B bob16972

        I had already changed that once, but apparently my "modify" did not stick. I saw a comment like yours coming right after I originally posted it so I thought Id modify it but technology apparently failed me. I went ahead and re-clarified it. The "DialogResult.OK" could potentially be valid in other namespaces so my statement should bear some weight. For what it's worth...

        J Offline
        J Offline
        J Dunlap
        wrote on last edited by
        #11

        Unlikely - but in the case that there is a clash you can rename one of them locally:

        using WFDialogResult = System.Windows.Forms.DialogResult;

        1 Reply Last reply
        0
        • B bob16972

          I was just casually strolling through VB'land and came across a question that had a snippet with this in it... If Result = System.Windows.Forms.DialogResult.OK Then I'm not a .NET person so forgive my inexperienced eyes, but are they really serious? That's quite long winded for something so trivial and probably common place. It makes me embrace my simple native loving VC++ 6.0 even tighter. This is a sad world indeed if that's progress. We are just asking for a repetitive motion injury with coding like that!

          C Offline
          C Offline
          Christian Graus
          wrote on last edited by
          #12

          The bit I don't get is why they have to store the result. The preceding line is almost certainly Dim Result as System.Windows.Forms.DialogResult = myForm.ShowDialog() Given that System.Windows.Forms is scope automatically anyhow, the code should look like this: if myForms.ShowDialog = DialogResult.OK Then

          Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog

          J 1 Reply Last reply
          0
          • C Christian Graus

            The bit I don't get is why they have to store the result. The preceding line is almost certainly Dim Result as System.Windows.Forms.DialogResult = myForm.ShowDialog() Given that System.Windows.Forms is scope automatically anyhow, the code should look like this: if myForms.ShowDialog = DialogResult.OK Then

            Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog

            J Offline
            J Offline
            Jorgen Sigvardsson
            wrote on last edited by
            #13

            Christian Graus wrote:

            Given that System.Windows.Forms is scope automatically anyhow, the code should look like this: if myForms.ShowDialog = DialogResult.OK Then

            Automatic due to a Koenig-like lookup, or because the wizard has injected a using System.Windows.Forms line somewhere in the file? If the former, then :cool:

            -- From the Makers of Futurama

            C N 2 Replies Last reply
            0
            • J Jorgen Sigvardsson

              Christian Graus wrote:

              Given that System.Windows.Forms is scope automatically anyhow, the code should look like this: if myForms.ShowDialog = DialogResult.OK Then

              Automatic due to a Koenig-like lookup, or because the wizard has injected a using System.Windows.Forms line somewhere in the file? If the former, then :cool:

              -- From the Makers of Futurama

              C Offline
              C Offline
              Christian Graus
              wrote on last edited by
              #14

              Latter, I am afraid. In C#, you also can't put a using statement for a single object in a namespace, AFAIK you can't do the equivelant of using std::cout;

              Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog

              1 Reply Last reply
              0
              • B bob16972

                "using" directives can cause name clashing, can they not?

                -- modified at 12:33 Saturday 22nd July, 2006 How exactly is someone reading the code supposed to know which namespace something is from? If you have 25 "using" statements, they are going to have a hard time tracking down which class to look up in MSDN to understand it's usage later on when somebody else is maintaining your code. Am I missing something?

                A Offline
                A Offline
                Alvaro Mendez
                wrote on last edited by
                #15

                bob16972 wrote:

                "using" directives can cause name clashing, can they not?

                Yes, but it's rare. The convenience of not having to always fully qualify type names far outweighs the possibility of name collisions. If a collision occurs, the compiler will let you know.

                bob16972 wrote:

                How exactly is someone reading the code supposed to know which namespace something is from? If you have 25 "using" statements, they are going to have a hard time tracking down which class to look up in MSDN to understand it's usage later on when somebody else is maintaining your code. Am I missing something?

                Yes: 1. The Visual Studio IDE is happy to show you a tool tip with the fully qualified name of the class when you hover over it. 2. Visual Studio is smart enough to bring up the proper help page for a class, even when it's not fully qualified. Regards, Alvaro


                The bible was written when people were even more stupid than they are today. Can you imagine that? - David Cross

                B 1 Reply Last reply
                0
                • A Alvaro Mendez

                  bob16972 wrote:

                  "using" directives can cause name clashing, can they not?

                  Yes, but it's rare. The convenience of not having to always fully qualify type names far outweighs the possibility of name collisions. If a collision occurs, the compiler will let you know.

                  bob16972 wrote:

                  How exactly is someone reading the code supposed to know which namespace something is from? If you have 25 "using" statements, they are going to have a hard time tracking down which class to look up in MSDN to understand it's usage later on when somebody else is maintaining your code. Am I missing something?

                  Yes: 1. The Visual Studio IDE is happy to show you a tool tip with the fully qualified name of the class when you hover over it. 2. Visual Studio is smart enough to bring up the proper help page for a class, even when it's not fully qualified. Regards, Alvaro


                  The bible was written when people were even more stupid than they are today. Can you imagine that? - David Cross

                  B Offline
                  B Offline
                  bob16972
                  wrote on last edited by
                  #16

                  Thanks for the info! I guess I never really noticed all the potential information from hovering. Most of the time it's redundant to what's on the code page so I'm guessing I got used to blanking it out and ignoring it.

                  1 Reply Last reply
                  0
                  • J Jorgen Sigvardsson

                    Christian Graus wrote:

                    Given that System.Windows.Forms is scope automatically anyhow, the code should look like this: if myForms.ShowDialog = DialogResult.OK Then

                    Automatic due to a Koenig-like lookup, or because the wizard has injected a using System.Windows.Forms line somewhere in the file? If the former, then :cool:

                    -- From the Makers of Futurama

                    N Offline
                    N Offline
                    Nemanja Trifunovic
                    wrote on last edited by
                    #17

                    Jörgen Sigvardsson wrote:

                    Automatic due to a Koenig-like lookup

                    :-D You give them way too much credit, my friend.


                    My programming blahblahblah blog. If you ever find anything useful here, please let me know to remove it.

                    1 Reply Last reply
                    0
                    • P peterchen

                      As far as house rule goes "Using namespace" in a header is off limits, but not in a cpp


                      Some of us walk the memory lane, others plummet into a rabbit hole
                      Tree in C# || Fold With Us! || sighist

                      I Offline
                      I Offline
                      Igor Sukhov
                      wrote on last edited by
                      #18

                      Thanks to the .NET we don't have to care about headers and source files, compilation and linking anymore. Does anybody know Microsoft plans for WTF (like Windows Transofrmation Foundation) abbreviation ?

                      Best regards, ----------- Igor Sukhovhttp://sukhov.net

                      P 1 Reply Last reply
                      0
                      • I Igor Sukhov

                        Thanks to the .NET we don't have to care about headers and source files, compilation and linking anymore. Does anybody know Microsoft plans for WTF (like Windows Transofrmation Foundation) abbreviation ?

                        Best regards, ----------- Igor Sukhovhttp://sukhov.net

                        P Offline
                        P Offline
                        peterchen
                        wrote on last edited by
                        #19

                        Thank god! using namespace "feels" ok in e.g. C# since it has a well defined scope. using namespace in a C++ header, otoh, is recipe for header-sorting disaster. The C++ compilation model is IMO the worst legacy about the language, and it would still be fixable.


                        Some of us walk the memory lane, others plummet into a rabbit hole
                        Tree in C# || Fold With Us! || sighist

                        1 Reply Last reply
                        0
                        • B bob16972

                          I was just casually strolling through VB'land and came across a question that had a snippet with this in it... If Result = System.Windows.Forms.DialogResult.OK Then I'm not a .NET person so forgive my inexperienced eyes, but are they really serious? That's quite long winded for something so trivial and probably common place. It makes me embrace my simple native loving VC++ 6.0 even tighter. This is a sad world indeed if that's progress. We are just asking for a repetitive motion injury with coding like that!

                          L Offline
                          L Offline
                          Lost User
                          wrote on last edited by
                          #20

                          Its the same in C++, if you use namespaceing. What is bizarre is that OK, an oft used constant, should be buried so deep. I suppose it is consistent, but where would you put 'TRUE' and 'FALSE'? How about, System.Logic.Boolean.Dualisim.Values.TRUE. Or should that be System.Logic.Dualism.Boolean.Values.TRUE. Kind of makes you wonder where you fit 'mu' logic but there you go.

                          Tronché pas ma miche!

                          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