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 is good code?

What is good code?

Scheduled Pinned Locked Moved The Lounge
questiondiscussion
104 Posts 39 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.
  • E Espen Harlinn

    The original point was that code works as designed Basicly coding is design work, and can be seen as the last iteration of the whole design process.

    Espen Harlinn Principal Architect, Software - Goodtech Projects & Services AS My LinkedIn Profile

    C Offline
    C Offline
    CPallini
    wrote on last edited by
    #57

    Espen Harlinn wrote:

    Basicly coding is design work, and can be seen as the last iteration of the whole design process.

    Yes it can seen like that. Simply I don't see it like that.

    Veni, vidi, vici.

    E 1 Reply Last reply
    0
    • C CPallini

      Espen Harlinn wrote:

      Basicly coding is design work, and can be seen as the last iteration of the whole design process.

      Yes it can seen like that. Simply I don't see it like that.

      Veni, vidi, vici.

      E Offline
      E Offline
      Espen Harlinn
      wrote on last edited by
      #58

      CPallini wrote:

      Yes it can seen like that. Simply I don't see it like that.

      Most people don't - personally I think it would be a good thing if they did.

      Espen Harlinn Principal Architect, Software - Goodtech Projects & Services AS My LinkedIn Profile

      1 Reply Last reply
      0
      • S Slacker007

        Who determines if your code is good? What is good code and what are the precise criteria for giving it a status of "good"? Since most of your code will never be reviewed by your peers (outside of work) then how do you know it is worth a damn, really? If I think your code sucks but the next guy thinks it is good, then who is right? This kind of goes in line with my other thoughts about the "greatness" of an individual programmer. Who determines that a person is a great programmer and that person writes some damn good code? You? Me? None of the above? We obviously cannot make this determination about ourselves or our code. So who does?

        "the meat from that butcher is just the dogs danglies, absolutely amazing cuts of beef." - DaveAuld (2011)
        "No, that is just the earthly manifestation of the Great God Retardon." - Nagy Vilmos (2011) "It is the celestial scrotum of good luck!" - Nagy Vilmos (2011) "But you probably have the smoothest scrotum of any grown man" - Pete O'Hanlon (2012)

        S Offline
        S Offline
        Single Step Debugger
        wrote on last edited by
        #59

        Good code is a little code. If I see you’ve achieved the goal with minimum efforts in coding and maximum in thinking, for me you’re okay and I’ll be glad to work with you.

        There is only one Vera Farmiga and Salma Hayek is her prophet! Advertise here – minimum three posts per day are guaranteed.

        1 Reply Last reply
        0
        • C Chris Meech

          This so spot on. Good code is in part measured by how it is used. I don't often bookmark posts, but I did yours. It needs to be re-iterated every time someone asks again about code quality and how to determine it. :)

          Chris Meech I am Canadian. [heard in a local bar] In theory there is no difference between theory and practice. In practice there is. [Yogi Berra] posting about Crystal Reports here is like discussing gay marriage on a catholic church’s website.[Nishant Sivakumar]

          G Offline
          G Offline
          Gary R Wheeler
          wrote on last edited by
          #60

          Thanks, Chris. After 30 years doing a job, and making and cleaning up a fair share of messes, you figure a few things out.

          Software Zen: delete this;

          1 Reply Last reply
          0
          • S Slacker007

            Who determines if your code is good? What is good code and what are the precise criteria for giving it a status of "good"? Since most of your code will never be reviewed by your peers (outside of work) then how do you know it is worth a damn, really? If I think your code sucks but the next guy thinks it is good, then who is right? This kind of goes in line with my other thoughts about the "greatness" of an individual programmer. Who determines that a person is a great programmer and that person writes some damn good code? You? Me? None of the above? We obviously cannot make this determination about ourselves or our code. So who does?

            "the meat from that butcher is just the dogs danglies, absolutely amazing cuts of beef." - DaveAuld (2011)
            "No, that is just the earthly manifestation of the Great God Retardon." - Nagy Vilmos (2011) "It is the celestial scrotum of good luck!" - Nagy Vilmos (2011) "But you probably have the smoothest scrotum of any grown man" - Pete O'Hanlon (2012)

            T Offline
            T Offline
            TheGreatAndPowerfulOz
            wrote on last edited by
            #61

            Good code follows these 4 principles: 1. It works and gets the job done. 2. It is the least code that will do the job and no more. 3. It is efficient and performant. 4. It is easy to maintain and extend. These are all things that any programmer worth his salt can do for himself. If you can't ensure your code follows these simple principles then get a different profession.

            If your actions inspire others to dream more, learn more, do more and become more, you are a leader." - John Quincy Adams
            You must accept one of two basic premises: Either we are alone in the universe, or we are not alone in the universe. And either way, the implications are staggering” - Wernher von Braun

            1 Reply Last reply
            0
            • S Slacker007

              Who determines if your code is good? What is good code and what are the precise criteria for giving it a status of "good"? Since most of your code will never be reviewed by your peers (outside of work) then how do you know it is worth a damn, really? If I think your code sucks but the next guy thinks it is good, then who is right? This kind of goes in line with my other thoughts about the "greatness" of an individual programmer. Who determines that a person is a great programmer and that person writes some damn good code? You? Me? None of the above? We obviously cannot make this determination about ourselves or our code. So who does?

              "the meat from that butcher is just the dogs danglies, absolutely amazing cuts of beef." - DaveAuld (2011)
              "No, that is just the earthly manifestation of the Great God Retardon." - Nagy Vilmos (2011) "It is the celestial scrotum of good luck!" - Nagy Vilmos (2011) "But you probably have the smoothest scrotum of any grown man" - Pete O'Hanlon (2012)

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

              Some people seem to be confusing what good code is and what a good developer is. They're not the same thing. A good developer has no problem writing substandard code. If it's a prototype, they might consider writing substandard code. Good code may be written by a bad developer (or a good developer making a bad decision). The code could be a shining example of excellence, but if it took too long and wasted an employer's time, it was a bad decision to write it so well. If the code isn't in source control, that's a bad decision for good code. As far as good code goes, that can vary based on context, but even some of the rules for contextually good code can be generalized:

              1. Code in the same style as the rest of the code base.
              2. The above can have exceptions. If you have a new code file and the rest of the code base has crap style, code your file in a better style to set a good example.
              3. Don't waste CPU cycles. Don't waste memory.
              4. Waste CPU cycles and memory when it will make the code much more clear or faster to write.
              5. Some code lives longer or is more widely used than other code. That code should have higher quality.
              6. Avoid security vulnerabilities (e.g., SQL injection).
              7. Code that makes use of other good code rather than reinventing the wheel is good code.
              8. As a corollary, avoid copy/paste code.
              9. Patterns are good, except when they're not. If the cost of the complexity is greater than the benefit it adds, it's not good.
              10. Code should be written to adapt to likely change. If you think a feature will be added later, leave room for it to be added without making it a breaking change.

              The list could go on and on and vary significantly depending on context.

              Thou mewling ill-breeding pignut!

              S 1 Reply Last reply
              0
              • Z ZurdoDev

                Just because code works, does not mean it is good.

                There are only 10 types of people in the world, those who understand binary and those who don't.

                R Offline
                R Offline
                realJSOP
                wrote on last edited by
                #63

                When you're on a tight schedule, if it was what it's supposed to do, it's "good" code. You guys are merely being pedantic, and are ignoring (or ignorant of) the realities of real-world development...

                ".45 ACP - because shooting twice is just silly" - JSOP, 2010
                -----
                You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
                -----
                "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

                S L Z 3 Replies Last reply
                0
                • S Slacker007

                  Who determines if your code is good? What is good code and what are the precise criteria for giving it a status of "good"? Since most of your code will never be reviewed by your peers (outside of work) then how do you know it is worth a damn, really? If I think your code sucks but the next guy thinks it is good, then who is right? This kind of goes in line with my other thoughts about the "greatness" of an individual programmer. Who determines that a person is a great programmer and that person writes some damn good code? You? Me? None of the above? We obviously cannot make this determination about ourselves or our code. So who does?

                  "the meat from that butcher is just the dogs danglies, absolutely amazing cuts of beef." - DaveAuld (2011)
                  "No, that is just the earthly manifestation of the Great God Retardon." - Nagy Vilmos (2011) "It is the celestial scrotum of good luck!" - Nagy Vilmos (2011) "But you probably have the smoothest scrotum of any grown man" - Pete O'Hanlon (2012)

                  N Offline
                  N Offline
                  Nueman
                  wrote on last edited by
                  #64

                  My users wear guns to work. I am still here. Therefore I write good code. Q.E.D ;P

                  What me worry?

                  1 Reply Last reply
                  0
                  • A AspDotNetDev

                    Some people seem to be confusing what good code is and what a good developer is. They're not the same thing. A good developer has no problem writing substandard code. If it's a prototype, they might consider writing substandard code. Good code may be written by a bad developer (or a good developer making a bad decision). The code could be a shining example of excellence, but if it took too long and wasted an employer's time, it was a bad decision to write it so well. If the code isn't in source control, that's a bad decision for good code. As far as good code goes, that can vary based on context, but even some of the rules for contextually good code can be generalized:

                    1. Code in the same style as the rest of the code base.
                    2. The above can have exceptions. If you have a new code file and the rest of the code base has crap style, code your file in a better style to set a good example.
                    3. Don't waste CPU cycles. Don't waste memory.
                    4. Waste CPU cycles and memory when it will make the code much more clear or faster to write.
                    5. Some code lives longer or is more widely used than other code. That code should have higher quality.
                    6. Avoid security vulnerabilities (e.g., SQL injection).
                    7. Code that makes use of other good code rather than reinventing the wheel is good code.
                    8. As a corollary, avoid copy/paste code.
                    9. Patterns are good, except when they're not. If the cost of the complexity is greater than the benefit it adds, it's not good.
                    10. Code should be written to adapt to likely change. If you think a feature will be added later, leave room for it to be added without making it a breaking change.

                    The list could go on and on and vary significantly depending on context.

                    Thou mewling ill-breeding pignut!

                    S Offline
                    S Offline
                    Slacker007
                    wrote on last edited by
                    #65

                    Your points are well made but I don't think you understood the point of my question. Some of the members who responded to my question, understood what I was trying to get to. Your list of 1-10 is what seems correct...for you. However, I don't agree with most of your list as criteria for good code. Does this mean I'm right? Of course not. Therein lies my point.

                    "the meat from that butcher is just the dogs danglies, absolutely amazing cuts of beef." - DaveAuld (2011)
                    "No, that is just the earthly manifestation of the Great God Retardon." - Nagy Vilmos (2011) "It is the celestial scrotum of good luck!" - Nagy Vilmos (2011) "But you probably have the smoothest scrotum of any grown man" - Pete O'Hanlon (2012)

                    A 1 Reply Last reply
                    0
                    • R realJSOP

                      When you're on a tight schedule, if it was what it's supposed to do, it's "good" code. You guys are merely being pedantic, and are ignoring (or ignorant of) the realities of real-world development...

                      ".45 ACP - because shooting twice is just silly" - JSOP, 2010
                      -----
                      You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
                      -----
                      "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

                      S Offline
                      S Offline
                      Slacker007
                      wrote on last edited by
                      #66

                      John Simmons / outlaw programmer wrote:

                      When you're on a tight schedule, if it was what it's supposed to do, it's "good" code.
                       
                      You guys are merely being pedantic, and are ignoring (or ignorant of) the realities of real-world development...

                      well said.

                      "the meat from that butcher is just the dogs danglies, absolutely amazing cuts of beef." - DaveAuld (2011)
                      "No, that is just the earthly manifestation of the Great God Retardon." - Nagy Vilmos (2011) "It is the celestial scrotum of good luck!" - Nagy Vilmos (2011) "But you probably have the smoothest scrotum of any grown man" - Pete O'Hanlon (2012)

                      Z 1 Reply Last reply
                      0
                      • S Slacker007

                        Your points are well made but I don't think you understood the point of my question. Some of the members who responded to my question, understood what I was trying to get to. Your list of 1-10 is what seems correct...for you. However, I don't agree with most of your list as criteria for good code. Does this mean I'm right? Of course not. Therein lies my point.

                        "the meat from that butcher is just the dogs danglies, absolutely amazing cuts of beef." - DaveAuld (2011)
                        "No, that is just the earthly manifestation of the Great God Retardon." - Nagy Vilmos (2011) "It is the celestial scrotum of good luck!" - Nagy Vilmos (2011) "But you probably have the smoothest scrotum of any grown man" - Pete O'Hanlon (2012)

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

                        Your question and assertion seem to be based around the fact that good code is not knowable. This is much like the philosophical argument that right and wrong are subjective and any objective determination cannot be made. I largely agree with those concepts, however I also question the necessity of finding objective determinations of what is good/right/wrong/etc. Such an answer really only has relevance among sentient beings such as humans. The quality of code especially so (not too many platypodes care about the style of brackets you use). And code quality will be relevant to certain humans more than others. There are many dimensions to relevance you could use to judge code quality. For one, a customer probably cares most about how well the code functions (e.g., that it is bug free). However, customers can be pretty ignorant, so they may be unable to judge that code is future-proof, which saves them money (even if they are unaware of it). Then there is your boss. He might care most about getting things done in a timely manner. From his perspective, getting things done fast makes you a quality coder, but whether that means your code is good or not depends on the perspective. From your collegue who was educated with 3 PhD's, maybe your code doesn't look as pristine as she'd like. However, your practical nature might conclude that pristine code is a waste of time, or you might have a different idea of what pristine code looks like. Much like morality, judgement of good or bad depends on the perspective, and that perspective can vary depending on how you want to select a group. You may be right that there is no objective measure of good code. However, that does not mean that, say, the .Net community does not have a few guidelines. And I'd also add that the larger your group is from which you are considering a perspective, the more generic you can be in declaring rules for quality. There may be some absolutes from the widest perspective (all humans), but by that time they may be so generic as to be useless to you on a specific level. So I guess this is really a bigger discussion. One that probably wouldn't be resolved any sooner than the "right" philosophy is achieved. :)

                        Thou mewling ill-breeding pignut!

                        S 1 Reply Last reply
                        0
                        • R realJSOP

                          When you're on a tight schedule, if it was what it's supposed to do, it's "good" code. You guys are merely being pedantic, and are ignoring (or ignorant of) the realities of real-world development...

                          ".45 ACP - because shooting twice is just silly" - JSOP, 2010
                          -----
                          You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
                          -----
                          "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

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

                          John Simmons / outlaw programmer wrote:

                          ignoring (or ignorant of) the realities of real-world development

                          I don't think so. In real world development, sure a schedule may be tight and it may be necessary to write code that is not 'as good as it could be' just to get it out the door, or to fix an urgent bug. But that still isn't good code, it is just working code. If it is left as-is, and the code base is modified over time, then such code can cause more and more issues (as you must know) If you're a good, experienced, programmer, then the likelihood of quickly developed code being poor is less, but we all know we sometimes cut corners to get the job done - and we all know it comes back to bite us (or our successor) in the bum when that happens. If someone writes hundreds of lines of spaghetti code to achieve what could have been written in a few lines of well structured code, by your measure, it is good code if the output is as required. But a part of the output should be the codes longevity and maintainability, not just the function return value.

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

                          Z 1 Reply Last reply
                          0
                          • S Slacker007

                            Who determines if your code is good? What is good code and what are the precise criteria for giving it a status of "good"? Since most of your code will never be reviewed by your peers (outside of work) then how do you know it is worth a damn, really? If I think your code sucks but the next guy thinks it is good, then who is right? This kind of goes in line with my other thoughts about the "greatness" of an individual programmer. Who determines that a person is a great programmer and that person writes some damn good code? You? Me? None of the above? We obviously cannot make this determination about ourselves or our code. So who does?

                            "the meat from that butcher is just the dogs danglies, absolutely amazing cuts of beef." - DaveAuld (2011)
                            "No, that is just the earthly manifestation of the Great God Retardon." - Nagy Vilmos (2011) "It is the celestial scrotum of good luck!" - Nagy Vilmos (2011) "But you probably have the smoothest scrotum of any grown man" - Pete O'Hanlon (2012)

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

                            this is good code according to JSOP (to save you compiling and building it, it is a flight simulator) and it works.

                            #include
                            #include
                            #include
                            #include
                            double L ,o ,P
                            ,_=dt,T,Z,D=1,d,
                            s[999],E,h= 8,I,
                            J,K,w[999],M,m,O
                            ,n[999],j=33e-3,i=
                            1E3,r,t, u,v ,W,S=
                            74.5,l=221,X=7.26,
                            a,B,A=32.2,c, F,H;
                            int N,q, C, y,p,U;
                            Window z; char f[52]
                            ; GC k; main(){ Display*e=
                            XOpenDisplay( 0); z=RootWindow(e,0); for (XSetForeground(e,k=XCreateGC (e,z,0,0),BlackPixel(e,0))
                            ; scanf("%lf%lf%lf",y +n,w+y, y+s)+1; y ++); XSelectInput(e,z= XCreateSimpleWindow(e,z,0,0,400,400,
                            0,0,WhitePixel(e,0) ),KeyPressMask); for(XMapWindow(e,z); ; T=sin(O)){ struct timeval G={ 0,dt*1e6}
                            ; K= cos(j); N=1e4; M+= H*_; Z=D*K; F+=_*P; r=E*K; W=cos( O); m=K*W; H=K*T; O+=D*_*F/ K+d/K*E*_; B=
                            sin(j); a=B*T*D-E*W; XClearWindow(e,z); t=T*E+ D*B*W; j+=d*_*D-_*F*E; P=W*E*B-T*D; for (o+=(I=D*W+E
                            *T*B,E*d/K *B+v+B/K*F*D)*_; p K)N=1e4; else{ q=W/K *4E2+2e2; C= 2E2+4e2/ K
                            *D; N-1E4&& XDrawLine(e ,z,k,N ,U,q,C); N=q; U=C; } ++p; } L+=_* (X*t +P*M+m*l); T=X*X+ l*l+M *M;
                            XDrawString(e,z,k ,20,380,f,17); D=v/l*15; i+=(B *l-M*r -X*Z)*_; for(; XPending(e); u *=CS!=N){
                            XEvent z; XNextEvent(e ,&z);
                            ++*((N=XLookupKeysym
                            (&z.xkey,0))-IT?
                            N-LT? UP-N?& E:&
                            J:& u: &h); --*(
                            DN -N? N-DT ?N==
                            RT?&u: & W:&h:&J
                            ); } m=15*F/l;
                            c+=(I=M/ l,l*H
                            +I*M+a*X)*_; H
                            =A*

                            S 1 Reply Last reply
                            0
                            • S Slacker007

                              Who determines if your code is good? What is good code and what are the precise criteria for giving it a status of "good"? Since most of your code will never be reviewed by your peers (outside of work) then how do you know it is worth a damn, really? If I think your code sucks but the next guy thinks it is good, then who is right? This kind of goes in line with my other thoughts about the "greatness" of an individual programmer. Who determines that a person is a great programmer and that person writes some damn good code? You? Me? None of the above? We obviously cannot make this determination about ourselves or our code. So who does?

                              "the meat from that butcher is just the dogs danglies, absolutely amazing cuts of beef." - DaveAuld (2011)
                              "No, that is just the earthly manifestation of the Great God Retardon." - Nagy Vilmos (2011) "It is the celestial scrotum of good luck!" - Nagy Vilmos (2011) "But you probably have the smoothest scrotum of any grown man" - Pete O'Hanlon (2012)

                              V Offline
                              V Offline
                              Vivi Chellappa
                              wrote on last edited by
                              #70

                              Slacker007 wrote:

                              We obviously cannot make this determination about ourselves or our code. So who does?

                              Good Houskeeping magazine. They hand out the Seal of Approval for all sorts of things. So you could write to them. ;P

                              1 Reply Last reply
                              0
                              • S Slacker007

                                Who determines if your code is good? What is good code and what are the precise criteria for giving it a status of "good"? Since most of your code will never be reviewed by your peers (outside of work) then how do you know it is worth a damn, really? If I think your code sucks but the next guy thinks it is good, then who is right? This kind of goes in line with my other thoughts about the "greatness" of an individual programmer. Who determines that a person is a great programmer and that person writes some damn good code? You? Me? None of the above? We obviously cannot make this determination about ourselves or our code. So who does?

                                "the meat from that butcher is just the dogs danglies, absolutely amazing cuts of beef." - DaveAuld (2011)
                                "No, that is just the earthly manifestation of the Great God Retardon." - Nagy Vilmos (2011) "It is the celestial scrotum of good luck!" - Nagy Vilmos (2011) "But you probably have the smoothest scrotum of any grown man" - Pete O'Hanlon (2012)

                                W Offline
                                W Offline
                                wizardzz
                                wrote on last edited by
                                #71

                                If you copy and paste good developers' code, then you have yourself good code.

                                "I have a theory that the truth is never told during the nine-to-five hours. " — Hunter S. Thompson

                                1 Reply Last reply
                                0
                                • S Slacker007

                                  Who determines if your code is good? What is good code and what are the precise criteria for giving it a status of "good"? Since most of your code will never be reviewed by your peers (outside of work) then how do you know it is worth a damn, really? If I think your code sucks but the next guy thinks it is good, then who is right? This kind of goes in line with my other thoughts about the "greatness" of an individual programmer. Who determines that a person is a great programmer and that person writes some damn good code? You? Me? None of the above? We obviously cannot make this determination about ourselves or our code. So who does?

                                  "the meat from that butcher is just the dogs danglies, absolutely amazing cuts of beef." - DaveAuld (2011)
                                  "No, that is just the earthly manifestation of the Great God Retardon." - Nagy Vilmos (2011) "It is the celestial scrotum of good luck!" - Nagy Vilmos (2011) "But you probably have the smoothest scrotum of any grown man" - Pete O'Hanlon (2012)

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

                                  Not being a professional programmer myself; only a hobbyist, I would say that good code is code that gets the job done in the most efficient (from a performance point of view), understandable (from a readability point of view) manner and that this will be self evident to anyone viewing the code.

                                  1 Reply Last reply
                                  0
                                  • S Slacker007

                                    Who determines if your code is good? What is good code and what are the precise criteria for giving it a status of "good"? Since most of your code will never be reviewed by your peers (outside of work) then how do you know it is worth a damn, really? If I think your code sucks but the next guy thinks it is good, then who is right? This kind of goes in line with my other thoughts about the "greatness" of an individual programmer. Who determines that a person is a great programmer and that person writes some damn good code? You? Me? None of the above? We obviously cannot make this determination about ourselves or our code. So who does?

                                    "the meat from that butcher is just the dogs danglies, absolutely amazing cuts of beef." - DaveAuld (2011)
                                    "No, that is just the earthly manifestation of the Great God Retardon." - Nagy Vilmos (2011) "It is the celestial scrotum of good luck!" - Nagy Vilmos (2011) "But you probably have the smoothest scrotum of any grown man" - Pete O'Hanlon (2012)

                                    Sander RosselS Offline
                                    Sander RosselS Offline
                                    Sander Rossel
                                    wrote on last edited by
                                    #73

                                    Reread your code next week, if you still understand what is going on it has potential to be good. Reread your code next month, if you still understand what is going on your code might be pretty allright. Reread your code after six months, if you still understand what is going on you probably have a winner. Reread your code after a year, if you still understand what is going on your code is good. Now have a colleague read your code. If he can't understand it he is in desperate need for some schooling (after all, your code is good). Now have your boss read your code. If he can't understand it your code wasn't good after all (even if your boss isn't a programmer, he makes the rules). Now have someone outside of your company read it. If he can't understand it who cares? His opinion doesn't matter anyway. Code that gets older than approximately five years (perhaps probably less) is bad code by definition. I think really very few people have written good code, ever :)

                                    It's an OO world.

                                    public class Naerling : Lazy<Person>{
                                    public void DoWork(){ throw new NotImplementedException(); }
                                    }

                                    S L 2 Replies Last reply
                                    0
                                    • S Slacker007

                                      Who determines if your code is good? What is good code and what are the precise criteria for giving it a status of "good"? Since most of your code will never be reviewed by your peers (outside of work) then how do you know it is worth a damn, really? If I think your code sucks but the next guy thinks it is good, then who is right? This kind of goes in line with my other thoughts about the "greatness" of an individual programmer. Who determines that a person is a great programmer and that person writes some damn good code? You? Me? None of the above? We obviously cannot make this determination about ourselves or our code. So who does?

                                      "the meat from that butcher is just the dogs danglies, absolutely amazing cuts of beef." - DaveAuld (2011)
                                      "No, that is just the earthly manifestation of the Great God Retardon." - Nagy Vilmos (2011) "It is the celestial scrotum of good luck!" - Nagy Vilmos (2011) "But you probably have the smoothest scrotum of any grown man" - Pete O'Hanlon (2012)

                                      F Offline
                                      F Offline
                                      Fran Porretto
                                      wrote on last edited by
                                      #74

                                      "Good" is an evaluation. An evaluation must rest on explicit criteria of goodness / badness. These are often personal.

                                      My criteria for "Is it good code?" are:

                                      1. Does it fulfill the requirements of the application?
                                      2. Is it stable under the worst projected loads?
                                      3. Is it legible and maintainable by a competent engineer other than the originator?

                                      Code that incorporates assorted ingenuities can meet criteria 1 and 2 but fail criterion 3. And criterion 3 is just as important as the others.

                                      Not long ago a subordinate of mine wrote exactly that sort of program. His product was massively ingenious. It was even visually impressive. But it was effectively unmaintainable -- "effectively," because this particular program is one that, by its very nature, requires rapid modification, and requires it frequently, at that. My first two attempts to alter it proved that conclusively. So at the earliest politic opportunity, despite the impact to my regular responsibilities, I "spent five hours to save five minutes," as the saying goes, and rewrote the thing from the requirements, making maximally sure that any moderately competent engineer could easily understand its workings.

                                      I still have the predecessor program. I go back to it now and then, just to remind myself of what too much cleverness can cost, down the maintenance road.

                                      (This message is programming you in ways you cannot detect. Be afraid.)

                                      1 Reply Last reply
                                      0
                                      • Sander RosselS Sander Rossel

                                        Reread your code next week, if you still understand what is going on it has potential to be good. Reread your code next month, if you still understand what is going on your code might be pretty allright. Reread your code after six months, if you still understand what is going on you probably have a winner. Reread your code after a year, if you still understand what is going on your code is good. Now have a colleague read your code. If he can't understand it he is in desperate need for some schooling (after all, your code is good). Now have your boss read your code. If he can't understand it your code wasn't good after all (even if your boss isn't a programmer, he makes the rules). Now have someone outside of your company read it. If he can't understand it who cares? His opinion doesn't matter anyway. Code that gets older than approximately five years (perhaps probably less) is bad code by definition. I think really very few people have written good code, ever :)

                                        It's an OO world.

                                        public class Naerling : Lazy<Person>{
                                        public void DoWork(){ throw new NotImplementedException(); }
                                        }

                                        S Offline
                                        S Offline
                                        Slacker007
                                        wrote on last edited by
                                        #75

                                        Naerling wrote:

                                        I think really very few people have written good code, ever

                                        The whole point of my question, really. :)

                                        "the meat from that butcher is just the dogs danglies, absolutely amazing cuts of beef." - DaveAuld (2011)
                                        "No, that is just the earthly manifestation of the Great God Retardon." - Nagy Vilmos (2011) "It is the celestial scrotum of good luck!" - Nagy Vilmos (2011) "But you probably have the smoothest scrotum of any grown man" - Pete O'Hanlon (2012)

                                        1 Reply Last reply
                                        0
                                        • L Lost User

                                          this is good code according to JSOP (to save you compiling and building it, it is a flight simulator) and it works.

                                          #include
                                          #include
                                          #include
                                          #include
                                          double L ,o ,P
                                          ,_=dt,T,Z,D=1,d,
                                          s[999],E,h= 8,I,
                                          J,K,w[999],M,m,O
                                          ,n[999],j=33e-3,i=
                                          1E3,r,t, u,v ,W,S=
                                          74.5,l=221,X=7.26,
                                          a,B,A=32.2,c, F,H;
                                          int N,q, C, y,p,U;
                                          Window z; char f[52]
                                          ; GC k; main(){ Display*e=
                                          XOpenDisplay( 0); z=RootWindow(e,0); for (XSetForeground(e,k=XCreateGC (e,z,0,0),BlackPixel(e,0))
                                          ; scanf("%lf%lf%lf",y +n,w+y, y+s)+1; y ++); XSelectInput(e,z= XCreateSimpleWindow(e,z,0,0,400,400,
                                          0,0,WhitePixel(e,0) ),KeyPressMask); for(XMapWindow(e,z); ; T=sin(O)){ struct timeval G={ 0,dt*1e6}
                                          ; K= cos(j); N=1e4; M+= H*_; Z=D*K; F+=_*P; r=E*K; W=cos( O); m=K*W; H=K*T; O+=D*_*F/ K+d/K*E*_; B=
                                          sin(j); a=B*T*D-E*W; XClearWindow(e,z); t=T*E+ D*B*W; j+=d*_*D-_*F*E; P=W*E*B-T*D; for (o+=(I=D*W+E
                                          *T*B,E*d/K *B+v+B/K*F*D)*_; p K)N=1e4; else{ q=W/K *4E2+2e2; C= 2E2+4e2/ K
                                          *D; N-1E4&& XDrawLine(e ,z,k,N ,U,q,C); N=q; U=C; } ++p; } L+=_* (X*t +P*M+m*l); T=X*X+ l*l+M *M;
                                          XDrawString(e,z,k ,20,380,f,17); D=v/l*15; i+=(B *l-M*r -X*Z)*_; for(; XPending(e); u *=CS!=N){
                                          XEvent z; XNextEvent(e ,&z);
                                          ++*((N=XLookupKeysym
                                          (&z.xkey,0))-IT?
                                          N-LT? UP-N?& E:&
                                          J:& u: &h); --*(
                                          DN -N? N-DT ?N==
                                          RT?&u: & W:&h:&J
                                          ); } m=15*F/l;
                                          c+=(I=M/ l,l*H
                                          +I*M+a*X)*_; H
                                          =A*

                                          S Offline
                                          S Offline
                                          Slacker007
                                          wrote on last edited by
                                          #76

                                          _Maxxx_ wrote:

                                          this is good code according to JSOP

                                          You and I both know what JSOP meant. ;) ...nice plane.

                                          "the meat from that butcher is just the dogs danglies, absolutely amazing cuts of beef." - DaveAuld (2011)
                                          "No, that is just the earthly manifestation of the Great God Retardon." - Nagy Vilmos (2011) "It is the celestial scrotum of good luck!" - Nagy Vilmos (2011) "But you probably have the smoothest scrotum of any grown man" - Pete O'Hanlon (2012)

                                          L 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