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. What makes code good?

What makes code good?

Scheduled Pinned Locked Moved The Lounge
wpfcsharpphpcomcollaboration
71 Posts 40 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 Josh Smith

    Jim Crafton wrote:

    If I write it, it's good.

    You must have difficultly getting into buildings, considering that your ego is too big to fit through a door! ;P

    :josh: My WPF Blog[^] Without a strive for perfection I would be terribly bored.

    J Offline
    J Offline
    Jim Crafton
    wrote on last edited by
    #17

    Not at all - I simply use my amazing mentat training and adjust the building's geometry at the quantum level to suit my needs.

    ¡El diablo está en mis pantalones! ¡Mire, mire! Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)! SELECT * FROM User WHERE Clue > 0 0 rows returned Save an Orange - Use the VCF! VCF Blog

    J 1 Reply Last reply
    0
    • E El Corazon

      Josh Smith wrote:

      Too many comments make it difficult to read the code, too few comments force you to read code

      This is true of all parts that you listed. Consistency is nice, but when consistant naming conventions use: int Volume_of_Fuel_for_Onboard_Motor_Sensor_of_Aircraft_Taco_Wing_from_Hanger15=0; too much of anything is a bad thing. Too much emphasis on design and future upgradeability, with little emphasis on functionality is bad, so can the reverse. Too much detail, or not enough detail in variables or comments each will be a bad thing. So my theory on good code can be broken down into one word: Balance. Get the point across, be succinct, not wordy, but be accurate and very clear about what is what. Comments, or code. Styles should be rapidly readable to much elegance can crowd the screen (I have heard requests for 4 spaces before and after {} which means 8 spaces for every open/close). Too much freedom of saying, "they just buy bigger hardware if it isn't fast enough" or too much focus on squeezing the last cpu cycle out of a CISC turnip processor. Too much of anything can be bad. well, except pay, they are welcome to pay me more to test that theory anytime.

      _________________________ Asu no koto o ieba, tenjo de nezumi ga warau. Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)

      J Offline
      J Offline
      Jim Crafton
      wrote on last edited by
      #18

      El Corazon wrote:

      Balance.

      Wish there was a way to vote that a 10 - in all things, Balance! :)

      ¡El diablo está en mis pantalones! ¡Mire, mire! Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)! SELECT * FROM User WHERE Clue > 0 0 rows returned Save an Orange - Use the VCF! VCF Blog

      G 1 Reply Last reply
      0
      • J Josh Smith

        What do you think makes some code better than other code? I don't necessarily mean "good" in the sense that it is bug-free, that's a pipe dream. What are the most important things to you when working with code? I think the following attributes are always found in code I consider to be good: 1) Consistency - The coding styles, naming conventions, usage of patterns, etc. are adhered to throughout the codebase. If your team prefixes private fields with an underscore, all private fields should start with "_". 2) Thoughtful naming - The names of things should accurately convey their purpose. I find that some of the best programmers I know dwell on a method name, or class name, or field name for a long time if necessary. 3) Smart comments - Too many comments make it difficult to read the code, too few comments force you to read code which could easily be summarized in one sentence. I think that all non-private members of a type should be commented, all types should have a comment explaining their purpose, and any tricky/hacky/weird code should be verbosely commented. What about you?

        :josh: My WPF Blog[^] Without a strive for perfection I would be terribly bored.

        D Offline
        D Offline
        Duncan Edwards Jones
        wrote on last edited by
        #19

        Good code is that which you don't mind looking through when you are tired/hungover/grumpy - i.e. easily read and understood.

        '--8<------------------------ Ex Datis: Duncan Jones Merrion Computing Ltd

        1 Reply Last reply
        0
        • J Jim Crafton

          Not at all - I simply use my amazing mentat training and adjust the building's geometry at the quantum level to suit my needs.

          ¡El diablo está en mis pantalones! ¡Mire, mire! Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)! SELECT * FROM User WHERE Clue > 0 0 rows returned Save an Orange - Use the VCF! VCF Blog

          J Offline
          J Offline
          Josh Smith
          wrote on last edited by
          #20

          Jim Crafton wrote:

          I simply use my amazing mentat training

          Perhaps you need some more "mentat" training Your Majesty. :laugh:

          :josh: My WPF Blog[^] Without a strive for perfection I would be terribly bored.

          J 1 Reply Last reply
          0
          • J Josh Smith

            What do you think makes some code better than other code? I don't necessarily mean "good" in the sense that it is bug-free, that's a pipe dream. What are the most important things to you when working with code? I think the following attributes are always found in code I consider to be good: 1) Consistency - The coding styles, naming conventions, usage of patterns, etc. are adhered to throughout the codebase. If your team prefixes private fields with an underscore, all private fields should start with "_". 2) Thoughtful naming - The names of things should accurately convey their purpose. I find that some of the best programmers I know dwell on a method name, or class name, or field name for a long time if necessary. 3) Smart comments - Too many comments make it difficult to read the code, too few comments force you to read code which could easily be summarized in one sentence. I think that all non-private members of a type should be commented, all types should have a comment explaining their purpose, and any tricky/hacky/weird code should be verbosely commented. What about you?

            :josh: My WPF Blog[^] Without a strive for perfection I would be terribly bored.

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

            Keep it simple. Some programmers like to write a hundred lines of code because it makes them feel like a programmer. Fuck that, write it in 20 because YOU ARE a programmer. Write everything out on paper before you even touch the keyboard...think it through. Take your time. Haste does make waste...and stinky waste it is.

            [ Don't do today what can be done tomorrow!! ;) ]

            1 Reply Last reply
            0
            • J Josh Smith

              Jim Crafton wrote:

              If I write it, it's good.

              You must have difficultly getting into buildings, considering that your ego is too big to fit through a door! ;P

              :josh: My WPF Blog[^] Without a strive for perfection I would be terribly bored.

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

              Josh Smith wrote:

              You must have difficultly getting into buildings, considering that your ego is too big to fit through a door!

              And his ass.

              J 1 Reply Last reply
              0
              • L Lost User

                Josh Smith wrote:

                You must have difficultly getting into buildings, considering that your ego is too big to fit through a door!

                And his ass.

                J Offline
                J Offline
                Josh Smith
                wrote on last edited by
                #23

                INITCOMMONCONTROLSEX wrote:

                And his ass.

                Speaking of asses...

                :josh: My WPF Blog[^] Without a strive for perfection I would be terribly bored.

                S 1 Reply Last reply
                0
                • J Josh Smith

                  Marc Clifton wrote:

                  The rest is just style, common sense, and coding rules.

                  You know what they say about common sense, right... :)

                  :josh: My WPF Blog[^] Without a strive for perfection I would be terribly bored.

                  P Offline
                  P Offline
                  Patrick Etc
                  wrote on last edited by
                  #24

                  Josh Smith wrote:

                  You know what they say about common sense, right...

                  It's incredibly common and everyone has it? Yes, we know already!!! :-D :-D :-D

                  1 Reply Last reply
                  0
                  • J Josh Smith

                    Marc Clifton wrote:

                    The rest is just style, common sense, and coding rules.

                    You know what they say about common sense, right... :)

                    :josh: My WPF Blog[^] Without a strive for perfection I would be terribly bored.

                    M Offline
                    M Offline
                    Marc Clifton
                    wrote on last edited by
                    #25

                    Josh Smith wrote:

                    You know what they say about common sense, right...

                    Yeah, if cents were common I'd be a rich man. :) Marc

                    Thyme In The Country
                    Interacx
                    My Blog

                    1 Reply Last reply
                    0
                    • H Hans Dietrich

                      #1. Maintainability #2. Reusability #3. Extensibility

                      Best wishes, Hans


                      [CodeProject Forum Guidelines] [How To Ask A Question] [My Articles]

                      M Offline
                      M Offline
                      Mark Salsbery
                      wrote on last edited by
                      #26

                      I agree 100% Isn't that the "Three Cs of Good Programming" ? C was as good a letter as any. MArk

                      Mark Salsbery Microsoft MVP - Visual C++ :java:

                      H 1 Reply Last reply
                      0
                      • M Marc Clifton

                        A good design goes a long way toward making good code. The rest is just style, common sense, and coding rules. [edit] And if you continue the analogy, a good set of requirements makes for good design, and a good set of requirements comes from a good relationship with the client. Therefore, good code starts with a good client. [edit] Marc

                        Thyme In The Country
                        Interacx
                        My Blog

                        J Offline
                        J Offline
                        Jim Crafton
                        wrote on last edited by
                        #27

                        Marc Clifton wrote:

                        The rest is just style, common sense

                        I would associate these two with aesthetics. And I would then say that many people either choose not to have any or just willfully ignore it. And their code suffers accordingly.

                        ¡El diablo está en mis pantalones! ¡Mire, mire! Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)! SELECT * FROM User WHERE Clue > 0 0 rows returned Save an Orange - Use the VCF! VCF Blog

                        1 Reply Last reply
                        0
                        • J Josh Smith

                          Jim Crafton wrote:

                          I simply use my amazing mentat training

                          Perhaps you need some more "mentat" training Your Majesty. :laugh:

                          :josh: My WPF Blog[^] Without a strive for perfection I would be terribly bored.

                          J Offline
                          J Offline
                          Jim Crafton
                          wrote on last edited by
                          #28

                          Hey now! Watch that tone - let's have some proper respect here! :)

                          ¡El diablo está en mis pantalones! ¡Mire, mire! Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)! SELECT * FROM User WHERE Clue > 0 0 rows returned Save an Orange - Use the VCF! VCF Blog

                          J 1 Reply Last reply
                          0
                          • E El Corazon

                            Josh Smith wrote:

                            Too many comments make it difficult to read the code, too few comments force you to read code

                            This is true of all parts that you listed. Consistency is nice, but when consistant naming conventions use: int Volume_of_Fuel_for_Onboard_Motor_Sensor_of_Aircraft_Taco_Wing_from_Hanger15=0; too much of anything is a bad thing. Too much emphasis on design and future upgradeability, with little emphasis on functionality is bad, so can the reverse. Too much detail, or not enough detail in variables or comments each will be a bad thing. So my theory on good code can be broken down into one word: Balance. Get the point across, be succinct, not wordy, but be accurate and very clear about what is what. Comments, or code. Styles should be rapidly readable to much elegance can crowd the screen (I have heard requests for 4 spaces before and after {} which means 8 spaces for every open/close). Too much freedom of saying, "they just buy bigger hardware if it isn't fast enough" or too much focus on squeezing the last cpu cycle out of a CISC turnip processor. Too much of anything can be bad. well, except pay, they are welcome to pay me more to test that theory anytime.

                            _________________________ Asu no koto o ieba, tenjo de nezumi ga warau. Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)

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

                            A field declaration like that would also demonstrate a complete lack of understanding of OO and arrays I think! :-D


                            I'm largely language agnostic


                            After a while they all bug me :doh:


                            E 1 Reply Last reply
                            0
                            • J Josh Smith

                              What do you think makes some code better than other code? I don't necessarily mean "good" in the sense that it is bug-free, that's a pipe dream. What are the most important things to you when working with code? I think the following attributes are always found in code I consider to be good: 1) Consistency - The coding styles, naming conventions, usage of patterns, etc. are adhered to throughout the codebase. If your team prefixes private fields with an underscore, all private fields should start with "_". 2) Thoughtful naming - The names of things should accurately convey their purpose. I find that some of the best programmers I know dwell on a method name, or class name, or field name for a long time if necessary. 3) Smart comments - Too many comments make it difficult to read the code, too few comments force you to read code which could easily be summarized in one sentence. I think that all non-private members of a type should be commented, all types should have a comment explaining their purpose, and any tricky/hacky/weird code should be verbosely commented. What about you?

                              :josh: My WPF Blog[^] Without a strive for perfection I would be terribly bored.

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

                              Josh Smith wrote:

                              What makes code good?

                              Code is good when it is: 1) Robust. 2) Efficient (when it matters, of course). 3) Easy to understand. 4) Easy to modify.


                              Programming Blog utf8-cpp

                              1 Reply Last reply
                              0
                              • M MidwestLimey

                                A field declaration like that would also demonstrate a complete lack of understanding of OO and arrays I think! :-D


                                I'm largely language agnostic


                                After a while they all bug me :doh:


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

                                MidwestLimey wrote:

                                A field declaration like that would also demonstrate a complete lack of understanding of OO and arrays I think!

                                well, the same thing can happen in OO use as well. full->indirection->can->go->to->far->in->many->cases->as->well->as->declaritive->variables you name your worst coding nightmare, I have seen it. :)

                                _________________________ Asu no koto o ieba, tenjo de nezumi ga warau. Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)

                                1 Reply Last reply
                                0
                                • J Josh Smith

                                  What do you think makes some code better than other code? I don't necessarily mean "good" in the sense that it is bug-free, that's a pipe dream. What are the most important things to you when working with code? I think the following attributes are always found in code I consider to be good: 1) Consistency - The coding styles, naming conventions, usage of patterns, etc. are adhered to throughout the codebase. If your team prefixes private fields with an underscore, all private fields should start with "_". 2) Thoughtful naming - The names of things should accurately convey their purpose. I find that some of the best programmers I know dwell on a method name, or class name, or field name for a long time if necessary. 3) Smart comments - Too many comments make it difficult to read the code, too few comments force you to read code which could easily be summarized in one sentence. I think that all non-private members of a type should be commented, all types should have a comment explaining their purpose, and any tricky/hacky/weird code should be verbosely commented. What about you?

                                  :josh: My WPF Blog[^] Without a strive for perfection I would be terribly bored.

                                  A Offline
                                  A Offline
                                  Abu Mami
                                  wrote on last edited by
                                  #32

                                  classic rock (loud) beer pizza

                                  D 1 Reply Last reply
                                  0
                                  • R Rama Krishna Vavilala

                                    Currently, I am reading this book: Beautiful Code[^]. I must say that content wise it is one of the best books I have read. I will rank it high up with books: Code Complete, Design Patterns and Refactoring.

                                    Josh Smith wrote:

                                    Thoughtful naming

                                    Agreed! To me intent code should be just be obvious by reading it. If the code adheres to well known patterns things are a lot easier.

                                    Josh Smith wrote:

                                    I think that all non-private members of a type should be commented

                                    The tricky parts always should have comments. But I hate comment clutter. I personally hate XML comments (javadoc is a little better) and I wish if there was an alternative. When you publish an API all public members should be documented but I necessarily don't agree that they should have comments on top of them. For example, I hate comments likes these if they appear everywhere and just convey the obvious. However, for something not very obvious things have to be commented.

                                    public class Employee
                                    {
                                    ///
                                    /// Gets or sets the employee name
                                    ///
                                    public string Name
                                    {
                                    get {return this.name; }
                                    set { this.name = value; }
                                    }

                                    ///
                                    /// Call this method to increase the salary of the employee
                                    ///
                                    public void IncreaseSalary(double salary)
                                    {
                                    ....
                                    }

                                    }

                                    Another thing issue I have seen is sometimes you may use a well known design pattern and the meaning may not be obvious to some programmers but programmers who have read the design patterns book may immediately recognize the pattern and understand how the code works. In such a case I think I will prefer programmer education rather than cluttering the code.

                                    Co-Author ASP.NET AJAX in Action

                                    B Offline
                                    B Offline
                                    Big Daddy Farang
                                    wrote on last edited by
                                    #33

                                    Rama Krishna Vavilala wrote:

                                    But I hate comment clutter.

                                    I agree. Years ago in a previous career, I worked with a wise, old man who taught me what has become a valuable lesson: It is better to smoke no cigar than a bad cigar. I have adapted this to many different situations. It is better to write no comment than a bad comment. Like your examples of comments that add no value to the code.

                                    Rama Krishna Vavilala wrote:

                                    In such a case I think I will prefer programmer education rather than cluttering the code.

                                    Agree with this, also. It might be nice to include a reference to the book in case like this. BDF

                                    1 Reply Last reply
                                    0
                                    • E El Corazon

                                      Josh Smith wrote:

                                      Too many comments make it difficult to read the code, too few comments force you to read code

                                      This is true of all parts that you listed. Consistency is nice, but when consistant naming conventions use: int Volume_of_Fuel_for_Onboard_Motor_Sensor_of_Aircraft_Taco_Wing_from_Hanger15=0; too much of anything is a bad thing. Too much emphasis on design and future upgradeability, with little emphasis on functionality is bad, so can the reverse. Too much detail, or not enough detail in variables or comments each will be a bad thing. So my theory on good code can be broken down into one word: Balance. Get the point across, be succinct, not wordy, but be accurate and very clear about what is what. Comments, or code. Styles should be rapidly readable to much elegance can crowd the screen (I have heard requests for 4 spaces before and after {} which means 8 spaces for every open/close). Too much freedom of saying, "they just buy bigger hardware if it isn't fast enough" or too much focus on squeezing the last cpu cycle out of a CISC turnip processor. Too much of anything can be bad. well, except pay, they are welcome to pay me more to test that theory anytime.

                                      _________________________ Asu no koto o ieba, tenjo de nezumi ga warau. Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)

                                      S Offline
                                      S Offline
                                      StevenWalsh
                                      wrote on last edited by
                                      #34

                                      El Corazon wrote:

                                      int Volume_of_Fuel_for_Onboard_Motor_Sensor_of_Aircraft_Taco_Wing_from_Hanger15=0;

                                      Hey its an aircraft... you might think about copy and pasting that name a few times to make sure its redendent enough not to make a mistake :)

                                      E 1 Reply Last reply
                                      0
                                      • S StevenWalsh

                                        El Corazon wrote:

                                        int Volume_of_Fuel_for_Onboard_Motor_Sensor_of_Aircraft_Taco_Wing_from_Hanger15=0;

                                        Hey its an aircraft... you might think about copy and pasting that name a few times to make sure its redendent enough not to make a mistake :)

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

                                        StevenWalsh wrote:

                                        you might think about copy and pasting that name a few times to make sure its redendent enough not to make a mistake

                                        naw, just copy and paste the entire routine for filling one tank into another routine to fill the other tank, or better yet, copy and past the whole thing into main!

                                        _________________________ Asu no koto o ieba, tenjo de nezumi ga warau. Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)

                                        1 Reply Last reply
                                        0
                                        • J Jim Crafton

                                          Hey now! Watch that tone - let's have some proper respect here! :)

                                          ¡El diablo está en mis pantalones! ¡Mire, mire! Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)! SELECT * FROM User WHERE Clue > 0 0 rows returned Save an Orange - Use the VCF! VCF Blog

                                          J Offline
                                          J Offline
                                          Judah Gabriel Himango
                                          wrote on last edited by
                                          #36

                                          Ego sum rex VCF et super grammaticam ;) (that is, you are the king of VCF, and are above grammar)

                                          Tech, life, family, faith: Give me a visit. I'm currently blogging about: Minnesota Bridge Collapses The apostle Paul, modernly speaking: Epistles of Paul Judah Himango

                                          J 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