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. Quality of code

Quality of code

Scheduled Pinned Locked Moved The Lounge
tools
47 Posts 29 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.
  • G Gary Wheeler

    Hans Dietrich wrote:

    "coding hall of shame" on an internal web site

    That is an awesome idea.

    Software Zen: delete this;

    T Offline
    T Offline
    Tomas Scheel
    wrote on last edited by
    #29

    I second that. Perhaps we should have a coding hall of shame here on codeproject...

    W D 2 Replies Last reply
    0
    • L Lukas_J

      I have heard such arguments many times. "...Why he couldn't give me his code on a silver plate..." People often think that if you find someone elses code they can take it. People don't take under consideration that some one put a lot of work in developing that code. So what that they use not very clear naming conventions so they don't put comments, they use goto. It's theirs choise becouse this is theirs code. When I develop something I really don't care if some one in the future will have problem reading it and understanding (if you want to use my work that's fine with me but I wan't you to work for it ;p to understand it, not just scroll thrugh it and decide - "that's it"). People tend to use things they have no idea of and if something goes wrong the blame the author. IF U DON'T KNOW WHAT IT IS THEN DON'T TUCH IT!!! this is what I'm always telling people. Take you time, study it, learn as much as posible about the thing and if after all that you'll don't understand how it works then I think it's time to realize this "toy" is not for you. Yes comments help. Nowdays people can do online and literaly copy paste someone elses work not even bothering to really study it. I myself avoid putting comments in my code. When I add them during development I remove them at the end. Comments, coding conventions, etc. ... they bind you to a schema. It's a lot more fun to code intuitively, to follow your guts when coding, when reading code samples without comments =].

      S Offline
      S Offline
      shiftedbitmonkey
      wrote on last edited by
      #30

      You are off topic. If you don't want other's messing with your code, then don't open source it! :rolleyes: If you are releasing your source as open source, you are inviting criticism.

      I've heard more said about less.

      L 1 Reply Last reply
      0
      • M Matt Totten

        And those of us who get a 10 year old piece of software dropped in our lap with almost no comments appreciate your efforts! I've had an awfully frustrating time the last couple of months tracing through reams of code for hours just to figure out what is happening. One of the most common phrases to come out of my mouth is, "What on Earth were they thinking?" :omg: I'm with you, John. I hope that the legacy I leave behind for the next person is one of less frustration than I've had. :cool:

        D Offline
        D Offline
        DrFrankenstein90
        wrote on last edited by
        #31

        Matt Totten wrote:

        And those of us who get a 10 year old piece of software dropped in our lap with almost no comments appreciate your efforts! I've had an awfully frustrating time the last couple of months tracing through reams of code for hours just to figure out what is happening.

        I have to deal with that at work. For some reason my boss understands the code right away. Well, not me.

        1 Reply Last reply
        0
        • T Tomas Scheel

          I second that. Perhaps we should have a coding hall of shame here on codeproject...

          W Offline
          W Offline
          wieczo yo
          wrote on last edited by
          #32

          I love the Daily WTF. You can see there many examples how not to do it.

          T 1 Reply Last reply
          0
          • W wieczo yo

            I love the Daily WTF. You can see there many examples how not to do it.

            T Offline
            T Offline
            Tomas Scheel
            wrote on last edited by
            #33

            I like that site as well. Always good to remind yourself that you aren't as dumb as you may have thought...

            1 Reply Last reply
            0
            • T Tomas Scheel

              I second that. Perhaps we should have a coding hall of shame here on codeproject...

              D Offline
              D Offline
              Dan Neely
              wrote on last edited by
              #34

              You mean like this...[^]

              Today's lesson is brought to you by the word "niggardly". Remember kids, don't attribute to racism what can be explained by Scandinavian language roots. -- Robert Royall

              1 Reply Last reply
              0
              • J John M Drescher

                Well except for the short variable names, I would consider this well written and well doccumented code.

                John

                C Offline
                C Offline
                cpkilekofp
                wrote on last edited by
                #35

                John M. Drescher wrote:

                Well except for the short variable names, I would consider this well written and well doccumented code.

                I would tend to agree. I also think that a good find/replace of 2-char names with meaningful names would be a worthwhile effort. It's not that the code is bad or poorly documented, it's just that it could be more readable. Comments should elucidate the code, they should not be necessary to explain every piece of it, not in a language that supports at least 32 characters for each identifier.

                1 Reply Last reply
                0
                • R realJSOP

                  I'm not worried about what the client thinks. I'm concerned about what maintenance programmers have to deal with.

                  "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

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

                  John Simmons / outlaw programmer wrote:

                  I'm concerned about what maintenance programmers have to deal with.

                  I am too. Unfortunately, most programmers seem not to be. Maybe it's the attitude of "what do I care, I'll only be here for a few months or a year or so at most."

                  Kevin

                  1 Reply Last reply
                  0
                  • A Alan Balkany

                    A lot of "professional" code is surprisingly bad. In my opinion many factors contribute to this: 1. In school, most (but not all) instructors don't place any value on code readability and maintainability; you get the grade if your code works. 2. In industry, managers usually only care if the code works. There's no incentive to write "good" code. 3. In industry, there is usually time pressure to complete projects, so the emphasis is on getting it done, and quality is sacrificed. 4. Time pressure also leaves no time for code reviews. 5. Software is a relatively recent engineering discipline, so standards haven't completely emerged. While most programmers know you should have comments, clear variable names, and avoid gotos, I'm often surprised how few programmers know the value of short functions. A function's complexity increases faster than linearly with respect to its length. If a function doubles in length, its complexity more than doubles. In my opinion, the underlying goal of all these heuristics is clarity. Clear code can be modified faster and with confidence. It's more reliable, and can be debugged faster. And that's a major difference between engineering and hacking.

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

                    Alan Balkany wrote:

                    I'm often surprised how few programmers know the value of short functions.

                    I am too.

                    Kevin

                    1 Reply Last reply
                    0
                    • S shiftedbitmonkey

                      You are off topic. If you don't want other's messing with your code, then don't open source it! :rolleyes: If you are releasing your source as open source, you are inviting criticism.

                      I've heard more said about less.

                      L Offline
                      L Offline
                      Lukas_J
                      wrote on last edited by
                      #38

                      I wanted just to point out the fact that we are all used to get everything the easy way(tons of comments, etc). What I'm trying to say is - even if someone releses his code as open source without comments or with funny naming conventions =] he is still giving us his work for free. And the least we can do is not to jump on the creator of the code for not writing his code as we like it. As for the topic of open cource. I think it's one of the best ways to expand our knowledge. We all must keep in mind that there were programmers long before us (especially before me) and they all had the same problems and solved them. They share their knowledge with us so we can build on top of it and pushing forward. Many programmers have their own way of doing things and it's hard to get rid of the habbits ;) (I for example love to work at night. Others dont't put comments :-D ). I never had problems with shearing my code with others (and my coding technic is creazy :D ) but not once I've heard arguments like those in the first post. Buttom line - If someone gave us his code lets not point out what we think is wrong but be greatfull to him for shearing his knowledge with us. PS. I may be still of topic a little but... :)

                      S 1 Reply Last reply
                      0
                      • R realJSOP

                        I downloaded the source code to ffmpeg (written entirely in C), and was perusing the code associated with the ffplay utility. 0) The variable naming conventions they use quite frankly suck. The names they use rarely indicate what they might represent, and most of them are limited to just two letters. 1) There are almost NO comments. Well, there are so few comments as to validate the claim of "no comments", but since there are a few comments, and since programmers by their nature are a pedantic lot, "almost no comments" is technically the more correct phrasing. 2) They made widespread use of the much hated goto. I don't know why, but I'm completely surprised at the almost complete lack of comments and the variable naming convention.

                        "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

                        S Offline
                        S Offline
                        saqib ku
                        wrote on last edited by
                        #39

                        That's really a dilemma

                        Najm Us Saqib Web Developer http://dreamxtream.wordpress.com

                        1 Reply Last reply
                        0
                        • L Lukas_J

                          I wanted just to point out the fact that we are all used to get everything the easy way(tons of comments, etc). What I'm trying to say is - even if someone releses his code as open source without comments or with funny naming conventions =] he is still giving us his work for free. And the least we can do is not to jump on the creator of the code for not writing his code as we like it. As for the topic of open cource. I think it's one of the best ways to expand our knowledge. We all must keep in mind that there were programmers long before us (especially before me) and they all had the same problems and solved them. They share their knowledge with us so we can build on top of it and pushing forward. Many programmers have their own way of doing things and it's hard to get rid of the habbits ;) (I for example love to work at night. Others dont't put comments :-D ). I never had problems with shearing my code with others (and my coding technic is creazy :D ) but not once I've heard arguments like those in the first post. Buttom line - If someone gave us his code lets not point out what we think is wrong but be greatfull to him for shearing his knowledge with us. PS. I may be still of topic a little but... :)

                          S Offline
                          S Offline
                          shiftedbitmonkey
                          wrote on last edited by
                          #40

                          Again. If you release your code as open source, you are inviting criticism. Whether that criticism is over the algorithm you used for problem 'x' or whether you use intuitive naming conventions and comment what's going on.

                          Lukas_J wrote:

                          Buttom line - If someone gave us his code lets not point out what we think is wrong but be greatfull to him for shearing his knowledge with us.

                          No. I will criticize what I see, hopefully constructively, so that we may improve. How can I be grateful if I don't understand what I see without reverse engineering? Most of the time I appreciate open source so I can learn something. Not so I can get some code for free to solve my problem. If that was the case I wouldn't care as much about the code, just the binary. So, while I appreciate you defending the contributer, I think you misinterpret constructive criticism for attacks.

                          I've heard more said about less.

                          L 1 Reply Last reply
                          0
                          • L Lukas_J

                            I have heard such arguments many times. "...Why he couldn't give me his code on a silver plate..." People often think that if you find someone elses code they can take it. People don't take under consideration that some one put a lot of work in developing that code. So what that they use not very clear naming conventions so they don't put comments, they use goto. It's theirs choise becouse this is theirs code. When I develop something I really don't care if some one in the future will have problem reading it and understanding (if you want to use my work that's fine with me but I wan't you to work for it ;p to understand it, not just scroll thrugh it and decide - "that's it"). People tend to use things they have no idea of and if something goes wrong the blame the author. IF U DON'T KNOW WHAT IT IS THEN DON'T TUCH IT!!! this is what I'm always telling people. Take you time, study it, learn as much as posible about the thing and if after all that you'll don't understand how it works then I think it's time to realize this "toy" is not for you. Yes comments help. Nowdays people can do online and literaly copy paste someone elses work not even bothering to really study it. I myself avoid putting comments in my code. When I add them during development I remove them at the end. Comments, coding conventions, etc. ... they bind you to a schema. It's a lot more fun to code intuitively, to follow your guts when coding, when reading code samples without comments =].

                            J Offline
                            J Offline
                            jschell
                            wrote on last edited by
                            #41

                            Lukas_J wrote:

                            Comments, coding conventions, etc. ... they bind you to a schema. It's a lot more fun to code intuitively, to follow your guts when coding, when reading code samples without comments

                            As a professional programmer my role entails more than just "fun". I need to produce code that not only works now but which is maintainable in the future. I recognize, because I have seen the studies, that maintaince costs anywhere from 1 to 10 times as much as the original product cost. Thus I feel it is my responsibility to do the best I can to reduce that very real future cost. I also understand that not only are not all programmers geniuses but in fact that very likely I am not as smart as I think I am either. Thus although my code might seem blinding obvious to me it might be a muddled mess to some future programmer. Thus I do code in a way which should help rather than hinder maintainance. And myself I consider it "fun" when I receive compliments on how easy my code is to maintain months and even years after I last touched it.

                            1 Reply Last reply
                            0
                            • S shiftedbitmonkey

                              Again. If you release your code as open source, you are inviting criticism. Whether that criticism is over the algorithm you used for problem 'x' or whether you use intuitive naming conventions and comment what's going on.

                              Lukas_J wrote:

                              Buttom line - If someone gave us his code lets not point out what we think is wrong but be greatfull to him for shearing his knowledge with us.

                              No. I will criticize what I see, hopefully constructively, so that we may improve. How can I be grateful if I don't understand what I see without reverse engineering? Most of the time I appreciate open source so I can learn something. Not so I can get some code for free to solve my problem. If that was the case I wouldn't care as much about the code, just the binary. So, while I appreciate you defending the contributer, I think you misinterpret constructive criticism for attacks.

                              I've heard more said about less.

                              L Offline
                              L Offline
                              Lukas_J
                              wrote on last edited by
                              #42

                              shiftedbitmonkey wrote:

                              So, while I appreciate you defending the contributer, I think you misinterpret constructive criticism for attacks.

                              I've looked over posts serval times and I realize you are right. I misinterpreted criticism for attacks mainly becouse I never look for ready answers but rather for inspiration in others code (that's why I never cared about missing comments etc, but I do care about the idea behind the code). And I will always honor programmers choice of not puting comments or using cryptic naming in his code. It's his work and It is he who will shape it as he pleases for us it's just an inspiration.

                              S 1 Reply Last reply
                              0
                              • L Lukas_J

                                shiftedbitmonkey wrote:

                                So, while I appreciate you defending the contributer, I think you misinterpret constructive criticism for attacks.

                                I've looked over posts serval times and I realize you are right. I misinterpreted criticism for attacks mainly becouse I never look for ready answers but rather for inspiration in others code (that's why I never cared about missing comments etc, but I do care about the idea behind the code). And I will always honor programmers choice of not puting comments or using cryptic naming in his code. It's his work and It is he who will shape it as he pleases for us it's just an inspiration.

                                S Offline
                                S Offline
                                shiftedbitmonkey
                                wrote on last edited by
                                #43

                                Lukas_J wrote:

                                And I will always honor programmers choice of not puting comments or using cryptic naming in his code. It's his work and It is he who will shape it as he pleases for us it's just an inspiration.

                                Its not about honoring his/her code. I'm honoring the code by providing constructive criticism. By pointing out how it could be better I'm honoring the author. It would be a dishonor to blithely ignore the quality gushing over the fact that its released as open. Again, if you release your source to the public, in my opinion it should be readable. If the naming convention is cryptic, then comments are a necessity. If only to derail misinterpretations. I've forgotten logic driving some of the code I've written 6 months back. Sure I figured it out, but if I wasn't too lazy to comment the thing it would have saved me time trying to remember what the hell I was thinking.

                                Lukas_J wrote:

                                but rather for inspiration in others code

                                How can you be inspired if you don't understand what you're looking at? For instance... get inspired by this:

                                for (i=0, k=0; i < N && k < NW; k++)
                                for (j=0; j < NF && i < N; j++, i++)
                                {
                                ttym[i] = M(tty[i]);
                                rm.fds_b[k] |= ttym[i];
                                }

                                I've heard more said about less.

                                L 1 Reply Last reply
                                0
                                • S shiftedbitmonkey

                                  Lukas_J wrote:

                                  And I will always honor programmers choice of not puting comments or using cryptic naming in his code. It's his work and It is he who will shape it as he pleases for us it's just an inspiration.

                                  Its not about honoring his/her code. I'm honoring the code by providing constructive criticism. By pointing out how it could be better I'm honoring the author. It would be a dishonor to blithely ignore the quality gushing over the fact that its released as open. Again, if you release your source to the public, in my opinion it should be readable. If the naming convention is cryptic, then comments are a necessity. If only to derail misinterpretations. I've forgotten logic driving some of the code I've written 6 months back. Sure I figured it out, but if I wasn't too lazy to comment the thing it would have saved me time trying to remember what the hell I was thinking.

                                  Lukas_J wrote:

                                  but rather for inspiration in others code

                                  How can you be inspired if you don't understand what you're looking at? For instance... get inspired by this:

                                  for (i=0, k=0; i < N && k < NW; k++)
                                  for (j=0; j < NF && i < N; j++, i++)
                                  {
                                  ttym[i] = M(tty[i]);
                                  rm.fds_b[k] |= ttym[i];
                                  }

                                  I've heard more said about less.

                                  L Offline
                                  L Offline
                                  Lukas_J
                                  wrote on last edited by
                                  #44

                                  shiftedbitmonkey wrote:

                                  Its not about honoring his/her code. I'm honoring the code by providing constructive criticism. By pointing out how it could be better I'm honoring the author.

                                  I dont't want to be rude but pointing out to the author that his code can be better if he adds more commnets or he'll use better names... From the technical point of view the code its functionality, its ability to do its wark faster more efficient is pointless. Coders are individuals and they always do things their way =]. I gues we are like elderly people :) we do things our way and don't even try to tell us it's the wrong way :laugh: . In many cases when you try to improve someones code by pointing out variuos flaws in logic like use Lists instead of arrays or use stored procedures instead of tons of selects to improve performence is done after consutling wiht author. But even then if you only talk about commnets ,guy will look at you and most likely say something like "...GET OUT BEFORE I @#$@! YOU..." :laugh: . So in my opinion pointing out missing commnets is usless. As for the last part of Your reply:

                                  shiftedbitmonkey wrote:

                                  How can you be inspired if you don't understand what you're looking at? For instance... get inspired by this:

                                  for (i=0, k=0; i < N && k < NW; k++)
                                  for (j=0; j < NF && i < N; j++, i++)
                                  {
                                  ttym[i] = M(tty[i]);
                                  rm.fds_b[k] |= ttym[i];
                                  }

                                  I would like to answer your question with my own: If I show You best page from the best book ever written will you be understand the book?? Code You opsted is just a loop and while I agree with You that variables are unreadable the fact is this is just a part of a code taken out of context. But if I would look at that loop about 5 - 6 years ago I would learn that I can write not only standard for loops but even more complicated ones like the one you provided. I wouldn't understand the whole concept (becouse I don't see the whole picture) however it's not the point with open source becouse You always see everything. ;)

                                  S 1 Reply Last reply
                                  0
                                  • L Lukas_J

                                    shiftedbitmonkey wrote:

                                    Its not about honoring his/her code. I'm honoring the code by providing constructive criticism. By pointing out how it could be better I'm honoring the author.

                                    I dont't want to be rude but pointing out to the author that his code can be better if he adds more commnets or he'll use better names... From the technical point of view the code its functionality, its ability to do its wark faster more efficient is pointless. Coders are individuals and they always do things their way =]. I gues we are like elderly people :) we do things our way and don't even try to tell us it's the wrong way :laugh: . In many cases when you try to improve someones code by pointing out variuos flaws in logic like use Lists instead of arrays or use stored procedures instead of tons of selects to improve performence is done after consutling wiht author. But even then if you only talk about commnets ,guy will look at you and most likely say something like "...GET OUT BEFORE I @#$@! YOU..." :laugh: . So in my opinion pointing out missing commnets is usless. As for the last part of Your reply:

                                    shiftedbitmonkey wrote:

                                    How can you be inspired if you don't understand what you're looking at? For instance... get inspired by this:

                                    for (i=0, k=0; i < N && k < NW; k++)
                                    for (j=0; j < NF && i < N; j++, i++)
                                    {
                                    ttym[i] = M(tty[i]);
                                    rm.fds_b[k] |= ttym[i];
                                    }

                                    I would like to answer your question with my own: If I show You best page from the best book ever written will you be understand the book?? Code You opsted is just a loop and while I agree with You that variables are unreadable the fact is this is just a part of a code taken out of context. But if I would look at that loop about 5 - 6 years ago I would learn that I can write not only standard for loops but even more complicated ones like the one you provided. I wouldn't understand the whole concept (becouse I don't see the whole picture) however it's not the point with open source becouse You always see everything. ;)

                                    S Offline
                                    S Offline
                                    shiftedbitmonkey
                                    wrote on last edited by
                                    #45

                                    Clearly we just disagree. I don't find anything wrong with the criticism and you do. Why so sensitive? Anyway, I'm done with this thread. Have a good day.

                                    I've heard more said about less.

                                    L 1 Reply Last reply
                                    0
                                    • S shiftedbitmonkey

                                      Clearly we just disagree. I don't find anything wrong with the criticism and you do. Why so sensitive? Anyway, I'm done with this thread. Have a good day.

                                      I've heard more said about less.

                                      L Offline
                                      L Offline
                                      Lukas_J
                                      wrote on last edited by
                                      #46

                                      True, we have different points of view =]. I also have nothing against criticism, as long as it's aiming at the code and it can improve the code, and I don't mean improving by adding comments or changing names =] ( as I wrote earlyer I find this kind of help pointles). I enjoyed our conversation and I realy aprishiate your opinions on the subject.

                                      S 1 Reply Last reply
                                      0
                                      • L Lukas_J

                                        True, we have different points of view =]. I also have nothing against criticism, as long as it's aiming at the code and it can improve the code, and I don't mean improving by adding comments or changing names =] ( as I wrote earlyer I find this kind of help pointles). I enjoyed our conversation and I realy aprishiate your opinions on the subject.

                                        S Offline
                                        S Offline
                                        shiftedbitmonkey
                                        wrote on last edited by
                                        #47

                                        I said I was done, but since you reiterated your point...

                                        Lukas_J wrote:

                                        , as long as it's aiming at the code and it can improve the code

                                        That's not how it works.

                                        Lukas_J wrote:

                                        ( as I wrote earlyer I find this kind of help pointles).

                                        Its not about you. The main point for submitting source as open is to be part of a community. Effective communication is key when working on a team. If you submit your source to the community expect criticism regarding readability aimed at maintenance and understanding what's going on under the hood. Just release the binaries if you want to share the code but not the source. You forfeit your right to avoid criticism regarding readability when you join the community and offer up your writing to others. Go ahead and drop in another last word reiterating that you don't like this style of criticism. I'm wondering how much real world experience you have working on teams. Based on your views expressed, I wouldn't want to work on the same code base as you. And to satisfy the spelling pedant inside me:

                                        Lukas_J wrote:

                                        aprishiate

                                        Appreciate.

                                        Lukas_J wrote:

                                        as I wrote earlyer I find this kind of help pointles

                                        Earlier. Pointless.

                                        I've heard more said about less.

                                        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