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 Weird and The Wonderful
  4. I wonder!!!!

I wonder!!!!

Scheduled Pinned Locked Moved The Weird and The Wonderful
questioncsharpdotnet
20 Posts 8 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.
  • P PIEBALDconsult

    Thomas Weller wrote:

    - It forces the developer to be explicit about what he's doing - always a good thing. - Types with identical names can occur in more than one namespace. With using you can distinguish them properly. (Take for example System.Windows.Forms.Timer vs. System.Threading.Timer...).

    I think you have that backward.

    T Offline
    T Offline
    Thomas Weller 0
    wrote on last edited by
    #11

    I'm afraid I don't get what you mean... :~ Regards Thomas

    _Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.

    Programmer - an organism that turns coffee into software._

    P 1 Reply Last reply
    0
    • T Thomas Weller 0

      AhsanS wrote:

      I didn't pasted it twice, it was like that in a file.

      Then indeed it's complete nonsense. Does it compile?

      _Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.

      Programmer - an organism that turns coffee into software._

      A Offline
      A Offline
      AhsanS
      wrote on last edited by
      #12

      Yes it compiles and where the reference is used it is used as using abc.abc it is working perfectly fine and perhaps for these sorts of issue, i am looking into each file again.

      Ahsan Ullah Senior Software Engineer

      T 1 Reply Last reply
      0
      • A AhsanS

        Yes it compiles and where the reference is used it is used as using abc.abc it is working perfectly fine and perhaps for these sorts of issue, i am looking into each file again.

        Ahsan Ullah Senior Software Engineer

        T Offline
        T Offline
        Thomas Weller 0
        wrote on last edited by
        #13

        AhsanS wrote:

        where the reference is used it is used as using abc.abc

        So the author of this piece of code accidentally created a nested namespace... This is syntactically correct and being allowed to do so makes perfect sense - generally. Of course it makes no sense at all to do it that way - I bet this is a CPD (CPD = copy paste desaster :) ). Regards Thomas

        _Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.

        Programmer - an organism that turns coffee into software._

        A 1 Reply Last reply
        0
        • T Thomas Weller 0

          I'm afraid I don't get what you mean... :~ Regards Thomas

          _Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.

          Programmer - an organism that turns coffee into software._

          P Offline
          P Offline
          PIEBALDconsult
          wrote on last edited by
          #14

          Using fully-specified names do what you say; not the using directive.

          T 1 Reply Last reply
          0
          • P PIEBALDconsult

            Using fully-specified names do what you say; not the using directive.

            T Offline
            T Offline
            Thomas Weller 0
            wrote on last edited by
            #15

            PIEBALDconsult wrote:

            Using fully-specified names do what you say; not the using directive.

            There is absolutely no difference (in terms of syntactical functionality) between the two alternatives. The first is totally equivalent to the second. :^) The only difference is that with fully qualified type names you will end up with horrible long lines of code that say nothing more than if the programmer had used a using statement. - You will produce code that tends to become unreadable and your keyboard will soon give up... Regards Thomas

            _Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.

            Programmer - an organism that turns coffee into software._

            1 Reply Last reply
            0
            • T Thomas Weller 0

              AhsanS wrote:

              where the reference is used it is used as using abc.abc

              So the author of this piece of code accidentally created a nested namespace... This is syntactically correct and being allowed to do so makes perfect sense - generally. Of course it makes no sense at all to do it that way - I bet this is a CPD (CPD = copy paste desaster :) ). Regards Thomas

              _Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.

              Programmer - an organism that turns coffee into software._

              A Offline
              A Offline
              AhsanS
              wrote on last edited by
              #16

              it might be CPD, but he must have known the issue when using "using abc.abc"????

              Ahsan Ullah Senior Software Engineer

              T 1 Reply Last reply
              0
              • A AhsanS

                it might be CPD, but he must have known the issue when using "using abc.abc"????

                Ahsan Ullah Senior Software Engineer

                T Offline
                T Offline
                Thomas Weller 0
                wrote on last edited by
                #17

                AhsanS wrote:

                he must have known the issue

                Maybe, maybe not. There are some tools/functionalities out there that generate those using statements automatically for you (e.g. VS 2008 and Resharper can do that). And pressing Ctrl+Enter when Intellisense offers you something slightly strange but working (like the second abc after the first) is also simpler than thinking about the code. So chances are he was just lazy. Just taking something that reliably works without really understanding why... :suss: Regards Thomas

                _Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.

                Programmer - an organism that turns coffee into software._

                1 Reply Last reply
                0
                • A AhsanS

                  I was just going through block of code for refactoring and found this. I wonder why is this even allowed in .net framework? What is benefit of it after all?

                  using System;
                  using System.Collections.Generic;
                  using System.Text;
                  using System.Timers;

                  namespace abc{
                  using System;
                  using System.Collections.Generic;
                  using System.Text;
                  using System.Timers;

                  namespace abc{

                  Ahsan Ullah Senior Software Engineer

                  C Offline
                  C Offline
                  cliran
                  wrote on last edited by
                  #18

                  I think it's pretty obvious. It's just that the good fellas down at Redmond decided to allow this so we could enjoy some hilarious coding horror posts

                  1 Reply Last reply
                  0
                  • A AhsanS

                    I was just going through block of code for refactoring and found this. I wonder why is this even allowed in .net framework? What is benefit of it after all?

                    using System;
                    using System.Collections.Generic;
                    using System.Text;
                    using System.Timers;

                    namespace abc{
                    using System;
                    using System.Collections.Generic;
                    using System.Text;
                    using System.Timers;

                    namespace abc{

                    Ahsan Ullah Senior Software Engineer

                    N Offline
                    N Offline
                    notmasteryet
                    wrote on last edited by
                    #19

                    Try to compile following without first or second using:

                    using System; // 1

                    namespace MyCode.Console
                    {
                    using System; // 2

                    class Program
                    {
                        static void Main(string\[\] args)
                        {
                            Console.WriteLine("Test");
                        }
                    }
                    

                    }

                    1 Reply Last reply
                    0
                    • T Thomas Weller 0

                      AhsanS wrote:

                      namespace abc{

                      Is this really twice in the source or is it just a copy/paste mistake? If so, this code should not compile. If not: using statements can occur in one of two places: - Above namespace declaration - Inside namespace declaration, but outside any other element This combined with the fact that duplicating a using directive is only treated as a warning not as an error, your code will compile - even if it's quite horrible indeed.

                      AhsanS wrote:

                      What is benefit of it after all?

                      - It forces the developer to be explicit about what he's doing - always a good thing. - Types with identical names can occur in more than one namespace. With using you can distinguish them properly. (Take for example System.Windows.Forms.Timer vs. System.Threading.Timer...). Regards Thomas

                      _Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.

                      Programmer - an organism that turns coffee into software._

                      modified on Thursday, November 6, 2008 12:30 PM

                      M Offline
                      M Offline
                      Megidolaon
                      wrote on last edited by
                      #20

                      Actually this doesn't force the developer to do anythin, on the contrary. It allows to use simple class names instead of full class names. If you hvae a name that can refer to more thsn 1 class, you get a compiler error and forced to use the full name, regardless of usings. But usings that are not use at the beginning of the file but at the beginning of a namespace sounds like more like an accident than anythign else.

                      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