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. No comment

No comment

Scheduled Pinned Locked Moved The Lounge
businesscollaboration
77 Posts 58 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.
  • R Rob Philpott

    Where I work presently, we are 'agile' if you will. Very disciplined agile. One rule the team has is that comments in code are not allowed (no, really). Code should be self describing, and if you need to comment something, you're better taking it and putting in its own method with a meaningful name. I'd be interested to hear what people's opionions on this are.

    Regards, Rob Philpott.

    D Offline
    D Offline
    Derek Viljoen
    wrote on last edited by
    #54

    I got about halfway through the responses to this before I had to reach for my duct tape to prevent my head from exploding. No comments? Really? That's the stupidest thing I've ever heard. And I used to work for IBM. They collected statistics on klocs! So I've heard some pretty stupid things.

    1 Reply Last reply
    0
    • R Rob Philpott

      Where I work presently, we are 'agile' if you will. Very disciplined agile. One rule the team has is that comments in code are not allowed (no, really). Code should be self describing, and if you need to comment something, you're better taking it and putting in its own method with a meaningful name. I'd be interested to hear what people's opionions on this are.

      Regards, Rob Philpott.

      W Offline
      W Offline
      Wambach
      wrote on last edited by
      #55

      I use to add jokes, odd stories and stuff as comments in my code. Much like here at the lounge. Sometimes I would add comments about coding quirks, crazy stories about why I chose one design over another. It was nice to hear new developers laughing in their cubicles while tasked with maintaining my old code rather than cussing me out.

      1 Reply Last reply
      0
      • N Nagy Vilmos

        Use a gun on the moron who came up with the no comment policy.


        Panic, Chaos, Destruction. My work here is done.

        J Offline
        J Offline
        JasonPSage
        wrote on last edited by
        #56

        Agreed

        Know way too many languages... master of none!

        1 Reply Last reply
        0
        • R Rob Philpott

          Where I work presently, we are 'agile' if you will. Very disciplined agile. One rule the team has is that comments in code are not allowed (no, really). Code should be self describing, and if you need to comment something, you're better taking it and putting in its own method with a meaningful name. I'd be interested to hear what people's opionions on this are.

          Regards, Rob Philpott.

          P Offline
          P Offline
          Plamen Dragiyski
          wrote on last edited by
          #57

          Example of self-explanatory code: UINT ReturnIDOfTheCommandReceivedFromPressingTheDefaultButtonInSecondTabOfTheUI(UINT* PointerToArrayContainingCurrentStateOfTheControlsInTheCommandUIWindow) {... Comments? Who needs 'em? :laugh:

          1 Reply Last reply
          0
          • R Rob Philpott

            Where I work presently, we are 'agile' if you will. Very disciplined agile. One rule the team has is that comments in code are not allowed (no, really). Code should be self describing, and if you need to comment something, you're better taking it and putting in its own method with a meaningful name. I'd be interested to hear what people's opionions on this are.

            Regards, Rob Philpott.

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

            Thinking that your code is self explanatory is like thinking that your code is bug free and doesn't require QA testing. I have the following convention in my team. During code review, if your peer doesn't understand your code, put comments. As for your boss, have him read this thread.

            1 Reply Last reply
            0
            • R Rob Philpott

              Where I work presently, we are 'agile' if you will. Very disciplined agile. One rule the team has is that comments in code are not allowed (no, really). Code should be self describing, and if you need to comment something, you're better taking it and putting in its own method with a meaningful name. I'd be interested to hear what people's opionions on this are.

              Regards, Rob Philpott.

              P Offline
              P Offline
              Phasma
              wrote on last edited by
              #59

              As one maintaining a business app written over 20years in c, where there is hardly any comments, i'm against this. For Christmas i wish for comments, in the code i'm maintaining

              1 Reply Last reply
              0
              • R Rob Philpott

                Where I work presently, we are 'agile' if you will. Very disciplined agile. One rule the team has is that comments in code are not allowed (no, really). Code should be self describing, and if you need to comment something, you're better taking it and putting in its own method with a meaningful name. I'd be interested to hear what people's opionions on this are.

                Regards, Rob Philpott.

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

                The rule that proper naming should mean no comments is great if (a) Everyone in your team is as good at you in naming things (b) everyone on your team think that every word you use means exactly the same thing as you These two basic requirements for a "no comment" system may work wiht 2, or maybe 3 developers, or may work on very simple code that, say, takes data from a database and displays it, but for everything else you're screwed. I'm Australian, I work with Canadian, Ukrainian and US developers. We are constantly clarifying to each other what we mean (in a good way) but it only reinforces how differently we all treat words in the English language. On top of this, what you yourself consider a name to mean one day may very well not be the intention 6 months later.

                cheers, Chris Maunder The Code Project Co-founder Microsoft C++ MVP

                1 Reply Last reply
                0
                • R Rob Philpott

                  Where I work presently, we are 'agile' if you will. Very disciplined agile. One rule the team has is that comments in code are not allowed (no, really). Code should be self describing, and if you need to comment something, you're better taking it and putting in its own method with a meaningful name. I'd be interested to hear what people's opionions on this are.

                  Regards, Rob Philpott.

                  K Offline
                  K Offline
                  k bl
                  wrote on last edited by
                  #61

                  Hey I've got an idea, let's make something completely useful, and then not use it! When you can't explain it in a comment, just use long identifiers ;) : Decimal ClassThatTakesADecimalRoundsItToTheNearestSecondDecimalAndThenReturnsItAsADecimalVeryEffeciantly(Decimal num) { return Math.Round(num, 2); }

                  ASP.Net meets JQuery... Imagine the possibilities.

                  1 Reply Last reply
                  0
                  • R Rob Philpott

                    Where I work presently, we are 'agile' if you will. Very disciplined agile. One rule the team has is that comments in code are not allowed (no, really). Code should be self describing, and if you need to comment something, you're better taking it and putting in its own method with a meaningful name. I'd be interested to hear what people's opionions on this are.

                    Regards, Rob Philpott.

                    B Offline
                    B Offline
                    bwestrick
                    wrote on last edited by
                    #62

                    I think a no comment policy is a bit idealistic. Sure, code should be written so that it can easily be read, but many times the assumptions that one programmer makes are not the same as another reading the code. Or subtleties might be missed. At other times efficient code is not readable without comments. I think a no comment policy is a bit like saying, everyone should drive safe so we don't need seatbelt and insurance. Or, nobody should steal so we don't need to lock our doors. i just don;t think we are there yet.

                    1 Reply Last reply
                    0
                    • R Rob Philpott

                      Where I work presently, we are 'agile' if you will. Very disciplined agile. One rule the team has is that comments in code are not allowed (no, really). Code should be self describing, and if you need to comment something, you're better taking it and putting in its own method with a meaningful name. I'd be interested to hear what people's opionions on this are.

                      Regards, Rob Philpott.

                      A Offline
                      A Offline
                      Anna Jayne Metcalfe
                      wrote on last edited by
                      #63

                      That's at least as nuts as thinking that waterfall development is a good idea. :omg:

                      Anna :rose: Tech Blog | Visual Lint "Why would anyone prefer to wield a weapon that takes both hands at once, when they could use a lighter (and obviously superior) weapon that allows you to wield multiple ones at a time, and thus supports multi-paradigm carnage?"

                      1 Reply Last reply
                      0
                      • U User 167261

                        I disagree. Regions are useful if used sparingly and appropriately.

                        do or do not, there is no try

                        J Offline
                        J Offline
                        Jason Christian
                        wrote on last edited by
                        #64

                        I think regions are great. Crtl+M+O to collapse everything, and then open up the section I need to work with. If I'm looking for the implementation of an interface, I don't have to scroll through all the property defintions first, etc... As for comments, I agree they should be used sparingly and more thought put into making the code self-documenting. Comments can get out of sync with the code, and if you aren't being careful in writing descriptive code why would you be careful about writing a descriptive comment? However, there are times when comments are necessary, so banning them completely is ridiculous. For instance you are calling a 3rd party API that has something uninituitive, and you want to explain why you are calling it a certain way - a method name isn't going to provided that information without being ridiculous ( i.e. DoSomethingWithExtraParametersSo3rdPartyAPIIsHappy ). Comments are also useful to explain the rationale behind a hack when the expected technique won't work for some reason.

                        1 Reply Last reply
                        0
                        • Richard Andrew x64R Richard Andrew x64

                          Sounds like the rules were made by a zealot who doesn't have to write or read code himself/herself.

                          J Offline
                          J Offline
                          James Lonero
                          wrote on last edited by
                          #65

                          Then later comes and asks you "What the hell were you thinking!" and "What does is this doing?"

                          1 Reply Last reply
                          0
                          • R Rob Philpott

                            Where I work presently, we are 'agile' if you will. Very disciplined agile. One rule the team has is that comments in code are not allowed (no, really). Code should be self describing, and if you need to comment something, you're better taking it and putting in its own method with a meaningful name. I'd be interested to hear what people's opionions on this are.

                            Regards, Rob Philpott.

                            J Offline
                            J Offline
                            James Lonero
                            wrote on last edited by
                            #66

                            I have heard of that mentality since the early 80s, especially from those in the UNIX world. The logic is good if all you’re concerned with is what it is doing and how it is being done. You could even put what the method does in the method name. The thinking is that each method should do one and only one thing has been a mantra for years. Coming from the world of C, many years ago, coders liked writing very tight code using many short cuts making the code hard to follow. And, thus, making it more difficult to understand. In today’s world, business dictates that we get the product out ASAP, which may necessitate the rule of “no comments”. The consequences is that at a later point, when someone else picks up your code or you restart in it, the knowledge of what it was doing is degraded and you need to spend time reviewing your work. Also, comments are useful to map code to requirements or bug fixes.

                            1 Reply Last reply
                            0
                            • W wolfbinary

                              At a previous job a consultant mentioned and then explained what agile was and then he declared that's what we'd been doing all along. He missed the part about defining what you're doing and then not changing that until sometime later as another cycle. Agile, as I've seen it, mostly keeps documentation of the system from happening and foresight of the product or system from taking place. When customers ask for documentation we didn't have much to say other than to sputter and then commit to making some later. It was never part of the project. Poorly written comments are just as bad as no comments. What the code is doing doesn't necessarily explain the why. Just my opinion though.

                              A Offline
                              A Offline
                              Alan Burkhart
                              wrote on last edited by
                              #67

                              I've always favored a few lines of comment before a code block to provide an explanation of it's purpose, then if necessary add a few brief comments at the end of a line of code. A year later I can go back and read it and actually remember what I was doing.

                              F 1 Reply Last reply
                              0
                              • R Rob Philpott

                                Where I work presently, we are 'agile' if you will. Very disciplined agile. One rule the team has is that comments in code are not allowed (no, really). Code should be self describing, and if you need to comment something, you're better taking it and putting in its own method with a meaningful name. I'd be interested to hear what people's opionions on this are.

                                Regards, Rob Philpott.

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

                                Lots of possibilities for abuse I see.

                                int _____SuggestDefaultLocation;

                                int ____preallocateSomeComments = 0;
                                int ___checkIfApplicationRunsOnAPlatformSupportingRegistry = 0;
                                int ___queryUserSettingsFirst = 0;
                                int ___fallBackToMachineSettings= 0;

                                CString location; int ___remainsEmptyIfNoDefaultLocationCanBeSuggested;

                                if (___checkIfApplicationRunsOnAPlatformSupportingRegistry, app.Settings.RegSupported)
                                {
                                if (!(___queryUserSettingsFirst,
                                location=RegGet(app.Settings.RegRoot,
                                regidDefaultLocation, location.GetLength())))
                                location = RegGet((___fallBackToMachineSettings, app.Settings.RegUsrRoot), regidDefaultLocation);
                                }

                                Instant win!


                                [edit] On a serious note: Ideally, well written code can tell you clearly what it does. Comments are to tell the reader why.

                                Personally, I love the idea that Raymond spends his nights posting bad regexs to mailing lists under the pseudonym of Jane Smith. He'd be like a super hero, only more nerdy and less useful. [Trevel]
                                | FoldWithUs! | sighist | µLaunch - program launcher for server core and hyper-v server

                                1 Reply Last reply
                                0
                                • A Alan Burkhart

                                  I've always favored a few lines of comment before a code block to provide an explanation of it's purpose, then if necessary add a few brief comments at the end of a line of code. A year later I can go back and read it and actually remember what I was doing.

                                  F Offline
                                  F Offline
                                  FrankLaPiana
                                  wrote on last edited by
                                  #69

                                  One of the comments that I remember (from an article about comments), is that experienced programmers don't always comment what a section of code does, but it was a very good practise to explain why the section was coded that way. Explaining why a particular algoritm was used was more useful than explaining how the algoritm worked.

                                  A 1 Reply Last reply
                                  0
                                  • F FrankLaPiana

                                    One of the comments that I remember (from an article about comments), is that experienced programmers don't always comment what a section of code does, but it was a very good practise to explain why the section was coded that way. Explaining why a particular algoritm was used was more useful than explaining how the algoritm worked.

                                    A Offline
                                    A Offline
                                    Alan Burkhart
                                    wrote on last edited by
                                    #70

                                    Why not? :cool:

                                    '[example...]

                                    'this sub converts a vertical list to a delimited list using a delimiter
                                    'chosen from the delChr array using the SelectedIndex property from the
                                    'combobox in the GetDelimiter dialog
                                    Private Sub menuLines_VertToDel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles menuLines_VertToDel.Click

                                    If sci.Selection.Text.Length = 0 Then 'stop if no text is selected
                                      MsgBox("You must first select some text to convert.", MsgBoxStyle.Information, title)
                                      Exit Sub
                                    End If
                                    
                                    
                                    res = dialog\_GetDelimiter.ShowDialog
                                    
                                    If res = Windows.Forms.DialogResult.OK Then
                                      Try
                                        Dim dc As String = delChr(dialog\_GetDelimiter.cmb\_Delimiter.SelectedIndex) 'char from array
                                        sci.Selection.Text = sci.Text.Replace(Environment.NewLine, dc) 'replace Newline with delimiter chr
                                      Catch ex As Exception
                                        MsgBox(ex.ToString, MsgBoxStyle.Exclamation, title)
                                      End Try
                                    End If
                                    

                                    End Sub

                                    F 1 Reply Last reply
                                    0
                                    • R Rob Philpott

                                      Where I work presently, we are 'agile' if you will. Very disciplined agile. One rule the team has is that comments in code are not allowed (no, really). Code should be self describing, and if you need to comment something, you're better taking it and putting in its own method with a meaningful name. I'd be interested to hear what people's opionions on this are.

                                      Regards, Rob Philpott.

                                      K Offline
                                      K Offline
                                      kjthorn
                                      wrote on last edited by
                                      #71

                                      This only sounds workable if (1) you never need to optimize anything for speed, (2) you don't have to credit anyone else's code, (3) no algorithms were harmed in the making of your software, (4) your code is single-threaded, and (5) your software doesn't do much more than move things around and apply simple transformations. Otherwise, sure, no comments. Why not?

                                      1 Reply Last reply
                                      0
                                      • A Alan Burkhart

                                        Why not? :cool:

                                        '[example...]

                                        'this sub converts a vertical list to a delimited list using a delimiter
                                        'chosen from the delChr array using the SelectedIndex property from the
                                        'combobox in the GetDelimiter dialog
                                        Private Sub menuLines_VertToDel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles menuLines_VertToDel.Click

                                        If sci.Selection.Text.Length = 0 Then 'stop if no text is selected
                                          MsgBox("You must first select some text to convert.", MsgBoxStyle.Information, title)
                                          Exit Sub
                                        End If
                                        
                                        
                                        res = dialog\_GetDelimiter.ShowDialog
                                        
                                        If res = Windows.Forms.DialogResult.OK Then
                                          Try
                                            Dim dc As String = delChr(dialog\_GetDelimiter.cmb\_Delimiter.SelectedIndex) 'char from array
                                            sci.Selection.Text = sci.Text.Replace(Environment.NewLine, dc) 'replace Newline with delimiter chr
                                          Catch ex As Exception
                                            MsgBox(ex.ToString, MsgBoxStyle.Exclamation, title)
                                          End Try
                                        End If
                                        

                                        End Sub

                                        F Offline
                                        F Offline
                                        FrankLaPiana
                                        wrote on last edited by
                                        #72

                                        Well I actually do tend to comment what the function does, ie, "FindCustomerName". But I think the reason was why a particular algorithm was used... which depends upon the complexity of the requirements and the implementation of the logic. // Find object by using custom mapping routine that locks nodes into memory. // This custom map does not need locking for existing items and multi-thread use. // Tested as fastest method and avoids double de-reference of pointer to get to the actual data. program logic blah blah blah // object was not found, must lock here and retry search. program logic blah blah blah // object still not found, create it and add it to the map while we're locked.

                                        1 Reply Last reply
                                        0
                                        • R Rob Philpott

                                          Where I work presently, we are 'agile' if you will. Very disciplined agile. One rule the team has is that comments in code are not allowed (no, really). Code should be self describing, and if you need to comment something, you're better taking it and putting in its own method with a meaningful name. I'd be interested to hear what people's opionions on this are.

                                          Regards, Rob Philpott.

                                          C Offline
                                          C Offline
                                          CoolDadTx
                                          wrote on last edited by
                                          #73

                                          I'd look for a new job as your team evidently heard about Agile, thought it was great and then implemented it wrong. Agile has nothing to do with commenting code. Agile is about reducing all the lengthy, useless documentation that follows a project because it assumes the docs will be wrong. Such docs are unrelated to code comments. Comments help clarify what the code is suppose to do. I do agree that you should not comment every line of code. I also agree that you should use meaningful names and proper modularity but it is important to remember a couple of things that comments provide that you simply can't get in code: 1) Comments specify what the code is suppose to do, not what it actually does. Unless you write perfect code there is always a chance that you'll introduce a logical error into your code. When reviewing someone's code if the comments don't match the code then it should send up a red flag. Just having the code won't help you here. 2) Comments justify why code works the way it does. This is especially important when you don't use verbose documentation (since that goes against Agile). Sometimes there are business rules or decisions that are made by analysts or others and your code just has to do it. It is therefore important to identify why the code works the way it does. For example a block of code that is difficult to read and manage because it has been heavily optimized would probably send an agilist into refactor mode but wait. If a comment above the code said something like "This code is called hundreds of times a minute and has been optimized using profiling and memory utilization tools to make it as fast as possible" then the agilist would know to leave the code alone. Yes in a real world all code is perfectly designed but the more you modularize and OOD a problem the slower the app gets. 3) Agile should not dictate type and variable names. Sure you can use descriptive names but there comes a point where the name of identifiers simply gets too long. For example suppose you are writing some base class types and you need to implement a base class that implements a couple common interfaces such as IEditableObject, INotifyPropertyChanged and IDataErrorInfo. Try naming that type in a meaningful way. Chances are you're going to reduce it to something like BaseBusinessObject or something. Now how does that in any way convey information about the interfaces being implemented? It doesn't. You'd have to look at the code itself. Start nesting these types and it can get ug

                                          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