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. Commenting and Style Differences... [modified - added a final thought]

Commenting and Style Differences... [modified - added a final thought]

Scheduled Pinned Locked Moved The Lounge
csharpc++csscomtools
23 Posts 15 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 James R Twine

    So - as I delve into more and more C# code, I am noticing something.  When reading C++ code, I tended to see that the code tends to be wrapped nicely, broken up into smaller functions, and does not extend too far to the right.    However, much of the C# code that I am seeing tends to runs onto the right more often than not, requiring scrolling back and forth just to grok a single line (and I run my monitors at a pretty healthy resolution).  Perhaps, some of this can be partially attributed to the longer names of the classes/objects included in the framework (e.g. AssemblyInformationalVersionAttribute, IDictionaryEnumerator, DataColumnMappingCollection), how things like enums are referenced (e.g. FileShare.ReadWrite), and how certain constructs are written (e.g. foreach( ... ), using( ... ))    Even the autogenerated code is much different - when I had an IDL file generated, or generated an empty interface implementation from one, I rarely got really long lines.  With C#/.NET, I have seen autogenerated code extend beyond 400(!) characters!

    [System.Web.Services.Protocols.SoapDocumentMethodAttribute
    ("http://www.domain.com/schemas/App/1.0/MyWebService/ReserveActions",
    RequestNamespace="http://www.domain.com/schemas/App/1.0/MyWebService/",
    ResponseNamespace="http://www.domain.com/schemas/App/1.0/MyWebService/",
    Use=System.Web.Services.Description.SoapBindingUse.Literal,
    ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]

    (Line manually wrapped and some things changed above to protect certain information.)    I cannot help but wonder that when a developer's tools generate code like this, do the developers take that as examples of how it should be done?    Commenting is also different - I am seeing much less of it in C# code than in C/C++ code than I used to see.    Am I just seeing too many poor examples in one place, or is this really a trend that other former C/C++1 developers are seeing?  Or is this just a form of "developer evolution?"    Anyway...    Peace! 1 This in relevant - developers that only have done C# have little to compare to. Edit: Thank God for things like auto-completion, otherwise all those rapid development claims would be offset by the amount of time it took to

    P Offline
    P Offline
    phannon86
    wrote on last edited by
    #3

    My only work experience is with C#, ASP.NET and minimal MFC, but I noticed this too during my time at uni, my C++ tutor was insistent everything was clearly commented/structured/indented to the point he awarded/deducted high percentages of marks for this alone. Whereas say, my Java tutor and C# tutor didn't seem too hung up on it and were more convinced that well written code is self commenting. This put the students in an awkward position, but I feel it was beneficial in a way because we had both of these importances beaten into us. One isn't necessarily more important than the other and well written code comes from a combination of these things.

    He who makes a beast out of himself gets rid of the pain of being a man

    1 Reply Last reply
    0
    • C Chris Maunder

      Long lines: We have a policy in-house of wrapping lines at column 100. Part of the art of software development is naming variables and classes and it's a shame that this seems to have been thrown to the wind. Comments: It could be that C# is more approachable that C++ so we're seeing developers with less experience coming to the fore. Or it could be that C# encourages code that is so well structured that it doesn't need comments. Or it could be all those ex-VB6 developers we're hearing about... :P

      cheers, Chris Maunder

      CodeProject.com : C++ MVP

      O Offline
      O Offline
      Oakman
      wrote on last edited by
      #4

      Chris Maunder wrote:

      Or it could be that C# encourages code that is so well structured that it doesn't need comments

      ROFL

      Jon Smith & Wesson: The original point and click interface

      G 1 Reply Last reply
      0
      • J James R Twine

        So - as I delve into more and more C# code, I am noticing something.  When reading C++ code, I tended to see that the code tends to be wrapped nicely, broken up into smaller functions, and does not extend too far to the right.    However, much of the C# code that I am seeing tends to runs onto the right more often than not, requiring scrolling back and forth just to grok a single line (and I run my monitors at a pretty healthy resolution).  Perhaps, some of this can be partially attributed to the longer names of the classes/objects included in the framework (e.g. AssemblyInformationalVersionAttribute, IDictionaryEnumerator, DataColumnMappingCollection), how things like enums are referenced (e.g. FileShare.ReadWrite), and how certain constructs are written (e.g. foreach( ... ), using( ... ))    Even the autogenerated code is much different - when I had an IDL file generated, or generated an empty interface implementation from one, I rarely got really long lines.  With C#/.NET, I have seen autogenerated code extend beyond 400(!) characters!

        [System.Web.Services.Protocols.SoapDocumentMethodAttribute
        ("http://www.domain.com/schemas/App/1.0/MyWebService/ReserveActions",
        RequestNamespace="http://www.domain.com/schemas/App/1.0/MyWebService/",
        ResponseNamespace="http://www.domain.com/schemas/App/1.0/MyWebService/",
        Use=System.Web.Services.Description.SoapBindingUse.Literal,
        ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]

        (Line manually wrapped and some things changed above to protect certain information.)    I cannot help but wonder that when a developer's tools generate code like this, do the developers take that as examples of how it should be done?    Commenting is also different - I am seeing much less of it in C# code than in C/C++ code than I used to see.    Am I just seeing too many poor examples in one place, or is this really a trend that other former C/C++1 developers are seeing?  Or is this just a form of "developer evolution?"    Anyway...    Peace! 1 This in relevant - developers that only have done C# have little to compare to. Edit: Thank God for things like auto-completion, otherwise all those rapid development claims would be offset by the amount of time it took to

        K Offline
        K Offline
        Kevin McFarlane
        wrote on last edited by
        #5

        James R. Twine wrote:

        Commenting is also different - I am seeing much less of it in C# code than in C/C++ code than I used to see.

        Not really noticed a difference. Lots missing in both C/C++ and C#.

        Kevin

        1 Reply Last reply
        0
        • O Oakman

          Chris Maunder wrote:

          Or it could be that C# encourages code that is so well structured that it doesn't need comments

          ROFL

          Jon Smith & Wesson: The original point and click interface

          G Offline
          G Offline
          Gary Wheeler
          wrote on last edited by
          #6

          My inner voice said "not f***ing likely" to that one.

          Software Zen: delete this;

          C E 2 Replies Last reply
          0
          • G Gary Wheeler

            My inner voice said "not f***ing likely" to that one.

            Software Zen: delete this;

            C Offline
            C Offline
            Chris Maunder
            wrote on last edited by
            #7

            :D

            cheers, Chris Maunder

            CodeProject.com : C++ MVP

            1 Reply Last reply
            0
            • G Gary Wheeler

              My inner voice said "not f***ing likely" to that one.

              Software Zen: delete this;

              E Offline
              E Offline
              El Corazon
              wrote on last edited by
              #8

              Gary Wheeler wrote:

              My inner voice said "not f***ing likely" to that one.

              gary, gary... stare at that light colored fuzzy bunny hugs artwork until your inner voice calms down... then all will be fine! all will be good!

              _________________________ Asu no koto o ieba, tenjo de nezumi ga warau. Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb) John Andrew Holmes "It is well to remember that the entire universe, with one trifling exception, is composed of others."

              G 1 Reply Last reply
              0
              • J James R Twine

                So - as I delve into more and more C# code, I am noticing something.  When reading C++ code, I tended to see that the code tends to be wrapped nicely, broken up into smaller functions, and does not extend too far to the right.    However, much of the C# code that I am seeing tends to runs onto the right more often than not, requiring scrolling back and forth just to grok a single line (and I run my monitors at a pretty healthy resolution).  Perhaps, some of this can be partially attributed to the longer names of the classes/objects included in the framework (e.g. AssemblyInformationalVersionAttribute, IDictionaryEnumerator, DataColumnMappingCollection), how things like enums are referenced (e.g. FileShare.ReadWrite), and how certain constructs are written (e.g. foreach( ... ), using( ... ))    Even the autogenerated code is much different - when I had an IDL file generated, or generated an empty interface implementation from one, I rarely got really long lines.  With C#/.NET, I have seen autogenerated code extend beyond 400(!) characters!

                [System.Web.Services.Protocols.SoapDocumentMethodAttribute
                ("http://www.domain.com/schemas/App/1.0/MyWebService/ReserveActions",
                RequestNamespace="http://www.domain.com/schemas/App/1.0/MyWebService/",
                ResponseNamespace="http://www.domain.com/schemas/App/1.0/MyWebService/",
                Use=System.Web.Services.Description.SoapBindingUse.Literal,
                ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]

                (Line manually wrapped and some things changed above to protect certain information.)    I cannot help but wonder that when a developer's tools generate code like this, do the developers take that as examples of how it should be done?    Commenting is also different - I am seeing much less of it in C# code than in C/C++ code than I used to see.    Am I just seeing too many poor examples in one place, or is this really a trend that other former C/C++1 developers are seeing?  Or is this just a form of "developer evolution?"    Anyway...    Peace! 1 This in relevant - developers that only have done C# have little to compare to. Edit: Thank God for things like auto-completion, otherwise all those rapid development claims would be offset by the amount of time it took to

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

                This is one of the things that annoys me about C#. Before generics, it was all made worse by the incredible amount of casting you had to do. I've long worked in the clear-algorithms-few-comments style of coding, so that's not as big an issue for me. I do know that after working in C# for a few days, I find it an incredible relief and joy to get back to C++. With the exception of anonymous delegates, and quick prototyping with forms, C# gets in the way all too often (I do non-database client application development.)

                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
                • C Chris Maunder

                  Long lines: We have a policy in-house of wrapping lines at column 100. Part of the art of software development is naming variables and classes and it's a shame that this seems to have been thrown to the wind. Comments: It could be that C# is more approachable that C++ so we're seeing developers with less experience coming to the fore. Or it could be that C# encourages code that is so well structured that it doesn't need comments. Or it could be all those ex-VB6 developers we're hearing about... :P

                  cheers, Chris Maunder

                  CodeProject.com : C++ MVP

                  R Offline
                  R Offline
                  Roger Alsing 0
                  wrote on last edited by
                  #10

                  >>Or it could be that C# encourages code that is so well structured that it doesn't need comments. Maybe not like that, but VS.NET have become really really good to give feedback to the developer. intellisense + infotips when hovering variables/methods/whatever. So Id say that part of the reason is that the envoronment is giving us much of the info we need. info that we had to use comments or hungarian notation for in the past.

                  Blog: http://www.rogeralsing.com Projects: http://www.puzzleframework.com

                  J 1 Reply Last reply
                  0
                  • R Roger Alsing 0

                    >>Or it could be that C# encourages code that is so well structured that it doesn't need comments. Maybe not like that, but VS.NET have become really really good to give feedback to the developer. intellisense + infotips when hovering variables/methods/whatever. So Id say that part of the reason is that the envoronment is giving us much of the info we need. info that we had to use comments or hungarian notation for in the past.

                    Blog: http://www.rogeralsing.com Projects: http://www.puzzleframework.com

                    J Offline
                    J Offline
                    James R Twine
                    wrote on last edited by
                    #11

                    True, but this assumes that everyone will be using the same IDE that you are, so the information that the IDE so easily provides you is just as easily taken for granted.    Additional information such as comments, and notation are very easily ignored if they are not required.  However, needing the additional information and not having it is a different story entirely.    Besides, I have had too many issues with Intelli_nonsense_ in the past that I only trust Visual Assist! :laugh:    Peace!

                    -=- James
                    Please rate this message - let me know if I helped or not! * * * If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong!
                    Remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road!
                    See DeleteFXPFiles

                    1 Reply Last reply
                    0
                    • C Chris Maunder

                      Long lines: We have a policy in-house of wrapping lines at column 100. Part of the art of software development is naming variables and classes and it's a shame that this seems to have been thrown to the wind. Comments: It could be that C# is more approachable that C++ so we're seeing developers with less experience coming to the fore. Or it could be that C# encourages code that is so well structured that it doesn't need comments. Or it could be all those ex-VB6 developers we're hearing about... :P

                      cheers, Chris Maunder

                      CodeProject.com : C++ MVP

                      realJSOPR Offline
                      realJSOPR Offline
                      realJSOP
                      wrote on last edited by
                      #12

                      Lack of comments is a direct side-effect of having open source developers start developing for Windows because they "gotta eat, afterall". If you look at most open-source code, you'll see a little/no comments at all because the original author abandoned the code right after he had his first clean compile. His view was "I'm not gonna maintain this code, so I don't need to put comments in it to remind me of why I did things." These same guys are now realizing that free source code doesn't put beans on the table, so they have to work in the Windows world, where they bring their half-assed coding techniques along with them.

                      "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
                      -----
                      "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001

                      G 1 Reply Last reply
                      0
                      • C Chris Maunder

                        Long lines: We have a policy in-house of wrapping lines at column 100. Part of the art of software development is naming variables and classes and it's a shame that this seems to have been thrown to the wind. Comments: It could be that C# is more approachable that C++ so we're seeing developers with less experience coming to the fore. Or it could be that C# encourages code that is so well structured that it doesn't need comments. Or it could be all those ex-VB6 developers we're hearing about... :P

                        cheers, Chris Maunder

                        CodeProject.com : C++ MVP

                        J Offline
                        J Offline
                        James R Twine
                        wrote on last edited by
                        #13

                        I used to wrap at column 61!  May seem a bit short to some but it worked well for commenting on the right (my code on this site demonstrate this).  Lines rarely went past that column, and when they did, they very rarely hit column 80.    If your code started getting more and more to the right (.e.g. nested ifs, etc.) to where you were running out of space and started doing things like putting each word/variable/operation on a new line, it was the indication that you needed to extract that code into a new function.    It kinda forced you to break things up into functions, refactor longer code into smaller more optimized code, or at the very least to rethink things like how your ifs should be structured.    Peace!

                        -=- James
                        Please rate this message - let me know if I helped or not! * * * If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong!
                        Remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road!
                        See DeleteFXPFiles

                        1 Reply Last reply
                        0
                        • E El Corazon

                          Gary Wheeler wrote:

                          My inner voice said "not f***ing likely" to that one.

                          gary, gary... stare at that light colored fuzzy bunny hugs artwork until your inner voice calms down... then all will be fine! all will be good!

                          _________________________ Asu no koto o ieba, tenjo de nezumi ga warau. Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb) John Andrew Holmes "It is well to remember that the entire universe, with one trifling exception, is composed of others."

                          G Offline
                          G Offline
                          Gary Wheeler
                          wrote on last edited by
                          #14

                          I've been listening to a mix of Spanish guitar and Keiko Matsui all morning. Thus far, the mellow just ain't happenin'.

                          Software Zen: delete this;

                          E 1 Reply Last reply
                          0
                          • realJSOPR realJSOP

                            Lack of comments is a direct side-effect of having open source developers start developing for Windows because they "gotta eat, afterall". If you look at most open-source code, you'll see a little/no comments at all because the original author abandoned the code right after he had his first clean compile. His view was "I'm not gonna maintain this code, so I don't need to put comments in it to remind me of why I did things." These same guys are now realizing that free source code doesn't put beans on the table, so they have to work in the Windows world, where they bring their half-assed coding techniques along with them.

                            "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
                            -----
                            "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001

                            G Offline
                            G Offline
                            Gary Wheeler
                            wrote on last edited by
                            #15

                            Preach it, brother!

                            Software Zen: delete this;

                            1 Reply Last reply
                            0
                            • J James R Twine

                              So - as I delve into more and more C# code, I am noticing something.  When reading C++ code, I tended to see that the code tends to be wrapped nicely, broken up into smaller functions, and does not extend too far to the right.    However, much of the C# code that I am seeing tends to runs onto the right more often than not, requiring scrolling back and forth just to grok a single line (and I run my monitors at a pretty healthy resolution).  Perhaps, some of this can be partially attributed to the longer names of the classes/objects included in the framework (e.g. AssemblyInformationalVersionAttribute, IDictionaryEnumerator, DataColumnMappingCollection), how things like enums are referenced (e.g. FileShare.ReadWrite), and how certain constructs are written (e.g. foreach( ... ), using( ... ))    Even the autogenerated code is much different - when I had an IDL file generated, or generated an empty interface implementation from one, I rarely got really long lines.  With C#/.NET, I have seen autogenerated code extend beyond 400(!) characters!

                              [System.Web.Services.Protocols.SoapDocumentMethodAttribute
                              ("http://www.domain.com/schemas/App/1.0/MyWebService/ReserveActions",
                              RequestNamespace="http://www.domain.com/schemas/App/1.0/MyWebService/",
                              ResponseNamespace="http://www.domain.com/schemas/App/1.0/MyWebService/",
                              Use=System.Web.Services.Description.SoapBindingUse.Literal,
                              ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]

                              (Line manually wrapped and some things changed above to protect certain information.)    I cannot help but wonder that when a developer's tools generate code like this, do the developers take that as examples of how it should be done?    Commenting is also different - I am seeing much less of it in C# code than in C/C++ code than I used to see.    Am I just seeing too many poor examples in one place, or is this really a trend that other former C/C++1 developers are seeing?  Or is this just a form of "developer evolution?"    Anyway...    Peace! 1 This in relevant - developers that only have done C# have little to compare to. Edit: Thank God for things like auto-completion, otherwise all those rapid development claims would be offset by the amount of time it took to

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

                              James R. Twine wrote:

                              Am I just seeing too many poor examples in one place, or is this really a trend that other former C/C++ developers are seeing?

                              As a former C++ developer who used C# for a couple of years and then ran back to C++, I remember I was extremely annoyed by:

                              using (MyBigFatClass myBigFatObject = new MyBigFatClass())
                              {
                              ...
                              }

                              vs.

                              MyBigFatClass myBigFatObject;
                              ...

                              Not to mention that many developers wouldn't even bother to use using and prefered to manually call Dispose, and the most extreme ones kept claiming that even that is harmful, and the GC is smart enough to clean up all the resources. Oh, and the casting... X| And reflection X| X|

                              Programming Blog utf8-cpp

                              M 1 Reply Last reply
                              0
                              • G Gary Wheeler

                                I've been listening to a mix of Spanish guitar and Keiko Matsui all morning. Thus far, the mellow just ain't happenin'.

                                Software Zen: delete this;

                                E Offline
                                E Offline
                                El Corazon
                                wrote on last edited by
                                #17

                                Gary Wheeler wrote:

                                a mix of Spanish guitar and Keiko Matsui

                                mixing those will make you ill... one at a time Gary, one at a time! :-D

                                _________________________ Asu no koto o ieba, tenjo de nezumi ga warau. Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb) John Andrew Holmes "It is well to remember that the entire universe, with one trifling exception, is composed of others."

                                1 Reply Last reply
                                0
                                • J James R Twine

                                  So - as I delve into more and more C# code, I am noticing something.  When reading C++ code, I tended to see that the code tends to be wrapped nicely, broken up into smaller functions, and does not extend too far to the right.    However, much of the C# code that I am seeing tends to runs onto the right more often than not, requiring scrolling back and forth just to grok a single line (and I run my monitors at a pretty healthy resolution).  Perhaps, some of this can be partially attributed to the longer names of the classes/objects included in the framework (e.g. AssemblyInformationalVersionAttribute, IDictionaryEnumerator, DataColumnMappingCollection), how things like enums are referenced (e.g. FileShare.ReadWrite), and how certain constructs are written (e.g. foreach( ... ), using( ... ))    Even the autogenerated code is much different - when I had an IDL file generated, or generated an empty interface implementation from one, I rarely got really long lines.  With C#/.NET, I have seen autogenerated code extend beyond 400(!) characters!

                                  [System.Web.Services.Protocols.SoapDocumentMethodAttribute
                                  ("http://www.domain.com/schemas/App/1.0/MyWebService/ReserveActions",
                                  RequestNamespace="http://www.domain.com/schemas/App/1.0/MyWebService/",
                                  ResponseNamespace="http://www.domain.com/schemas/App/1.0/MyWebService/",
                                  Use=System.Web.Services.Description.SoapBindingUse.Literal,
                                  ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]

                                  (Line manually wrapped and some things changed above to protect certain information.)    I cannot help but wonder that when a developer's tools generate code like this, do the developers take that as examples of how it should be done?    Commenting is also different - I am seeing much less of it in C# code than in C/C++ code than I used to see.    Am I just seeing too many poor examples in one place, or is this really a trend that other former C/C++1 developers are seeing?  Or is this just a form of "developer evolution?"    Anyway...    Peace! 1 This in relevant - developers that only have done C# have little to compare to. Edit: Thank God for things like auto-completion, otherwise all those rapid development claims would be offset by the amount of time it took to

                                  M Offline
                                  M Offline
                                  Member 96
                                  wrote on last edited by
                                  #18

                                  Ironically this is one of the most visually confusing and unreadable posts I've ever seen here. :)


                                  "The pursuit of excellence is less profitable than the pursuit of bigness, but it can be more satisfying." - David Ogilvy

                                  J 1 Reply Last reply
                                  0
                                  • N Nemanja Trifunovic

                                    James R. Twine wrote:

                                    Am I just seeing too many poor examples in one place, or is this really a trend that other former C/C++ developers are seeing?

                                    As a former C++ developer who used C# for a couple of years and then ran back to C++, I remember I was extremely annoyed by:

                                    using (MyBigFatClass myBigFatObject = new MyBigFatClass())
                                    {
                                    ...
                                    }

                                    vs.

                                    MyBigFatClass myBigFatObject;
                                    ...

                                    Not to mention that many developers wouldn't even bother to use using and prefered to manually call Dispose, and the most extreme ones kept claiming that even that is harmful, and the GC is smart enough to clean up all the resources. Oh, and the casting... X| And reflection X| X|

                                    Programming Blog utf8-cpp

                                    M Offline
                                    M Offline
                                    MidwestLimey
                                    wrote on last edited by
                                    #19

                                    Nemanja Trifunovic wrote:

                                    Oh, and the casting...

                                    To be fair egregious casting is hardly the preserve of C#, it's more an indication of failed design.

                                    Nemanja Trifunovic wrote:

                                    And reflection

                                    Reflection is damn handy, used conservatively. The alternative is to design away the need for metadata via alternative plumbing or to add the metadata plumbing yourself. Instead you could use whats provided, provided you know the implications. Seems to me that most of the arguments leveled against C# are typically pointing to a mass of bad design and/or implementation by less experienced or less skilled developers, presumably attracted by it's apparent ease. But bad design and implementation are not the preserve of C# by a long shot. There's a reason for competitions for the most obfuscated C code, and god knows I've written some whoppers :D


                                    I'm largely language agnostic


                                    After a while they all bug me :doh:


                                    N 1 Reply Last reply
                                    0
                                    • M MidwestLimey

                                      Nemanja Trifunovic wrote:

                                      Oh, and the casting...

                                      To be fair egregious casting is hardly the preserve of C#, it's more an indication of failed design.

                                      Nemanja Trifunovic wrote:

                                      And reflection

                                      Reflection is damn handy, used conservatively. The alternative is to design away the need for metadata via alternative plumbing or to add the metadata plumbing yourself. Instead you could use whats provided, provided you know the implications. Seems to me that most of the arguments leveled against C# are typically pointing to a mass of bad design and/or implementation by less experienced or less skilled developers, presumably attracted by it's apparent ease. But bad design and implementation are not the preserve of C# by a long shot. There's a reason for competitions for the most obfuscated C code, and god knows I've written some whoppers :D


                                      I'm largely language agnostic


                                      After a while they all bug me :doh:


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

                                      MidwestLimey wrote:

                                      To be fair egregious casting is hardly the preserve of C#, it's more an indication of failed design.

                                      I beg to dissagree. At least before generics, I had to constantly cast down whenever I was using the containers. And even now, just look at all the methods that return System.Object.

                                      MidwestLimey wrote:

                                      Reflection is damn handy, used conservatively.

                                      The only valid use of reflection I am aware of is in the Development tools, like IDE's, compilers, and unit-test frameworks.

                                      Programming Blog utf8-cpp

                                      G 1 Reply Last reply
                                      0
                                      • J James R Twine

                                        So - as I delve into more and more C# code, I am noticing something.  When reading C++ code, I tended to see that the code tends to be wrapped nicely, broken up into smaller functions, and does not extend too far to the right.    However, much of the C# code that I am seeing tends to runs onto the right more often than not, requiring scrolling back and forth just to grok a single line (and I run my monitors at a pretty healthy resolution).  Perhaps, some of this can be partially attributed to the longer names of the classes/objects included in the framework (e.g. AssemblyInformationalVersionAttribute, IDictionaryEnumerator, DataColumnMappingCollection), how things like enums are referenced (e.g. FileShare.ReadWrite), and how certain constructs are written (e.g. foreach( ... ), using( ... ))    Even the autogenerated code is much different - when I had an IDL file generated, or generated an empty interface implementation from one, I rarely got really long lines.  With C#/.NET, I have seen autogenerated code extend beyond 400(!) characters!

                                        [System.Web.Services.Protocols.SoapDocumentMethodAttribute
                                        ("http://www.domain.com/schemas/App/1.0/MyWebService/ReserveActions",
                                        RequestNamespace="http://www.domain.com/schemas/App/1.0/MyWebService/",
                                        ResponseNamespace="http://www.domain.com/schemas/App/1.0/MyWebService/",
                                        Use=System.Web.Services.Description.SoapBindingUse.Literal,
                                        ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]

                                        (Line manually wrapped and some things changed above to protect certain information.)    I cannot help but wonder that when a developer's tools generate code like this, do the developers take that as examples of how it should be done?    Commenting is also different - I am seeing much less of it in C# code than in C/C++ code than I used to see.    Am I just seeing too many poor examples in one place, or is this really a trend that other former C/C++1 developers are seeing?  Or is this just a form of "developer evolution?"    Anyway...    Peace! 1 This in relevant - developers that only have done C# have little to compare to. Edit: Thank God for things like auto-completion, otherwise all those rapid development claims would be offset by the amount of time it took to

                                        P Online
                                        P Online
                                        PIEBALDconsult
                                        wrote on last edited by
                                        #21

                                        I hold myself to 112 characters per line because that's how many I can fit across an 8.5" sheet of paper using 8 point Courier with half-inch margins. :-D Comments are another matter but I don't think I've improved or worsened since my just-plain-C days.

                                        1 Reply Last reply
                                        0
                                        • M Member 96

                                          Ironically this is one of the most visually confusing and unreadable posts I've ever seen here. :)


                                          "The pursuit of excellence is less profitable than the pursuit of bigness, but it can be more satisfying." - David Ogilvy

                                          J Offline
                                          J Offline
                                          James R Twine
                                          wrote on last edited by
                                          #22

                                          Well, luckly my code is much more readable! :)    Peace!

                                          -=- James
                                          Please rate this message - let me know if I helped or not! * * * If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong!
                                          Remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road!
                                          See DeleteFXPFiles

                                          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