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. The Lounge
  3. Curse the .NET designers

Curse the .NET designers

Scheduled Pinned Locked Moved The Lounge
csharpc++
45 Posts 21 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.
  • J Offline
    J Offline
    Joe Woodbury
    wrote on last edited by
    #1

    I need to take a moment to publicly curse the .NET designers for not implementing the "friend" keyword in C# as it is in C++. For the third time in a week, the lack of this has prevented me from making what would be an elegant implementation of some classes.

    Anyone who thinks he has a better idea of what's good for people than people do is a swine. - P.J. O'Rourke

    W C P R L 17 Replies Last reply
    0
    • J Joe Woodbury

      I need to take a moment to publicly curse the .NET designers for not implementing the "friend" keyword in C# as it is in C++. For the third time in a week, the lack of this has prevented me from making what would be an elegant implementation of some classes.

      Anyone who thinks he has a better idea of what's good for people than people do is a swine. - P.J. O'Rourke

      W Offline
      W Offline
      wout de zeeuw
      wrote on last edited by
      #2

      Did you discover the InternalsVisibleTo attribute? It's not as fine grained (works on assembly level), but it does the job for me mostly.

      Wout

      J 1 Reply Last reply
      0
      • J Joe Woodbury

        I need to take a moment to publicly curse the .NET designers for not implementing the "friend" keyword in C# as it is in C++. For the third time in a week, the lack of this has prevented me from making what would be an elegant implementation of some classes.

        Anyone who thinks he has a better idea of what's good for people than people do is a swine. - P.J. O'Rourke

        C Offline
        C Offline
        Christopher Duncan
        wrote on last edited by
        #3

        Dude, you don't even want to get me started on the designers. Who's idea was it that you could only inherit from a class if the code lived in this magic little App_Code directory? Probably the same moron who decided that you couldn't put user controls with the UI separated from the code (i.e. ascx and ascx.cs) files in the App_Code directory. So, if you want to use a common base class for your pages (which must by definition live in the App_Code directory), and it wants to load user controls e.g. ControlOne c = (ControlOne)LoadControl("~/ControlOne.ascx"); then you won't successfully compile. Why? Because the code in the magic directory doesn't recognize ControlOne since it doesn't live in the magic directory, which, by definition, it can't. More Flying Dutchman logic. Lovely. Yeah. I want to meet the .NET designers. Really.

        Christopher Duncan Author of The Career Programmer and Unite the Tribes Coming soon: Got a career question? Ask the Attack Chihuahua! www.PracticalUSA.com

        R 1 Reply Last reply
        0
        • J Joe Woodbury

          I need to take a moment to publicly curse the .NET designers for not implementing the "friend" keyword in C# as it is in C++. For the third time in a week, the lack of this has prevented me from making what would be an elegant implementation of some classes.

          Anyone who thinks he has a better idea of what's good for people than people do is a swine. - P.J. O'Rourke

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

          But all .net code is friends with all other .net code. :confused: (It's that Java stuff it doesn't like.)

          1 Reply Last reply
          0
          • W wout de zeeuw

            Did you discover the InternalsVisibleTo attribute? It's not as fine grained (works on assembly level), but it does the job for me mostly.

            Wout

            J Offline
            J Offline
            Joe Woodbury
            wrote on last edited by
            #5

            I know all about that and it's completely inadequate. Who wants to create an assembly just for the classes that need it?

            Anyone who thinks he has a better idea of what's good for people than people do is a swine. - P.J. O'Rourke

            W 1 Reply Last reply
            0
            • C Christopher Duncan

              Dude, you don't even want to get me started on the designers. Who's idea was it that you could only inherit from a class if the code lived in this magic little App_Code directory? Probably the same moron who decided that you couldn't put user controls with the UI separated from the code (i.e. ascx and ascx.cs) files in the App_Code directory. So, if you want to use a common base class for your pages (which must by definition live in the App_Code directory), and it wants to load user controls e.g. ControlOne c = (ControlOne)LoadControl("~/ControlOne.ascx"); then you won't successfully compile. Why? Because the code in the magic directory doesn't recognize ControlOne since it doesn't live in the magic directory, which, by definition, it can't. More Flying Dutchman logic. Lovely. Yeah. I want to meet the .NET designers. Really.

              Christopher Duncan Author of The Career Programmer and Unite the Tribes Coming soon: Got a career question? Ask the Attack Chihuahua! www.PracticalUSA.com

              R Offline
              R Offline
              Rocky Moore
              wrote on last edited by
              #6

              Actually, you could use the "web application projects" to structure the site in the older method. Now with VS2008, you have a Web Application (old method with Codebehind files) or "Website"s which offer the new method. I prefer the older method as the site is precompiled and source is not required at the site.

              Rocky <>< Blog Post: Handy utility app that is always on my machines! Tech Blog Post: Microsoft Live Writer Plug-ins!

              F C 2 Replies Last reply
              0
              • J Joe Woodbury

                I need to take a moment to publicly curse the .NET designers for not implementing the "friend" keyword in C# as it is in C++. For the third time in a week, the lack of this has prevented me from making what would be an elegant implementation of some classes.

                Anyone who thinks he has a better idea of what's good for people than people do is a swine. - P.J. O'Rourke

                R Offline
                R Offline
                Rocky Moore
                wrote on last edited by
                #7

                About the only thing I miss from c/c++ was the mutliple base classes. That was handy at times.

                Rocky <>< Blog Post: Handy utility app that is always on my machines! Tech Blog Post: Microsoft Live Writer Plug-ins!

                S T 2 Replies Last reply
                0
                • R Rocky Moore

                  About the only thing I miss from c/c++ was the mutliple base classes. That was handy at times.

                  Rocky <>< Blog Post: Handy utility app that is always on my machines! Tech Blog Post: Microsoft Live Writer Plug-ins!

                  S Offline
                  S Offline
                  smindlos
                  wrote on last edited by
                  #8

                  Multiple inheritance (in C++) sure was handy but equally evil. Interfaces/abstracts would be the way to go.

                  M J 2 Replies Last reply
                  0
                  • S smindlos

                    Multiple inheritance (in C++) sure was handy but equally evil. Interfaces/abstracts would be the way to go.

                    M Offline
                    M Offline
                    ManicQin
                    wrote on last edited by
                    #9

                    Bow down to my Awesome power! Ha Ha Ha puny .Net programmers! The most funny thing is that in every c++ forum you'll read people ranting about how friendships are the worst thing that was introduced to Object Oriented... But once they leave old c they start missing it... "Don't it always seem to go That you don't know what you got till it's gone They paved paradise and put up a parking lot"

                    1 Reply Last reply
                    0
                    • J Joe Woodbury

                      I need to take a moment to publicly curse the .NET designers for not implementing the "friend" keyword in C# as it is in C++. For the third time in a week, the lack of this has prevented me from making what would be an elegant implementation of some classes.

                      Anyone who thinks he has a better idea of what's good for people than people do is a swine. - P.J. O'Rourke

                      L Offline
                      L Offline
                      lainon
                      wrote on last edited by
                      #10

                      And the internal keyword...? Very useful, truly... You must try it before... :(

                      J 1 Reply Last reply
                      0
                      • J Joe Woodbury

                        I need to take a moment to publicly curse the .NET designers for not implementing the "friend" keyword in C# as it is in C++. For the third time in a week, the lack of this has prevented me from making what would be an elegant implementation of some classes.

                        Anyone who thinks he has a better idea of what's good for people than people do is a swine. - P.J. O'Rourke

                        J Offline
                        J Offline
                        John Eldridge
                        wrote on last edited by
                        #11

                        The c# equivalent of friend is internal. Even VB uses the Friend keyword!

                        1 Reply Last reply
                        0
                        • J Joe Woodbury

                          I know all about that and it's completely inadequate. Who wants to create an assembly just for the classes that need it?

                          Anyone who thinks he has a better idea of what's good for people than people do is a swine. - P.J. O'Rourke

                          W Offline
                          W Offline
                          wout de zeeuw
                          wrote on last edited by
                          #12

                          That's not what the attribute encourages, it just allows assembly B to access assembly A's internal types/members, but the internal keyword works just as fine within the assembly itself. The internal keyword is a bit coarse, but at least it gives you the option of sharing your internals with others.

                          Wout

                          1 Reply Last reply
                          0
                          • J Joe Woodbury

                            I need to take a moment to publicly curse the .NET designers for not implementing the "friend" keyword in C# as it is in C++. For the third time in a week, the lack of this has prevented me from making what would be an elegant implementation of some classes.

                            Anyone who thinks he has a better idea of what's good for people than people do is a swine. - P.J. O'Rourke

                            G Offline
                            G Offline
                            Grimolfr
                            wrote on last edited by
                            #13

                            Can't you simulate it using reflection?

                            Grim MCDBA, MCSD, MCP+SB SELECT * FROM users WHERE clue IS NOT NULL (0 row(s) affected)

                            1 Reply Last reply
                            0
                            • R Rocky Moore

                              Actually, you could use the "web application projects" to structure the site in the older method. Now with VS2008, you have a Web Application (old method with Codebehind files) or "Website"s which offer the new method. I prefer the older method as the site is precompiled and source is not required at the site.

                              Rocky <>< Blog Post: Handy utility app that is always on my machines! Tech Blog Post: Microsoft Live Writer Plug-ins!

                              F Offline
                              F Offline
                              fletchsod
                              wrote on last edited by
                              #14

                              > I prefer the older method as the site is precompiled and source is not required at the site. I prefer the latter. It's a lot faster in updating a website. Nobody want to change the code, recompile the website and wait for the web browser to appear then login to get to the webpage you're trying to work on. Most of the time, I can update the code on the fly and just refresh the web browser instead of going through the whole process. Beside the IIS web server won't make this App_Code visible to the web browser. This come in handy when the website get bigger and bigger.

                              R 1 Reply Last reply
                              0
                              • J Joe Woodbury

                                I need to take a moment to publicly curse the .NET designers for not implementing the "friend" keyword in C# as it is in C++. For the third time in a week, the lack of this has prevented me from making what would be an elegant implementation of some classes.

                                Anyone who thinks he has a better idea of what's good for people than people do is a swine. - P.J. O'Rourke

                                D Offline
                                D Offline
                                Dave Buhl
                                wrote on last edited by
                                #15

                                As you seem to have discovered, C# is NOT C++. C# uses different paradigms to achieve the same goals. Trying to apply C++ concepts to C# is like trying to mix French words and sentence structure into a Spanish conversation. Even those who know both languages will be confused and frustrated. If you really feel the need to program with C++ put it in a library and call if from C#, that is the beauty of our multiple languages. If done appropriately, we all really can get along.

                                J 1 Reply Last reply
                                0
                                • L lainon

                                  And the internal keyword...? Very useful, truly... You must try it before... :(

                                  J Offline
                                  J Offline
                                  Joe Woodbury
                                  wrote on last edited by
                                  #16

                                  The internal keyword is lame. It hides things from external non-friend assemblies. It does absolutely no good for classes within an assembly. The result is to force code to be ugly and to not use data and method hiding.

                                  Anyone who thinks he has a better idea of what's good for people than people do is a swine. - P.J. O'Rourke

                                  1 Reply Last reply
                                  0
                                  • S smindlos

                                    Multiple inheritance (in C++) sure was handy but equally evil. Interfaces/abstracts would be the way to go.

                                    J Offline
                                    J Offline
                                    Joe Woodbury
                                    wrote on last edited by
                                    #17

                                    smindlos wrote:

                                    Interfaces/abstracts would be the way to go.

                                    Interfaces are okay, but ultimately way too underpowered to be fully effective. Even worse, a class using an interface MUST implement all the items in the interface. This either means lots of pain with a large interface or intentionally writing the interface to be small and marginally useful. It's a hack.

                                    Anyone who thinks he has a better idea of what's good for people than people do is a swine. - P.J. O'Rourke

                                    1 Reply Last reply
                                    0
                                    • D Dave Buhl

                                      As you seem to have discovered, C# is NOT C++. C# uses different paradigms to achieve the same goals. Trying to apply C++ concepts to C# is like trying to mix French words and sentence structure into a Spanish conversation. Even those who know both languages will be confused and frustrated. If you really feel the need to program with C++ put it in a library and call if from C#, that is the beauty of our multiple languages. If done appropriately, we all really can get along.

                                      J Offline
                                      J Offline
                                      Joe Woodbury
                                      wrote on last edited by
                                      #18

                                      Dave Buhl wrote:

                                      As you seem to have discovered, C# is NOT C++.

                                      I discovered that five years ago. I also discovered that the .NET designers were lazy asses who eliminated valid OO concepts in C# for no good reason. (They also forgot to implement many useful things in Win32. .NET 2.0 went a long way to fixing this, but I'm still astonished how how much interop I have to do. The problem is that too many of the .NET designers never did application development--seriously, one key designer was hired straight out of college and had never designed classes let alone an application of any significance. This lack of real-world experience really shows.)

                                      Anyone who thinks he has a better idea of what's good for people than people do is a swine. - P.J. O'Rourke

                                      D 1 Reply Last reply
                                      0
                                      • R Rocky Moore

                                        Actually, you could use the "web application projects" to structure the site in the older method. Now with VS2008, you have a Web Application (old method with Codebehind files) or "Website"s which offer the new method. I prefer the older method as the site is precompiled and source is not required at the site.

                                        Rocky <>< Blog Post: Handy utility app that is always on my machines! Tech Blog Post: Microsoft Live Writer Plug-ins!

                                        C Offline
                                        C Offline
                                        Christopher Duncan
                                        wrote on last edited by
                                        #19

                                        Do you have a notion as to how much hassle it is to move an existing project to the older method? I, too, prefer the precompiled approach. I know you can still precompile with 2.0, but it changes the assembly name each time, and if you want to use fixed names it spits out a different dll for each page. Yuck.

                                        Christopher Duncan Author of The Career Programmer and Unite the Tribes Coming soon: Got a career question? Ask the Attack Chihuahua! www.PracticalUSA.com

                                        R 1 Reply Last reply
                                        0
                                        • J Joe Woodbury

                                          I need to take a moment to publicly curse the .NET designers for not implementing the "friend" keyword in C# as it is in C++. For the third time in a week, the lack of this has prevented me from making what would be an elegant implementation of some classes.

                                          Anyone who thinks he has a better idea of what's good for people than people do is a swine. - P.J. O'Rourke

                                          S Offline
                                          S Offline
                                          Syed Muhammad Fahad
                                          wrote on last edited by
                                          #20

                                          I too missed this keyword alot

                                          Syed Muhammad Fahad Application Development Tyler Technologies -- TEMS Division mfahad@mazikusa.com

                                          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