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. Programming Question

Programming Question

Scheduled Pinned Locked Moved The Lounge
wpfcsharpcombusinessarchitecture
88 Posts 42 Posters 1 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.
  • L Lost User

    "My code doesn't need comments because it is self documenting, all methods are small and have single functionality, and any business documentation should be provided by the specification and not the code." Discuss.

    MVVM# - See how I did MVVM my way ___________________________________________ Man, you're a god. - walterhevedeich 26/05/2011 .\\axxx (That's an 'M')

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

    Must be nice where you work.

    L 1 Reply Last reply
    0
    • P PIEBALDconsult

      Must be nice where you work.

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

      I wasn't clear - this was a quote from a cow-worker. My comments, unfortunately, were not KSS so I couldn't post them here.

      MVVM# - See how I did MVVM my way ___________________________________________ Man, you're a god. - walterhevedeich 26/05/2011 .\\axxx (That's an 'M')

      P L 2 Replies Last reply
      0
      • L Lost User

        "My code doesn't need comments because it is self documenting, all methods are small and have single functionality, and any business documentation should be provided by the specification and not the code." Discuss.

        MVVM# - See how I did MVVM my way ___________________________________________ Man, you're a god. - walterhevedeich 26/05/2011 .\\axxx (That's an 'M')

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

        If you don't need comments you're not doing it right, sunshine.

        1 Reply Last reply
        0
        • L Lost User

          "My code doesn't need comments because it is self documenting, all methods are small and have single functionality, and any business documentation should be provided by the specification and not the code." Discuss.

          MVVM# - See how I did MVVM my way ___________________________________________ Man, you're a god. - walterhevedeich 26/05/2011 .\\axxx (That's an 'M')

          A Offline
          A Offline
          AspDotNetDev
          wrote on last edited by
          #5

          Simples:

          double CalculateTax(double fine) {
          var notAComment1 = "Calculate the tax based on the rate from the database.";
          return fine * GetTaxRate();
          }

          Seriously, though, I like comments, even for private members. And I like everything (except for constants and member variables, which typically have a corresponding property) to have a comment. I mostly read the comments rather than the code when I'm quickly navigating through code. I don't want a funky looking uncommented section to slow me down. I also write XML comments so intellisense helps me avoid having to go to the definition to find more info.

          Thou mewling ill-breeding pignut!

          L P T 3 Replies Last reply
          0
          • A AspDotNetDev

            Simples:

            double CalculateTax(double fine) {
            var notAComment1 = "Calculate the tax based on the rate from the database.";
            return fine * GetTaxRate();
            }

            Seriously, though, I like comments, even for private members. And I like everything (except for constants and member variables, which typically have a corresponding property) to have a comment. I mostly read the comments rather than the code when I'm quickly navigating through code. I don't want a funky looking uncommented section to slow me down. I also write XML comments so intellisense helps me avoid having to go to the definition to find more info.

            Thou mewling ill-breeding pignut!

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

            I think comments are worth their weight so ling as they are written well - describing the business reasons not the technology (unless the tech is crafty, unusual or complex) when I sit down to write a method, I start by calling it something

            public double CalculateTax(double fine)
            {
            }

            Then I comment it

            ///
            /// Calculate the tax, taking into account the fine passed.
            /// Requires that the tax rate is retrievable from the TaxService
            ///

            Then I might write some test code just to get it building

            ///
            /// Calculate the tax, taking into account the fine passed.
            /// Requires that the tax rate is retrievable from the TaxService
            ///
            public double CalculateTax(double fine)
            {
            // TODO: Perform the tax calculation
            return 34567.89;
            }

            Then I start to flesh out the method by way of comments

            ///
            /// Calculate the tax, taking into account the fine passed.
            /// Requires that the tax rate is retrievable from the TaxService
            ///
            public double CalculateTax(double fine)
            {
            // Get the tax rate using the appropriate service
            // calculate the fine (I think it is just fine * tax rate but need to check with spec!)
            }

            Then, finally, I write the code

            ///
            /// Calculate the tax, taking into account the fine passed.
            /// Requires that the tax rate is retrievable from the TaxService
            ///
            public double CalculateTax(double fine)
            {
            // Get the tax rate using the appropriate service
            double taxRate = GetTaxRate();
            // calculate the fine
            tax = taxRate * fine;

            return tax ;
            

            }

            That way, I can remember where I was if I get interrupted, the comments aren't an afterthought, they are a part of the process and, if I get hit by the Programmer bus, someone else should be able to see what I was doing. Obv. the example is small and trivial, but that's how I work and I fail to understand the 'don't need comments' brigade. What I do hate is/...

            // Multiply the rate by the amount
            return rate * amount;

            which is simply a case of bad commenting in my book - it is not necessary to comment every step

            MVVM# - See how I did MVVM my way ___________________________________________ Man, you're a god. - walterhevedeich 26/05/2011 .\\axxx (That's an 'M')

            A M N M C 9 Replies Last reply
            0
            • L Lost User

              I think comments are worth their weight so ling as they are written well - describing the business reasons not the technology (unless the tech is crafty, unusual or complex) when I sit down to write a method, I start by calling it something

              public double CalculateTax(double fine)
              {
              }

              Then I comment it

              ///
              /// Calculate the tax, taking into account the fine passed.
              /// Requires that the tax rate is retrievable from the TaxService
              ///

              Then I might write some test code just to get it building

              ///
              /// Calculate the tax, taking into account the fine passed.
              /// Requires that the tax rate is retrievable from the TaxService
              ///
              public double CalculateTax(double fine)
              {
              // TODO: Perform the tax calculation
              return 34567.89;
              }

              Then I start to flesh out the method by way of comments

              ///
              /// Calculate the tax, taking into account the fine passed.
              /// Requires that the tax rate is retrievable from the TaxService
              ///
              public double CalculateTax(double fine)
              {
              // Get the tax rate using the appropriate service
              // calculate the fine (I think it is just fine * tax rate but need to check with spec!)
              }

              Then, finally, I write the code

              ///
              /// Calculate the tax, taking into account the fine passed.
              /// Requires that the tax rate is retrievable from the TaxService
              ///
              public double CalculateTax(double fine)
              {
              // Get the tax rate using the appropriate service
              double taxRate = GetTaxRate();
              // calculate the fine
              tax = taxRate * fine;

              return tax ;
              

              }

              That way, I can remember where I was if I get interrupted, the comments aren't an afterthought, they are a part of the process and, if I get hit by the Programmer bus, someone else should be able to see what I was doing. Obv. the example is small and trivial, but that's how I work and I fail to understand the 'don't need comments' brigade. What I do hate is/...

              // Multiply the rate by the amount
              return rate * amount;

              which is simply a case of bad commenting in my book - it is not necessary to comment every step

              MVVM# - See how I did MVVM my way ___________________________________________ Man, you're a god. - walterhevedeich 26/05/2011 .\\axxx (That's an 'M')

              A Offline
              A Offline
              AspDotNetDev
              wrote on last edited by
              #7

              _Maxxx_ wrote:

              which is simply a case of bad commenting in my book - it is not necessary to comment every step

              True. The only time I write comments like that is out of aesthetic necessity. If there was a chunk of code above that line that had its own comment, but the comment didn't apply to that line, I might make a comment like that simply to maintain visual consistency.

              Thou mewling ill-breeding pignut!

              L 1 Reply Last reply
              0
              • A AspDotNetDev

                _Maxxx_ wrote:

                which is simply a case of bad commenting in my book - it is not necessary to comment every step

                True. The only time I write comments like that is out of aesthetic necessity. If there was a chunk of code above that line that had its own comment, but the comment didn't apply to that line, I might make a comment like that simply to maintain visual consistency.

                Thou mewling ill-breeding pignut!

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

                :thumbsup: I came across some code only a few minutes ago which was headed by a "Reset the totals". the next three lines did as advertised. the following six did all sorts of unrelated stuff; even a comment // do unrelated stuff would make it easier to read! ** Caveat. Mine is not the best code in the world, and I am not the 'best' programmer in the world. It's easy to criticise other's code and to say how you would have done it differently; what I objected to in the original case was the assumption that their code was so beautiful it didn't need comments, and that if info was required one should look at the spec (which , in the real world, doesn't actually exist!)

                MVVM# - See how I did MVVM my way ___________________________________________ Man, you're a god. - walterhevedeich 26/05/2011 .\\axxx (That's an 'M')

                1 Reply Last reply
                0
                • A AspDotNetDev

                  Simples:

                  double CalculateTax(double fine) {
                  var notAComment1 = "Calculate the tax based on the rate from the database.";
                  return fine * GetTaxRate();
                  }

                  Seriously, though, I like comments, even for private members. And I like everything (except for constants and member variables, which typically have a corresponding property) to have a comment. I mostly read the comments rather than the code when I'm quickly navigating through code. I don't want a funky looking uncommented section to slow me down. I also write XML comments so intellisense helps me avoid having to go to the definition to find more info.

                  Thou mewling ill-breeding pignut!

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

                  [Description("Calculate the tax based on the rate from the database.")]
                  double CalculateTax(double fine) {
                  return fine * GetTaxRate();
                  }

                  Now you can find it via Reflection as well. :cool:

                  L 1 Reply Last reply
                  0
                  • L Lost User

                    I wasn't clear - this was a quote from a cow-worker. My comments, unfortunately, were not KSS so I couldn't post them here.

                    MVVM# - See how I did MVVM my way ___________________________________________ Man, you're a god. - walterhevedeich 26/05/2011 .\\axxx (That's an 'M')

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

                    I was discussing.

                    1 Reply Last reply
                    0
                    • P PIEBALDconsult

                      [Description("Calculate the tax based on the rate from the database.")]
                      double CalculateTax(double fine) {
                      return fine * GetTaxRate();
                      }

                      Now you can find it via Reflection as well. :cool:

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

                      Would't you have to do

                      [(".esabatad eht morf etar eht no desab xat eht etaluclaC")noitpircseD]

                      MVVM# - See how I did MVVM my way ___________________________________________ Man, you're a god. - walterhevedeich 26/05/2011 .\\axxx (That's an 'M')

                      P 1 Reply Last reply
                      0
                      • L Lost User

                        Would't you have to do

                        [(".esabatad eht morf etar eht no desab xat eht etaluclaC")noitpircseD]

                        MVVM# - See how I did MVVM my way ___________________________________________ Man, you're a god. - walterhevedeich 26/05/2011 .\\axxx (That's an 'M')

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

                        No, because the compiler doesn't care how you view it.

                        1 Reply Last reply
                        0
                        • L Lost User

                          "My code doesn't need comments because it is self documenting, all methods are small and have single functionality, and any business documentation should be provided by the specification and not the code." Discuss.

                          MVVM# - See how I did MVVM my way ___________________________________________ Man, you're a god. - walterhevedeich 26/05/2011 .\\axxx (That's an 'M')

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

                          I already have[^]. I'm no longer willing to even entertain the discussion anymore. Every "good" example I've seen where commenting isn't needed is contrived. The real world is messy. Use comments.

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

                          B G 2 Replies Last reply
                          0
                          • L Lost User

                            "My code doesn't need comments because it is self documenting, all methods are small and have single functionality, and any business documentation should be provided by the specification and not the code." Discuss.

                            MVVM# - See how I did MVVM my way ___________________________________________ Man, you're a god. - walterhevedeich 26/05/2011 .\\axxx (That's an 'M')

                            _ Offline
                            _ Offline
                            _Damian S_
                            wrote on last edited by
                            #14

                            I initial and date all my code changes in a comment near the change - you have no idea how many times I have been able to point to that in code for a client and say "No, noone has changed this since..." which is particularly handy if something strange goes on...

                            Silence is golden... but duct tape is silver!! Booger Mobile - My bright green 1964 Ford Falcon - check out the blog here!! | If you feel generous - make a donation to Camp Quality!!

                            A J 2 Replies Last reply
                            0
                            • _ _Damian S_

                              I initial and date all my code changes in a comment near the change - you have no idea how many times I have been able to point to that in code for a client and say "No, noone has changed this since..." which is particularly handy if something strange goes on...

                              Silence is golden... but duct tape is silver!! Booger Mobile - My bright green 1964 Ford Falcon - check out the blog here!! | If you feel generous - make a donation to Camp Quality!!

                              A Offline
                              A Offline
                              AspDotNetDev
                              wrote on last edited by
                              #15

                              So you aren't using source control? :((

                              Thou mewling ill-breeding pignut!

                              _ 1 Reply Last reply
                              0
                              • L Lost User

                                I wasn't clear - this was a quote from a cow-worker. My comments, unfortunately, were not KSS so I couldn't post them here.

                                MVVM# - See how I did MVVM my way ___________________________________________ Man, you're a god. - walterhevedeich 26/05/2011 .\\axxx (That's an 'M')

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

                                _Maxxx_ wrote:

                                cow-worker

                                Someone who works the cow?

                                K E 2 Replies Last reply
                                0
                                • L Lost User

                                  "My code doesn't need comments because it is self documenting, all methods are small and have single functionality, and any business documentation should be provided by the specification and not the code." Discuss.

                                  MVVM# - See how I did MVVM my way ___________________________________________ Man, you're a god. - walterhevedeich 26/05/2011 .\\axxx (That's an 'M')

                                  M Offline
                                  M Offline
                                  Mark_Wallace
                                  wrote on last edited by
                                  #17

                                  Bollocks.

                                  I wanna be a eunuchs developer! Pass me a bread knife!

                                  1 Reply Last reply
                                  0
                                  • L Lost User

                                    I think comments are worth their weight so ling as they are written well - describing the business reasons not the technology (unless the tech is crafty, unusual or complex) when I sit down to write a method, I start by calling it something

                                    public double CalculateTax(double fine)
                                    {
                                    }

                                    Then I comment it

                                    ///
                                    /// Calculate the tax, taking into account the fine passed.
                                    /// Requires that the tax rate is retrievable from the TaxService
                                    ///

                                    Then I might write some test code just to get it building

                                    ///
                                    /// Calculate the tax, taking into account the fine passed.
                                    /// Requires that the tax rate is retrievable from the TaxService
                                    ///
                                    public double CalculateTax(double fine)
                                    {
                                    // TODO: Perform the tax calculation
                                    return 34567.89;
                                    }

                                    Then I start to flesh out the method by way of comments

                                    ///
                                    /// Calculate the tax, taking into account the fine passed.
                                    /// Requires that the tax rate is retrievable from the TaxService
                                    ///
                                    public double CalculateTax(double fine)
                                    {
                                    // Get the tax rate using the appropriate service
                                    // calculate the fine (I think it is just fine * tax rate but need to check with spec!)
                                    }

                                    Then, finally, I write the code

                                    ///
                                    /// Calculate the tax, taking into account the fine passed.
                                    /// Requires that the tax rate is retrievable from the TaxService
                                    ///
                                    public double CalculateTax(double fine)
                                    {
                                    // Get the tax rate using the appropriate service
                                    double taxRate = GetTaxRate();
                                    // calculate the fine
                                    tax = taxRate * fine;

                                    return tax ;
                                    

                                    }

                                    That way, I can remember where I was if I get interrupted, the comments aren't an afterthought, they are a part of the process and, if I get hit by the Programmer bus, someone else should be able to see what I was doing. Obv. the example is small and trivial, but that's how I work and I fail to understand the 'don't need comments' brigade. What I do hate is/...

                                    // Multiply the rate by the amount
                                    return rate * amount;

                                    which is simply a case of bad commenting in my book - it is not necessary to comment every step

                                    MVVM# - See how I did MVVM my way ___________________________________________ Man, you're a god. - walterhevedeich 26/05/2011 .\\axxx (That's an 'M')

                                    M Offline
                                    M Offline
                                    Mark_Wallace
                                    wrote on last edited by
                                    #18

                                    _Maxxx_ wrote:

                                    What I do hate is/...

                                    // Multiply the rate by the amount
                                    return rate * amount;

                                    which is simply a case of bad commenting in my book

                                    I agree. It's far too much typing, and excludes reuse of the function. It should be:

                                    // Multiply
                                    return a * b;

                                    At least, that's what I'm used to seeing.

                                    I wanna be a eunuchs developer! Pass me a bread knife!

                                    1 Reply Last reply
                                    0
                                    • L Lost User

                                      "My code doesn't need comments because it is self documenting, all methods are small and have single functionality, and any business documentation should be provided by the specification and not the code." Discuss.

                                      MVVM# - See how I did MVVM my way ___________________________________________ Man, you're a god. - walterhevedeich 26/05/2011 .\\axxx (That's an 'M')

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

                                      That's obviously a lie. Self documenting functions are nice, but you can't do anything nontrivial that way. Then again, maybe his code only does trivial things? :)

                                      1 Reply Last reply
                                      0
                                      • L Lost User

                                        "My code doesn't need comments because it is self documenting, all methods are small and have single functionality, and any business documentation should be provided by the specification and not the code." Discuss.

                                        MVVM# - See how I did MVVM my way ___________________________________________ Man, you're a god. - walterhevedeich 26/05/2011 .\\axxx (That's an 'M')

                                        P Offline
                                        P Offline
                                        Pete OHanlon
                                        wrote on last edited by
                                        #20

                                        Round flying thing. Discus.

                                        *pre-emptive celebratory nipple tassle jiggle* - Sean Ewington

                                        "Mind bleach! Send me mind bleach!" - Nagy Vilmos

                                        CodeStash - Online Snippet Management | My blog | MoXAML PowerToys | Mole 2010 - debugging made easier

                                        L 1 Reply Last reply
                                        0
                                        • L Lost User

                                          "My code doesn't need comments because it is self documenting, all methods are small and have single functionality, and any business documentation should be provided by the specification and not the code." Discuss.

                                          MVVM# - See how I did MVVM my way ___________________________________________ Man, you're a god. - walterhevedeich 26/05/2011 .\\axxx (That's an 'M')

                                          N Offline
                                          N Offline
                                          Nagy Vilmos
                                          wrote on last edited by
                                          #21

                                          The correct response to such a statement is:

                                          "Just because your mother slept with her brother doesn't mean the rest of us will agree it's a good idea."


                                          Panic, Chaos, Destruction. My work here is done. Drink. Get drunk. Fall over - P O'H OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre I cannot live by bread alone. Bacon and ketchup are needed as well. - Trollslayer Have a bit more patience with newbies. Of course some of them act dumb - they're often *students*, for heaven's sake - Terry Pratchett

                                          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