Slashdot Mirror


Ask Slashdot: What Makes Some Code Particularly Good?

itwbennett writes: When developers talk about what makes some source code particularly 'good,' a handful of qualities tend to get mentioned frequently (functional, readable, testable). What would you add to this list?

298 comments

  1. Obviously by Anonymous Coward · · Score: 5, Funny

    When it's mine.

    1. Re:Obviously by Anonymous Coward · · Score: 2, Insightful

      What makes an article a click whoring waste of time? I don't know, I didn't read past the first for 9 impression generating lazily written dreck, but being posted on slashdot is becoming a good indication.

    2. Re:Obviously by Anonymous+Brave+Guy · · Score: 4, Funny

      Tell that to your six-months-ago self, who wrote the mess you've been debugging all week. :-)

      --
      If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
    3. Re:Obviously by Anonymous Coward · · Score: 0

      When it's not my coworkers's!

    4. Re:Obviously by nitehawk214 · · Score: 4, Funny

      I hate it when I have to debug some other asshole's code.

      I hate it more when the asshole is six-months-ago-me.

      --
      I'm a good cook. I'm a fantastic eater. - Steven Brust
    5. Re:Obviously by plopez · · Score: 2

      When it's mine and I am the only one who understands it and so therefore have a cash cow until retirement :)

      --
      putting the 'B' in LGBTQ+
    6. Re:Obviously by Anonymous Coward · · Score: 0

      Yip, once in a while I make bad good (according to me and my coworkers), often code that is pretty good (according to coworkers), at home I make code that is very good (according to me), and sometimes I am brilliant (according to my coworkers).
      I am all over the place, I guess many programmers are.

    7. Re:Obviously by stjobe · · Score: 4, Insightful

      I am all over the place, I guess many programmers are.

      Being a programmer is a trade in some parts, and you can get by with good craftsmanship.
      In other parts it's a creative art, and you can't force creativity.

      To write really good code, you need to both have the craftsmanship and the creativity.

      --
      "Total destruction the only solution" - Bob Marley
    8. Re:Obviously by TeknoHog · · Score: 1

      Man, that's a big-ass hole.

      --
      Escher was the first MC and Giger invented the HR department.
    9. Re: Obviously by johnsnails · · Score: 1
    10. Re:Obviously by Jane+Q.+Public · · Score: 2

      There *IS* one problem here: efficiency is the last item, while "simple" and "pleasant to look at" are given higher priority on the list.

      Yes, that is a regrettable trend I've seen lately. Yes, code should be readable, and should be easy to maintain. But there is a huge amount -- maybe even majority -- of time when efficiency should be considered before readability or beauty.

    11. Re:Obviously by Jane+Q.+Public · · Score: 2

      I will elaborate just a little:

      I have personally seen code essential to execution time, which was neat and canonical, made literally more than 100 times more efficient in the sense of time and CPU cycles, by using methods that were a little less readable.

      And I mean via testing, not just subjective impression.

      TFA has its priorities skewed.

    12. Re:Obviously by Anonymous Coward · · Score: 1

      True story:
      I was debugging some code and ran across a section that appeared completely whack. Found myself thinking
      "What on earth were you smoking ... " when the comment a row below caught my eye saying:
      "I wasn't smoking anything! The above is correct because .. X Y and Z".

      Not only did I write that code, I had been there debugging / inspecting that bit before. And having no memory of either.

    13. Re:Obviously by nitehawk214 · · Score: 3, Insightful

      The door wings both ways though. Sometimes six-months-ago-me is a pretty cool guy.

      Like that time I was searching for an answer to a problem on Stack Overflow. At first I thought "Ha, what a coincidence, the top rated answerer has the same name as me." It was not a coincidence... it was me.

      --
      I'm a good cook. I'm a fantastic eater. - Steven Brust
    14. Re:Obviously by americanpossum · · Score: 1

      Last time I met myself, I kicked my own ass!

      --John Shepherd

      ;-)

    15. Re: Obviously by Anonymous Coward · · Score: 0

      And that's why programming languages allow comments to be added with code...

    16. Re:Obviously by Anonymous Coward · · Score: 0

      I have personally seen code essential to execution time, which was neat and canonical, made literally more than 100 times more efficient in the sense of time and CPU cycles, by using methods that were a little less readable.

      Can you give a specific example?
      Not doubting you, I just want to learn how this is done.

    17. Re:Obviously by Anonymous Coward · · Score: 0

      Do you believe in correct readable code?
      Yes I'm sure that it happens all the time
      What do you see when you open the IDE?
      I can't tell you but I know it's mine

    18. Re:Obviously by omfgnosis · · Score: 1

      For humans, simplicity and readability are generally prerequisites to efficiency. It's so obvious that the sentence reads like a tautology.

    19. Re:Obviously by Anonymous Coward · · Score: 0

      When the vast majority of code is IO bound, as long as the code is reasonably efficient both in memory and execution, who gives a fuck?

      Of course there are limits. Like Trion Games ridiculous launcher for Rift. It uses over 50 MB of RAM.

    20. Re: Obviously by Anonymous Coward · · Score: 0

      If it were obligatory you wouldn't have to point that out you dumbfuck

  2. Not being PHP by drakaan · · Score: 1, Funny

    Not being PHP would have to be in my top two list for what makes good code. Not being Visual Basic would be #1.

    --
    "Murphy was an optimist" - O'Toole's commentary on Murphy's Law
    1. Re:Not being PHP by Anonymous Coward · · Score: 0, Interesting

      Not being .NET and Not being Java would be my tops.

    2. Re:Not being PHP by orasio · · Score: 1

      PHP can be good or bad, like any other code. Lately it's getting better.
      As an example, do you think this looks bad? Looks pretty good to me.

        https://github.com/symfony/sym...

      I have some awful, unreadable examples I could share in Java, PHP, Javascript and even C, but chosen language no longer forces you to write bad code. Maybe Perl, but I haven't seen it lately.

    3. Re:Not being PHP by __aabppq7737 · · Score: 1

      From the very beginning, .NET was made for brownfield app development - never for speed. .NET has large dominance and is promoted by Microsoft because it wins over the windows platform.

    4. Re:Not being PHP by gmack · · Score: 1

      perl -e 'print $i=pack(c5,(41*2),sqrt(7056),(unpack(c,H)-2),oct(115),10);'

    5. Re:Not being PHP by MightyMartian · · Score: 1

      Dominance where exactly? A helluva lot of Windows development is still done in C/C++. Java still has massive penetration in the enterprise. I'll admit that .NET is a big player in the Windows world, but considering the Windows market appears to be at best static, and as a platform, compared to other computing devices (enterprise computing, mobile computing, etc.) is in absolute terms possibly even declining, I'd say .NET could hardly be described as dominant.

      --
      The world's burning. Moped Jesus spotted on I50. Details at 11.
    6. Re:Not being PHP by Anonymous Coward · · Score: 1

      Dominance where exactly? A helluva lot of Windows development is still done in C/C++. Java still has massive penetration in the enterprise. I'll admit that .NET is a big player in the Windows world, but considering the Windows market appears to be at best static, and as a platform, compared to other computing devices (enterprise computing, mobile computing, etc.) is in absolute terms possibly even declining, I'd say .NET could hardly be described as dominant.

      Windows programmers are not generally aware of platforms outside of the Windows world. I've known programmers who thought Microsoft invented ftp. That same programmer never logged to an operating system that different from Windows. You'll find the same it true for Windows shops. They don't know about anything else except Microsoft. So when someone makes a comment like, ".NET has large dominance..." They do it out of true ignorance and not malice.

    7. Re:Not being PHP by orasio · · Score: 1

      Does that manual encourage bad code ?

    8. Re:Not being PHP by Wootery · · Score: 1

      From the very beginning, .NET was made for brownfield app development - never for speed.

      Makes sense. Why would they try to make another C++?

      .NET is by no means slow though, as you seem to be implying.

    9. Re:Not being PHP by gmack · · Score: 1

      Any manual that encourages Perl encourages bad code.

    10. Re:Not being PHP by zarr · · Score: 1
      Reasons why hat code is crap:

      -Meaningless boilerplate comments. Comments on property getters and setters is pure noise.
      -Questionable OO design. Why are this class keeping references to serviceReferenceGraph and loggingFormatter which it doesn't use for anything?
      -Needless vertical scrolling. Given the triviality of this class, there is no reason for it not to be a one-pager.
      -It's in the DependencyInjection namespace, but... doesn't use dependency injection!
      -php pretending to be java. WTF is up with that?

    11. Re:Not being PHP by senatorpjt · · Score: 1

      It's pretty hard to fuck up a class that's just a collection of getters and setters. It was probably autogenerated anyway.

    12. Re:Not being PHP by Anonymous Coward · · Score: 0

      You project your ignorance and malice vs. apk tearing you up http://news.slashdot.org/comme... with documented facts.

    13. Re:Not being PHP by Bill+Dog · · Score: 1

      .NET is dominant on the Windows platform. After over a decade doing C/C++ on Win32, I finally had to switch to it several years back. Except for specialized stuff where the extra speed actually matters, no one is developing applications on Windows at this low level anymore.

      --
      Attention zealots and haters: 00100 00100
  3. Because it's mine! by DickBreath · · Score: 3, Insightful

    Doesn't every self important developer think that their own code is the best?


    How many managers does it take to reach a decision to begin a study to determine whether a light bulb should be replaced?

    --

    I'll see your senator, and I'll raise you two judges.
    1. Re:Because it's mine! by mykepredko · · Score: 2

      Agreed for "self important developers".

      "Good" developers know that they probably missed things or could have done some parts of it better (and know that unless there is a functionality issue, to not go back and try to fix them).

      myke

    2. Re:Because it's mine! by Wootery · · Score: 1

      Depends. Have they just finished it, or are they coming back to it a month later?

    3. Re:Because it's mine! by Livius · · Score: 1

      Doesn't every self important developer think that their own code is the best?

      Isn't that the definition of 'self important'?

  4. Unencumbered by davidwr · · Score: 1

    Not encumbered by patents, NDAs, or licensing restictions the keep me from making good use of it.

    --
    Knowledge is how to play a game, intelligence is how to win, wisdom is knowing what game to play.
    1. Re:Unencumbered by DickBreath · · Score: 1

      Unfortunately, whether or not code is encumbered by patents is not up to the author of the code. That is one (of many) major FAIL of the patent system. Your code, yes yours, could be encumbered by some pending patent, that the 'inventor' is keeping from being issued until your code is suddenly making money. Poof! Patent is now granted and you are infringing.

      --

      I'll see your senator, and I'll raise you two judges.
    2. Re:Unencumbered by Anonymous Coward · · Score: 0

      And doing a patent search makes you liable for treble damages.

    3. Re:Unencumbered by Anonymous Coward · · Score: 1

      Agreed, much better off pretending patents don't exist and paying bass damages instead.

    4. Re:Unencumbered by Anonymous Coward · · Score: 0

      paying bass damages

      Leave the fish out of it.

    5. Re: Unencumbered by Anonymous Coward · · Score: 0

      Bass? That was low.

  5. must fail by BytePusher · · Score: 3, Insightful

    Code needs to fail in an easy to understand and predictable way. If possible and practical provide descriptive and easy to follow details through logging or return values...

    1. Re:must fail by Anonymous Coward · · Score: 1

      Yeah I knew a guy once who when a configuration file lookup(environment variable) failed would default to the development environment. Of course he didn't bother to unit test the configuration lookup code which never worked in the first place. Lots of tears on deployment night!

      It's pretty simple stuff to test any likely to fail value and throw an exception saying something like "xyz configuration value is missing"
         

    2. Re:must fail by Rob+Y. · · Score: 1

      Yep. I've had C++ coders who were not building general purpose libraries, but still insisted on throwing exceptions in cases of fatal errors (because 'that's what you do'?). The caller would then catch the exception and then call a routine to log the error and core dump for later debugging. But dumping at the site of the caller discards all the detailed information and variables that would've been available in the core dump if the damn app just logged and dumped at the site of the error instead of throwing it back to the caller.

      --
      Posted from my Android phone. Oh, I can change this? There, that's better...
    3. Re:must fail by swilver · · Score: 2

      It is good practice to throw exceptions for even fatal errors. What they've missed however is to add information to the exception about the error (the stuff you propose they should log).

      Somewhere way up the call stack you have a catch all exception handler, which is responsible for logging the exception -- so it is not necesarilly the caller who logs this. If the caller cannot handle the exception, it should just leave it and let it bubble up.

      This way there's no need to duplicate logging code in every small little function that can't handle certain inputs.

    4. Re:must fail by Anonymous Coward · · Score: 0

      My code then must be the awesomest, it fails at compile time, consistently ;)

      I think the problem with most programmers (and techies) is they aren't big picture and very detail oriented -- which has it's upsides and downsides.

      They'll fight over hungarian notation and other minutae for a long time but rarely consider the overall design of something. The small down to the line of code stuff rarely matters all that much (but when it does, it does a whole lot!) and the whole design considerations need more than an afterthought.

    5. Re:must fail by Rob+Y. · · Score: 1

      My point is that in a fatal error of the sort "this should never happen, so I'm going to dump to let the programmer take a look", there's no way to format an exception to have the relevant information - you don't know what that info is. And for application (as opposed to library) code to throw exceptions that are never going to be handled other than to treat them as fatal and dump, throwing an exception is a waste of energy and discards possibly useful information. You're better off dumping at the site of the exception than where the caller catches it.

      --
      Posted from my Android phone. Oh, I can change this? There, that's better...
    6. Re:must fail by Rob+Y. · · Score: 1

      ...and 'logging code' is no more involved than 'exception code'. You format some kind of message and make a function call - how 'wasteful' is that?

      --
      Posted from my Android phone. Oh, I can change this? There, that's better...
    7. Re:must fail by xonen · · Score: 1

      I think the problem with most programmers (and techies) is they aren't big picture and very detail oriented

      Then, maybe, your using the wrong approach.

      Try "Don't document your code, but code you documentation"..

      This is as easy as creating all files you normally would, and just write down, in comments, the code you are planning to write. You catch several flies at once here: You design the entire code base, top-down, you bring structure to it, and you already documented it before you even started coding!

      All you have to do now is work out your comments. You start by prototyping your (OO) classes and methods or (non-OO) functions. Once you validated your information flow (as in: all methods take all parameters they need, objects have all variables and methods they need in a non-redundant way, etc etc)- the remaining task is trivial: work out any method.

      Then once you completed implementing the last method, you hit compile. And guess what: chances are your code _just works_ because you organized yourself and your activities in such a way that will avoid creating stupid mistakes and oversights, and 100% of your focus was with implementing well-defined functions or methods.

      Top-down just works. Especially when your projected project is large. Resist the temptation of coding (but of course, you can consider your approaches while designing). Don't feel stupid for spending 2 or more days designing without coding - you will earn this time back tenfold. And while designing without implementing, you will get a good feel of which potential libraries you need, and where the easy and tough bits of coding are. But eventually, it all comes down to avoiding errors while having oversight of the entire program flow.

      --
      A glitch a day keeps the bugs away.
  6. mine is good by Anonymous Coward · · Score: 0

    What makes good code? Most of the time it is 'mine is good yours sucks'. That is the mantra MANY unfortunately follow.

  7. When you go back to it several months later by Z80a · · Score: 5, Insightful

    And say "thank you, my past self for making this so easy to understand and versatile!".

    1. Re:When you go back to it several months later by Anonymous Coward · · Score: 0

      Versatility is contextual. There is no such quality in every situation.

    2. Re:When you go back to it several months later by Z80a · · Score: 1

      Indeed there's no such thing as a "do what i mean" function , but generally within the context of the application, its good when you run into a function that is "future proof" enough to not need to heavily hack it or rewrite it whole to do something slightly different.

    3. Re:When you go back to it several months later by Anonymous Coward · · Score: 0

      "Who wrote this brilliant piece of software, it's well documented and works"

      "Oh, it's mine".

      (And I have plenty of code where I've said the exact opposite. But stuff I publish as complete I try to complete and document as much as possible).

    4. Re:When you go back to it several months later by Anonymous Coward · · Score: 0

      I have 10 lines of recursive code it took a 2 week to write and test. I spent a year trying to find a non recursive way to do it and gave up and published it. I didn't understand it very well at the time. But it solves the probable of making water run down hill from point elevation data and collects all the watershed statistics as fail on the way out. I can spend a couple of weeks getting my head around it to work with it again. The only defense is I haven't found anyone that has done better.

    5. Re:When you go back to it several months later by Anonymous Coward · · Score: 0

      Cool story, bro(-grammer). But did you write COMMENTS explaining what it was doing (and why [some other method that might quickly pop to mind] should not be pursued)? If yes, then your code wins an award and I love you. If no, I consign thee to Programmer Hell when I encounter these 10 lines five years later and waste a week of my own time going down the [some other method that might quickly pop to mind] rabbit hole.

  8. Well commented. by Anonymous Coward · · Score: 0

    'nuff ...

    1. Re:Well commented. by Jamu · · Score: 5, Funny

      What if the comment is // this code sucks.?

      --
      Who ordered that?
    2. Re:Well commented. by Anonymous Coward · · Score: 0

      Or, // WTF did I do here? Here are my favorite comments from one CSS file for TEI Boilerplate:

      TEI span {
      /* jawalsh: why were we hiding this? */
      /* .hide; */
      }

      spanGrp {
      /* NOT SURE, look back on */
      }

      supplied {
      /* not sure on this one, seems like we should indicate somehow. Is there a standard way to do this? */
      }
      /* Why is this selector "TEI table" instead of just "table"? */

    3. Re:Well commented. by Anonymous Coward · · Score: 1

      I know this is a joke but my favorite comments are one like // this code sucks that unabashedly describe the merits and problems of the code. There's nothing worse than auditing convoluted code and wondering "is this code terrible or brilliant?" If the original author tells me that it's not brilliant then it saves me from exploring that avenue.

    4. Re:Well commented. by Anonymous Coward · · Score: 0

      Also, the comments is NOT part of the code. Its just metadata. Its usefull but it is not code.

    5. Re:Well commented. by infolation · · Score: 1

      Well, just comment out the code section that sucks. Job done.

    6. Re:Well commented. by Anonymous Coward · · Score: 0

      > Also, the comments is NOT part of the code. Its just metadata. Its usefull but it is not code.

      I disagree. I consider "code" to be the whole program, not just the parts that translate directly into machine instructions.

      People forget that the main purpose of using a programming language is to make the code readable to humans, not computers.

    7. Re:Well commented. by DMUTPeregrine · · Score: 1

      Hope it's controlling a vacuum pump.

      --
      Not a sentence!
  9. Good code by Anonymous Coward · · Score: 0

    For newly written code, things like readability, testability, and maintainability all can come in to whether it is "good" or not

    For legacy stuff, Good code is code that works. Who cares how easy it is to read or test as long as it works?

    My motto is "The only bad code is broken code. Anything untested is broken."

    1. Re:Good code by __aabppq7737 · · Score: 1

      Mathematics and calculus have given us many tools (domain and range calling back) to know for a fact whether something will work or not. That being said, most errors occur from the human side of things, although, technically, we could prove that code worked w/out having to provide real world data.

    2. Re:Good code by orasio · · Score: 4, Interesting

      For newly written code, things like readability, testability, and maintainability all can come in to whether it is "good" or not

      For legacy stuff, Good code is code that works. Who cares how easy it is to read or test as long as it works?

      The second one should also include "immutable". If it's hard to understand it will evolve easily to non working, and time spent on improvements can start to creep up very fast.

      I have worked in very clever, solid code, but not easy to read. It was then maintained and extended by average, but competent programmers down the road, and turned into a big mess, only because it was so hard to understand.

      In my experience, good code is easy to read, above all. That will make it easy to extend it coherently, find bugs and stuff. Also, if it doesn't work OK, it's easy to find out why. The single metric that saves time, money, and improves quality down the road is readability. Eveything else should be suject to that.

      And, about the last point in the "article", "efficient", it's nonsense. Premature optimization is the root of all evil. You should _always_ follow the second rule of optimization (see http://c2.com/cgi/wiki?RulesOfOptimization ).

    3. Re:Good code by Anonymous Coward · · Score: 0

      >(domain and range

      image or codomain?

    4. Re:Good code by Anonymous Coward · · Score: 0

      I guess it depends on what you mean by optimization. The fastest code is the code that never runs at all. Think about it. It's always better when code suddenly disappears in a puff of math.

    5. Re:Good code by Anonymous Coward · · Score: 0

      It also depends on what you mean when you say "code", an entire program or individual snippets. There are lots of small chunks of source code that never need to (and probably never should) be extended. There are also pieces of code that the next time they'll have to change will be because of something major (say moving to a new protocol) and they will essentially be a new entity at that point.

      I've seen serious damage done by someone who is going to "clean up" some code that was working fine but didn't fit their preferred style.

  10. "Good" by __aabppq7737 · · Score: 0

    is a sense that "experts" (10,000+ hrs of experience) acquire, much like good design, only applied to something textual. Sometimes, you just need to look at the code from a different perspective (UML helps, so does explaining to an XP partner).

  11. Easy to change by Anonymous Coward · · Score: 2

    Code that you can change, and the change does what you expected and did'nt ruin something else in a seemingly unrelated place.

    Doesn't matter if the code is otherwise butt ugly, as long as you can do this, the code is good enough to be workable.

    1. Re:Easy to change by Xolotl · · Score: 2

      I was looking for a comment along these lines .. exactly. Over the years I've found that good code is that which can be opened up months or years after it was written and changed or repurposed easily. Good programmers seem to write this instinctively.

  12. Venn diagrams by Anonymous Coward · · Score: 0

    Notice that the set of qualities which make code "good" are also the set of qualities not taught in any school.
    Think they'll ever fix that?

    -Signed, an Anonymous CS student

    1. Re:Venn diagrams by __aabppq7737 · · Score: 1

      What is art? If I live by that principle, I'll never write a line.

  13. a few heuristics by Sneftel · · Score: 3, Insightful

    Good code feels obvious and self-evident, as though its design springs directly from the problem, rather than from the cleverness of the developer.

    Good code is free of regret; regardless of how much it's been modified and refactored, it feels as though it was written in a single sitting, by a developer who somehow knew the right way to do it already.

    Good code is not just readable, but inviting. It feels as though there is no wrong place to start reading it.

    Good code doesn't have a single goddamn class named "Manager".

    --
    The opinions stated herein do not necessarily represent those of anybody at all. Deal with it.
    1. Re:a few heuristics by arth1 · · Score: 1

      I would say that good code is code that's as simple as possible for its task.

    2. Re:a few heuristics by __aabppq7737 · · Score: 1

      Good code doesn't have a single goddamn class named "Manager".

      ..but it does have main()

    3. Re:a few heuristics by avandesande · · Score: 3, Informative

      Good code is boring and bland, lacking excitement and surprises.... and mostly goes unnoticed.

      --
      love is just extroverted narcissism
    4. Re:a few heuristics by Scottingham · · Score: 1

      I'm not sure if it's just a semantics thing, but what's wrong with having a class called XManager that provides a set of safe functions to deal with a particular object or whatever it may be?

    5. Re:a few heuristics by carluva · · Score: 1

      About the only time a "Manager" is acceptable is if the code for the thing it manages is outside your control. Otherwise, "Manager" is almost always an instant sign of a functional design that's pretending to be object-oriented and failing miserably.

      Or, put another way: Classes called "Manager" almost always violate the single responsibility principle.

    6. Re:a few heuristics by dimeglio · · Score: 1

      It's a bit like watching a skilled performer. They are so good at it, they make it look easy. Then, when you try to do the same, everything ends up in main().

      --
      Views expressed do not necessarily reflect those of the author.
    7. Re:a few heuristics by Anonymous Coward · · Score: 0

      Good code doesn't have a single goddamn class named "Manager".

      But wouldn't that make the "View" classes lonely? Perhaps the "Controller" classes could offer some comfort..

    8. Re:a few heuristics by Anonymous Coward · · Score: 1

      I can't tell if you're being insightful or if this is an actual outcry for human contact . . .

    9. Re:a few heuristics by Anonymous Coward · · Score: 1

      An important one is that good code stays good after many rounds of alterations.

    10. Re:a few heuristics by Anonymous Coward · · Score: 1

      Nothing

    11. Re:a few heuristics by Anonymous Coward · · Score: 1

      So if I have a DomainClassManager for every DomainClass to provide an uniform contract to manage those objects it is wrong. If I call the manager a DAO does it stays wrong. If I do it so I can scale my development team faster by providing an uniform approach accessible to average programmer, those who don't read about software and tech after work, is it still wrong?

    12. Re:a few heuristics by lgw · · Score: 1

      Funny, in my world, classes called "XManager" are expected to have the "single responsibility" of X, but in a way that needs it's own thread or something to do it right - more separation than the usual class boundary. If X is too broad, expect complaints in code review.

      --
      Socialism: a lie told by totalitarians and believed by fools.
    13. Re:a few heuristics by Anonymous Coward · · Score: 1

      If I inherit code where the objects represent nouns and the methods represent verbs, I consider it a good day!

    14. Re:a few heuristics by Anonymous Coward · · Score: 0

      10 PRINT "A"

    15. Re:a few heuristics by bensch128 · · Score: 2

      I hate to burst your bubble, but every example of component based programming that I've seen uses managers to access and control the individual components. You cannot use components otherwise. (At least, not in a memory restricted environment like a video game)

      If you have ever worked on a large video games, then you know exactly what I am talking about.

  14. What would you add to this list? by QuietLagoon · · Score: 3, Insightful

    That it works.

    1. Re:What would you add to this list? by Oligonicella · · Score: 1

      Was reading through to see if I had to add that. Glad you did. It's really the most obvious and should have been first on the list.

    2. Re:What would you add to this list? by stjobe · · Score: 2

      To paraphrase Torvalds:

      If it compiles, it's good. If it runs, ship it.

      --
      "Total destruction the only solution" - Bob Marley
    3. Re:What would you add to this list? by Anonymous Coward · · Score: 0

      ...and efficiently. ...and correctly.

    4. Re:What would you add to this list? by Anonymous Coward · · Score: 0

      I thought that quote was a Microsoftism, not Linus Tornadovolts. No wonder it took 10+ years to clean up enough tweenware in Linux to make it useable. (disclaimer: I have used Linux exclusively the past 3 years).

    5. Re:What would you add to this list? by Anonymous Coward · · Score: 0

      Er, it was.

  15. Is it useful? by Anonymous Coward · · Score: 0

    See: Subject.

    I don't give a shit HOW readable, efficient, testable, etc. code is if it doesn't do anything useful.

    You'd (or maybe people not in the coding profession) be surprised how often you go through large programs and find unreachable code, code that doesn't do anything once it IS reached, and code that simply burns memory for no real reason, but taking it out is difficult because it was band-aided in a thousand times over.

  16. GOTO by s.petry · · Score: 3, Funny

    Lots and lots of GOTO NNNN and I know it's good code!

    --

    -The wise argue that there are few absolutes, the fool argues that there are no probabilities.

    1. Re:GOTO by Anonymous Coward · · Score: 0

      Actually, I'm working on a BASIC interpreter right now and wondering about stuff like it must be permitted to jump to arbitrary locations using GOTO or GOSUB and expect a RETURN to work under all circumstances. It's possible even to jump into the middle of a function declaration from the main program or across function declarations (i.e. a GOTO or GOSUB from one function or subroutine to another). It's legal BASIC code, and it must work, you know! ;)

  17. When it works. by Qbertino · · Score: 1

    When it works.

    No, seriously, that's the prime criteria. I'll take crap code over good code anytime, it it works and the "good" code needs some arcance and/or bizar setup procedure that I have to put up with to perhaps get it running.

    Point in case: WordPress, a PHP driven Web CMS that today runs about 20% of all websites, is a huge pile of typical PHP spagetti. And don't even get me started on the data model ... the WP crew probably doesn't even know what that is. Anyway, just the other day I spent two hours hacking the login template to coax it into not getting in the way of an auto-login feature built with Active X and JavaScript (...don't ask, the customer spends 150 Euros an hour, I'm sure as hell not gonna make stupid remarks on all this).

    I mean, just look at it! (Surgeon Generals Warning: Looking at WP code can cause instant heart problems and depression!)

    It was quite an adventure.

    However, it works. My grandma can setup WP in 10 minutes. Come around the corner with your flashy new Java whatnot, clean model and all, if I spend more than a week trying to get it runing on Debian or some other widespread Linux, I will ditch it, no matter how well the app itself is coded.

    Programms are for users, and they have to work. The rest is icing. End of story.

    --
    We suffer more in our imagination than in reality. - Seneca
    1. Re:When it works. by Jaime2 · · Score: 1

      Whether it works is orthogonal to quality. Good code can be fixed easily, so good code is always a short distance from "it works". Bad code can quickly go from "it works" to "it doesn't work and I don't know why" with just a simple change in requirements.

      One of my rules is that the customer is the judge of whether is works or not, but the team is the judge of whether it is good or not. If the only person to evaluate the product is the customer, then you are pretty much guaranteed to have bad code. Code quality management comes before testing in the form of design reviews, code reviews, standards, pair programming, etc...

    2. Re:When it works. by painandgreed · · Score: 1

      Whether it works is orthogonal to quality.

      I'd say that if it doesn't work, it's of pretty poor quality.

    3. Re:When it works. by Anonymous Coward · · Score: 0

      I have to agree. If it has gotten through "design reviews, code reviews, standards, pair programming, etc..." and doesn't work when it gets to test, you have a problem.

    4. Re:When it works. by Anonymous Coward · · Score: 0

      All code works to do something. Maybe not the last thing, which you care about. That's the problem.

    5. Re:When it works. by ShanghaiBill · · Score: 1

      If it has gotten through "design reviews, code reviews, standards, pair programming, etc..." and doesn't work when it gets to test, you have a problem.

      ... and your problem is a completely broken development process. Code should be tested as it is written. You should never waste time reviewing code that has not passed unit tests, functional tests, regression tests, etc. Hallway usability testing should be done even before the design review.

      Testing is an integral part of every development step, not something you tack on the end.

    6. Re:When it works. by Jaime2 · · Score: 1

      I have to agree. If it has gotten through "design reviews, code reviews, standards, pair programming, etc..." and doesn't work when it gets to test, you have a problem.

      in these cases, "doesn't work" is a matter of interpretation. It's usually a defect or omission in the spec.

    7. Re:When it works. by Jaime2 · · Score: 1

      Testing is an integral part of every development step, not something you tack on the end.

      Good thing you know that we don't do unit testing... otherwise where we we learn that we were doing it wrong? Are you also going to assuming we don't do everything else I don't mention? I re-read my post and I can't find any part of it that could be used to infer that unit testing isn't part of our process.

      Also, if you leave code review until after the product has passed all testing phases, then you have two problems. First, if you change anything after the code review, then you're not done testing, so the only way to do code review last is to magically have code that always zooms through code review with no comments. Second, you'll never get approval to fix more than a trivial amount of code if the pointy-haired boss knows the customer has already signed off; that's the classic path to being forced support bad code.

  18. Personally? by nospam007 · · Score: 1

    Personally, I like speed. It must be fast, you can comment out a nice readable version, but the one to be compiled must be fast.

    1. Re:Personally? by Jaime2 · · Score: 1

      You can usually make good fast without much effort. It's often hard to make fast code good. Prioritizing speed above all else is a recipe for disaster.

    2. Re:Personally? by ckatko · · Score: 1

      I think programmers should focus on making code that "isn't slow" more than they should focus on "is fast." Focus on not making stupid mistakes like running higher-order algorithms than necessary (ala using a for loop to search for a key when you could have been using a dictionary).

      If you focus on fast, you should definitely do a profile-first-optimize-last approach so you're actually optimizing code that the computer spends most of it's time running.

      If you're optimizing fringe functions, then it better be for a pet project and "because I want to." Because otherwise you'll be sacrificing maintenance and introducing bugs for something that isn't even affecting the user.

  19. Testedness by carluva · · Score: 1

    Testability is critical, but it's pointless without actual tests. By tests, I do not mean a single test case verifying only the "normal" path where everything goes exactly as expected. I mean testing every boundary case, varying degrees of complexity where applicable, and failure modes, ensuring that it fails in the way that it is intended to fail and in every case where it is intended to fail.

  20. take it from a pro by nimbius · · Score: 4, Funny

    I think i can shed light on this subject, having several years experience in this field. New programmers and seasoned alike often make this mistake, either through carelessness or ignorance. When working to write good code, you must make sure to set good="yes" or good="veryyes." ive written code for 20 years now and this has only ever failed me in PHP. Apparently the language does not support "good" code.

    --
    Good people go to bed earlier.
    1. Re:take it from a pro by Qbertino · · Score: 1

      I think i can shed light on this subject, having several years experience in this field. New programmers and seasoned alike often make this mistake, either through carelessness or ignorance. When working to write good code, you must make sure to set good="yes" or good="veryyes." ive written code for 20 years now and this has only ever failed me in PHP. Apparently the language does not support "good" code.

      Don't forget to check $_GOOD correctly.
      You have to evaluate "veryyes" == $_GOOD like this:
      if (("veryyes" == $_GOOD) !== false) {...}
      otherwise
      $_GOOD = "kindaSoSo" and $_GOOD = "sortaOk" will both cause "veryyes" == $_GOOD to evaluate to true. ... Gotta know your PHP. :-P

      --
      We suffer more in our imagination than in reality. - Seneca
    2. Re:take it from a pro by Anonymous Coward · · Score: 0

      [Search in project] -> ["Temporary workaround|TODO"] -> . . . -> [694393423987 results in 3021 files found]

  21. THE CORRECT LOOPING by Anonymous Coward · · Score: 0

    IF THE ANALYST codified CORRECTLY THE SYSTEM OF BUSINESS RULES , THESE WILL BE EXPRESSED AS FOLLOWS :

    1- DO SOMETHING INITIALLY
    2- DO SOMETHING TO ANSWER A QUESTION LOGIC
    3- DO SOMETHING WITH OPERATION LOGIC PRODUCT
    4- SAVE!
    RULES :
    1- USE FUNCTION OF LIBRARIES
    2- NEVER CREATE A JOB WITH THE SIZE OF ALL THE BIBLE BYTES ! YOU ARE NOT GOD!
    3-ASSEMBLY IN LINE, ONLY FOR THE ABSENCE OF A API !
    4-DEBUG!

    1. Re:THE CORRECT LOOPING by __aabppq7737 · · Score: 1

      Assembly inlining is good if you're writing 'clever' (DO NOT WRITE CLEVER CODE) code.

  22. Not being a metric ton of bit rot by fyngyrz · · Score: 1

    Fast; efficient; not bloated; not buggy; respectful of the user's privacy; hardened with regard to hacking if that's relevant; not encumbered by dependencies; adequately featured; well supported; well documented for the end user.

    As far as I'm concerned, if you can't hit those 00001000 or 00001001 targets, you should be looking for different line of work.

    Of course it is lovely if it's easily read code, well commented, well structured -- but if the former list is covered, I'll give the 00000011 latter a pass.

    --
    I've fallen off your lawn, and I can't get up.
    1. Re:Not being a metric ton of bit rot by Shompol · · Score: 1
      Pardon me, but your targets are off target: Fast Depends program objectives. Most of my code does not need to be fast, and some even works better if it is slow so it does not pig some resource efficient Usually the case, then again, see "Fast" not bloated maintenability not buggy BS. I just completed a complex project that integrates with pretty scary existing system. It is 95% bugs at this point, yet does not make it bad code. Most bugs will get weeded out over a few weeks, as long as code is easy to read and maintain. respectful of the user's privacy N/A hardened with regard to hacking yes not encumbered by dependencies maintenability adequately featured ? well supported It is if someone pays for it? well documented for the end user Users of a very complex iPhone never read a single page of documentation. I prefer things that just work as expected

      So IMHO it boils down to maintenability and security.

    2. Re:Not being a metric ton of bit rot by glenebob · · Score: 1

      Fast

      Depends program objectives. Most of my code does not need to be fast, and some even works better if it is slow so it does not pig some resource

      Sounds like a lame excuse for shitty code. Code should be fast/efficient, meaning it should get as much done as possible on as few cycles as possible. If efficient code hogs the CPU because it has a great deal of work to do, making the code slow is probably the wrong approach. Try lowering process or thread priority.

    3. Re:Not being a metric ton of bit rot by drkstr1 · · Score: 1

      So you write everything in assembler I take it?

      --
      Fanboy Status: Apache Flex, C#, Eclipse, KDE, Pirate Party, Ron Paul, Slackware, Windows 7
    4. Re:Not being a metric ton of bit rot by Shompol · · Score: 1

      I understand the CPU and other resource hogs are undesirable, but for simple things there is a trade off between keeping them simple or squeezing every drop of performance out, and for most practical tasks keeping things simple is more important.

      Imagine something that takes 0.001 ms on a cheap CPU and is used once a day. Is it worth making it faster for a day of work and a man-week of maintenance increase due to complexity?

    5. Re:Not being a metric ton of bit rot by Anonymous Coward · · Score: 0

      I work for a large company that builds an product stuffed full of embedded code. This application is probably larger then most embedded firmware ( 5 million+ LOC). Most everything is written in C, With some c++ in the UI. It works great and is very fast. You probably used one today.
        I also use tools written in the new 00 languages to maintain the project. These are slow, complicated, prone to user input error and very professionally built. The number of cycles spent abstracting the shit out of things that should be simple is incredible. Developers need to learn that every fucking thing does not need to be hidden under piles of misdirection, callbacks, abstraction and burned cycles.

    6. Re:Not being a metric ton of bit rot by Anonymous Coward · · Score: 0

      I just completed a complex project that integrates with pretty scary existing system. It is 95% bugs at this point, yet does not make it bad code. Most bugs will get weeded out over a few weeks, as long as code is easy to read and maintain.

      With that many bugs, I think it's fair to call it "bad code," since it doesn't do what it's supposed to and large parts of it will need to be rewritten. That doesn't make you a bad programmer, but consider this: why are you making those errors? Wouldn't it be better to skip them in the first place, instead of fixing them later?

      During my early career learning C programming, I created a lot of VERY buggy code, until I forced myself to do 2 things:
      1.) look at each line after I've written it (maybe wait until finishing the function) and "executing" it in my head
      2.) every time I fixed a bug, I wrote down the reason the error was made. I kept that list taped to my monitor and forced myself to run down the entire list every time I finished a module and *before* compiling it.

      Let me tell you, it doesn't take long to pick up good habits just to avoid the tedium of running down that list. My code improved 100x in the space of about 2 months! Most of it compiled on the first or second try, and ran correctly maybe 95% of the time. The 5% was usually due to something I forgot to implement rather than broken code.

    7. Re:Not being a metric ton of bit rot by Shompol · · Score: 1

      why are you making those errors?

      ...because it "integrates with a pretty scary existing system". Something written from scratch would have much much fewer. I guess it does speak of quality of the code but also depends on the quality of data it has to work with, external interfaces, changing user requirements, etc.

  23. Code Complete by Anonymous Coward · · Score: 0

    The rules in "Code Complete" make for good code. Just read it and do everything it says.

  24. Anything not written by by Anonymous Coward · · Score: 0

    - My coworkers
    - Google
    - Microsoft
    - Twitter
    - Amazon

    is good code. just for starters.

  25. Rhyming variable names by gurps_npc · · Score: 3, Funny
    Yes, that is the key measure of how good your code is.

    If you have no rhyming variable names, then your code sucks. 1 stars

    If you have one or two, it is barely acceptable. 2 stars

    Half rhyme, then 3 stars.

    If most, but not all, rhyme, 4 stars.

    If every single variable rhymes with at least one other variable, you have a great job, 5 stars.

    To get the coveted 6 stars, all the variable names have to rhyme with each other.

    --
    excitingthingstodo.blogspot.com
    1. Re:Rhyming variable names by Anonymous Coward · · Score: 0

      The new naming convection is to append _orange, to all variable names.

      -PHB

    2. Re:Rhyming variable names by ckatko · · Score: 1

      Rhymetime With Eminem - How do you rhyme with the word orange?

      https://www.youtube.com/watch?...

    3. Re:Rhyming variable names by Anonymous Coward · · Score: 0

      Playing by the rules is boringe.

  26. Why must it fail? Re: must fail by davidwr · · Score: 1

    Some code is small enough that it's feasible to prove that the code is correct, assuming that the underlying hardware, libraries, operating system, etc.. don't fail. For example, in most languages you really don't need to put error-checking in code as trivial as this pseudo-code:

    boolean isGreater(int a, int b)
    {return (a>b);}

    Sometimes, particularly when running in "small/tight" or real-time environments or when security is more important than debuggability, you may want a failure to be nothing more than something basic like "return -1" or "turn on aralm and halt the CPU" or even "flush caches, destoy security keys, and power off."

    But you are corrent, in most cases good souce code will have good, clear, easy-understand debugging code.

    --
    Knowledge is how to play a game, intelligence is how to win, wisdom is knowing what game to play.
  27. Define "Good" by mykepredko · · Score: 1, Informative

    This type of article comes up continuously on /. and without some concrete defining attribute asking what model/version/etc. of "X" is "Good" is going to turn into a poll.

    I would consider "Good" code to have the following attributes:
    1. Runs under all operating systems and platforms
    2. Source code is readable (note, this does not mean "Well Commented")
    3. Takes up the minimum amount of space
    4. Operations execute either apparently instantaneously or provides a progress bar for the user
    5. Installs quickly
    6. It's operation is intuitive
    7. Does not share user information
    8. Supports many/all user languages
    9. Does not have extreme licensing conditions
    10. Is free
    11. Source code available

    If I thought about it for another five minutes, I could probably double this list.

    And, it's *my* list of what I would look for in "Good" software, I suspect for anybody else here, YMMV.

    myke

    1. Re:Define "Good" by Zero__Kelvin · · Score: 1

      "1. Runs under all operating systems and platforms"

      Nothing like starting out of the gate with impossible to achieve goals.

      --
      Guns don't kill people; Physics kills people! - John Lithgow as Dick Solomon on Third Rock From The Sun
  28. diversity! by digsbo · · Score: 3, Funny

    When it's written by a gender and race balanced team, in a positive, multicultural environment, then it's good code!

  29. Most important criteria by Anonymous Coward · · Score: 0

    By far the most important criteria is that the code must be easy to maintain. People with many years of coding experience will relate to this

  30. I like eligant code by Karmashock · · Score: 2

    That is... as brief as it can possibly be to accomplish the stated goal. Very simple.

    I also like it when the code is commented properly so that every operation is broken down and and annotated to explain what it is doing.

    This lets me go through the whole program and see what it is doing and the way it is doing it very quickly.

    The code that makes me crazy is the rube goldberg code that does some thing very simple in the most elaborate way possible, has no annotations so I have no idea what the actual point of the code is, and then to make things worse various parts of the code will randomly switch between doing different things for no reason.

    THAT code I hate. I see that shit and I delete it and write over myself.

    Part of the problem is that people don't know how to do somethings. They understand the language but they haven't memorized the really short code snippets that are the ideal way of getting from point A to point B. And that's just something a programmer should either have memorized or stored somewhere for recall.

    Using those code snippets tends make the code far more elegant and much more readable because you can see beyond the annotations what they're doing because you recognize that snippet.

    If they never use them, that is fine too... just so long as they don't make their code look like that breakfast making machine from Chitty Chitty bang bang. If they do that, I will murder them all. :-D

    --
    I've decided to stop wasting my time responding to AC trolls/sockpuppets... so if you want a response from me... login.
  31. Obviously by itzly · · Score: 0

    When it has two functions, written by two different female programmers, that call each other recursively.

  32. I'd start with by GerryGilmore · · Score: 1

    ...not having your fucking article spread across 9 pages with about one paragraph per page. That would be a great start!

  33. Re:Compactness and Readability by Yunzil · · Score: 5, Insightful

    It communicates clearly what it is trying to do.

    It doesn't, actually. Looking at that as someone who doesn't know what a CRC32 is I have no idea why it's doing what it's doing. Some actual useful comments might be nice.

  34. Time by El_Muerte_TDS · · Score: 3, Insightful

    After 5 years you can still read it and understand what it was supposed to accomplish, and it does so.

    1. Re:Time by istartedi · · Score: 1

      Scrolled down for this. I would add, "time and testing" and "testing" usually involves wide distribution. Yes, JPEG, PNG and Open Source compression libraries have had bugs, sometimes very serious ones. I still consider it some of the best code out there. I don't think being able to read the code matters. That's a red herring, unless you need to work on it. If everybody needs to work on it, it's too unfinished to be particularly good code. The only thing I've read in some of these libraries is the headers, and mostly the comments in there. It was literally self-documenting in comments the last time I looked at it. That's some good code.

      --
      For all intensive purposes, "whom" is no longer a word. That begs the question, "who cares"?
    2. Re:Time by phantomfive · · Score: 1

      I don't think being able to read the code matters.

      Then you're talking about the quality of the API, not the quality of the code. If for some reason you became a maintainer, then you would care quite a bit about being able to read the code.

      --
      "First they came for the slanderers and i said nothing."
  35. Impossible to answer by Murdoch5 · · Score: 1

    Good code starts with the right language for the job and the developer, then you have to follow the best practices for that language. How I program in C# and PHP is far different from how I program in C and ASM. The one thing that doesn't make code is abundant use of catch phrases.

  36. chocolate. dark chocolate. by swschrad · · Score: 2

    not to be confused with code that sorta looks like it, but surely doesn't smell like it...

    --
    if this is supposed to be a new economy, how come they still want my old fashioned money?
  37. Re:Compactness and Readability by Anonymous Coward · · Score: 0

    Could be less than 27 lines, D-.

    void crc32_init() { for( short byte = 0; byte 256; byte++ ) {uint32_t crc = (uint32_t) byte; for( char bit = 0; bit 8; bit++ ) ...ann so on
               

  38. Simple by Elixon · · Score: 3, Insightful

    I would definitely add "simple". Everybody can write complex code but it takes experience and great knowledge to be able to choose the best fit for the implementation. More experience and knowledge you have more options to choose from. Beginner will usually go with the first hunch that will get complex sooner or later as he will meet challenges he didn't expect...

    So yeah, simple, readable, documented, functional, consistent...

    --
    Well, I've got to get back to work. When I stop rowing, the slave ship just goes in circles.
    1. Re:Simple by Anonymous Coward · · Score: 0

      I'd qualify that: Code should be only as complicated as the problem.

      I've written code that is quite complex because it needed to deal with a number of corner cases, as well as unexpected user inputs, whilst maintaining a reasonable performance. But its only complex because of the complex problem space.

  39. Cumbered by fyngyrz · · Score: 1

    And this is why closed source combined with black-box development is so much safer than open source. Sigh.

    I really don't mind -- actually, I think I'd be kind of of flattered -- if people were able to look at my code, go "hey, I can use that" and then proceed to use it. And in fact, I've written a fair bit of code I think would fall into that vein. I think I could write something book-length in the line of "cool coding stuff" and quite a few programmers would find it quite useful. I've been doing this since the early 70's. I write signal processing, and image processing (but I repeat myself, sorta) and AI code, with a strong background in embedded and special-purpose systems, a bunch more.

    But because a lawyer might look at my code, and use it to screw me, and through me, my family and employees quite harshly?

    Bang. Closed source. The opposite of furthering progress by virtue of passing along what I've learned. I give away some of my work product such as this, but you will never see my source code because of the legal environment.

    As far as I'm concerned, if I wrote it without referring to "other" source code, then no one else has any claim on my work. I don't have any idea how to fix copyright and patent and still retain the supposed commercial motivation to create, but fact is, as it stands, it's completely fucktarded.

    Pisses me off, it does. :/

    --
    I've fallen off your lawn, and I can't get up.
    1. Re:Cumbered by Bill+Dog · · Score: 1

      I would never even give away a program binary, let alone source, because even patents and copyrights aside, someone could use your code in their business and if something goes wrong, they could claim it's your fault and you cost them x thousands of dollars and then try to recover it from you in a lawsuit. I don't need patent reform, I need legal immunity; something like a good samaritan law for software.

      --
      Attention zealots and haters: 00100 00100
  40. Everybody's missing the most important stuff. by Anonymous Coward · · Score: 1

    No one's even mentioned the Bechdel test yet.

  41. You only coded what was needed, and its testable by Anonymous Coward · · Score: 0

    You only wrote the code I asked for to meet my requirements.

    If it's unique code, you did NOT write it to fix every possible future use of said code.

    If it's not unique code, and it's something we already have a library for, you used that library, correctly, and didn't reinvent the fucking wheel.

    You followed our coding conventions (regardless of how arbitrary or silly they are) and did not suddenly start your own coding convention just to be different.

    And most importantly

    You covered your code 100% with FUCKING TEST CASES that actually work, and pass. This obviously means that you also wrote the code to be testable (no methods with 5000 lines of code in them, and 30 input parameters).

  42. Re:Compactness and Readability by BarbaraHudson · · Score: 1

    _When_ was the last time you actually needed a different CRC function from the standard 32-bit one?

    When trying to create unique crcs to use as hashes for 8 billion pieces of data daily so as to find them quickly. 32 bits isn't enough. 64 bits is way more than enough.

    --
    "Transparent" is a shit show that trades on every stereotype going. A man in drag is NOT a transsexual.
  43. Vowels by rjstanford · · Score: 1

    Seriously. Good, readable names for everything make code far more self-documenting than otherwise, don't cost the compiler a single cycle, and make it far easier to understand when someone comes across it five years down the road.

    Other than that, I'd add methods that only perform one action, with no side effects, and that only work at one level of abstraction.

    Finally, code that matches its method name - don't say "if thing.checkValues()", say "if thing.isValid()" - and if isValid() does anything like trimming whitespace it should do it on its own transient copies of things, since its not obvious that the method would ever change state.

    And so on. It all boils down to code that doesn't surprise you.

    --
    You're special forces then? That's great! I just love your olympics!
  44. Two additional items by Anonymous Coward · · Score: 0

    For me the big thing is documentation. Whether it is my code (from the past) or someone elses, I need to know what it is doing, what it is supposed to do and why. The best thing I can hope to see in a source file is a lot of clearly written comments.

    Having code that does error checking and throws clearly defined errors is nice too.

  45. It's not that hard. by paavo512 · · Score: 3, Interesting

    Good code has documentation for knowing what it should do, and has unit tests to verify that it actually does that. If there are any problems good code can be modified to meet the (possibly changed) requirements better, while unit tests ensure the modifications do not make the code worse. Code which cannot be modified is not good code. It's that simple.

  46. no hungarian notation! by Virtucon · · Score: 1

    I don't care how bad or tangled the logic but as long as it's not using Hungarian notation, It's good.

    --
    Harrison's Postulate - "For every action there is an equal and opposite criticism"
    1. Re:no hungarian notation! by __aabppq7737 · · Score: 1

      Agreed. IDE's have fixed Hungarian notation - Simonyi lived before modern development environments came along.

    2. Re:no hungarian notation! by Livius · · Score: 1

      Hungarian notation was fabulous for its intended purpose: code that mixed C and assembly language.

      Sadly it escaped.

  47. Re:Compactness and Readability by __aabppq7737 · · Score: 1

    There needs to be a compiler (not language) that can convert mathematical proofs to an optimized assembly listing. How it would work, the files it would take in, and who would use it - I don't know.

  48. Re:Compactness and Readability by Anonymous Coward · · Score: 0

    That is a fairly typical CRC setup. Make a lookup table. Use that table to 'and' and 'power' with in a loop across the input data.

    It is done that way to speed up the computation. CRC is a fairly common operation so it has been optimized over the years.

    Someone who has never made a CRC function before? Yeah it probably looks like gibberish. As it is pretty much polynomial math with some optimizations.

    Whomever made it should have put a comment they were using the optimized version and what the original function was. The original function is probably much more readable. But MUCH slower (if I remember correctly ~40x slower).

  49. Re:Compactness and Readability by Anonymous Coward · · Score: 0

    Library code is often like that. It's mostly a result of having to work on multiple compilers, and multiple versions, and numerous language options and versions. Also CRCs aren't limited to 32-bit, and the library handles general cases. Library code is different to program code. Your code isn't suitable for a library. The error handling, for example, specifically uses printf, where a library would return an error state, or, in the case of C++, throw a standard exception. This is because someone might not want to use printf for errors. So here's my code:

    #include <boost/crc.hpp>
    typedef boost::crc_32_type crc_type;

    I think you're comparing program code to library code. The only way you'll get elegant library code is if it only works with one version of a compiler, using one version of a language, and with a single set of options. Otherwise, it's lots of engineering to cope with quirks, and macros galore.

  50. It's good if they don't code like 90s C++ devs by gestalt_n_pepper · · Score: 4, Interesting

    Their whole mindset still makes me want to puke.

    Obfuscated crap. Techno-machismo teens playing games trying to get their code into the least number of characters and the least amount of memory. I've had to fix or test so much of this junk and it's still just plain stupid.

    The *human* part of the system is what *matters* and that includes the code interface. First, I want comments not about *what* is happening. I can read that. I need to know *why* it was done, so I don't undo it, or I can do something different safely. Comments should be one liners, limited to "why" and sometimes "how".

    If adding a variable aids readability, add the fucking variable! Shove all the results into a meaningful, readable variable name and then shove *that* into your function argument, not some long series of nested function. It's not the 90s. You don't have to save memory! Memory is there to make your code readable. Use it!

    Ok, rant over. I'm going back to work now.

    --
    Please do not read this sig. Thank you.
    1. Re:It's good if they don't code like 90s C++ devs by Voyager529 · · Score: 2

      Techno-machismo teens playing games trying to get their code into the least number of characters and the least amount of memory.

      Given how many programs I've used over the past decade that have required unreasonably high amounts of RAM, and/or were subsequent releases of software that solved a particular problem in earlier iterations but required 1/10th the memory to do it, I wouldn't mind a handful of these guys getting their desks back. Adobe is a great place to start.

      I've had to fix or test so much of this junk and it's still just plain stupid.

      I'm by no means a programmer, but from the handful of times I've seen what you're talking about, I'll say this: if it's possible to save 10% of RAM by shifting the ease-of-use burden to the comments instead of the actual code, then as an end user, I'm 100% in favor of commenting the everloving hell out of difficult to read code that saves RAM when users are running it.

      You don't have to save memory! Memory is there to make your code readable. Use it!

      Wrong. Use as much as necessary, but no more. I might have 12GB of RAM in my laptop, but it's not all for you. It's for EVERYTHING I do, and when I start adding VMs or large After Effects projects to what I'm doing, 12GB starts to get pretty cramped. Some RAM usage will be inevitable, but wasteful RAM usage is wasteful.

      I most certainly have plenty of admiration for the Demoscene.

    2. Re:It's good if they don't code like 90s C++ devs by Anonymous Coward · · Score: 0

      This is so amusing! I have spent countless hour fixing code by clueless idiots like you who believe that hardware is an inexhaustible resource. At the start of the project it might seem that way but when you get more and more code in there you have to spend hours optimizing a clueless fresh out of university codes bloated code to get the last bytes you need to get shit running. Im amazed by the amount of people who get into coding that don't have the brain for it. "I can understand your code." "What does this '?' do?" "Why cant I have all my variables static?"

      I work with embedded systems so I cant just tell the user to but more RAM or CPU, what you see is what you got. People who write code for stupid people and not for machines should not write code.

    3. Re:It's good if they don't code like 90s C++ devs by Anonymous Coward · · Score: 0

      1. No amount of comments increase RAM usage for the user.
      2. Most large software isn't large because it has been written clearly. I would argue quite the opposite for the hundreds of extra mega and gigs that Apps take.

    4. Re:It's good if they don't code like 90s C++ devs by drinkypoo · · Score: 1

      If adding a variable aids readability, add the fucking variable! Shove all the results into a meaningful, readable variable name and then shove *that* into your function argument, not some long series of nested function. It's not the 90s. You don't have to save memory! Memory is there to make your code readable. Use it!

      If that's all the variable is used for, won't the compiler optimize it out of existence anyway? Or is that too fancy yet?

      --
      "You're right," Fisheye says. "I should have set it on 'whip' or 'chop.'"
    5. Re:It's good if they don't code like 90s C++ devs by tapspace · · Score: 1

      I think a lot of people don't really understand how the compiler actually works. Not even at a basic level. If I make three different loop variables (int types) for three different loops which run at different times in a function (let's say this improves readability), any modern compiler worth its salt will only use the space of a single int for these three (because they are never used together). In my experience, many programmers, even mid-level, would not know that. And, this doesn't even require an understanding of how a compiler works. This is SUPER basic compiler understanding. This leads to poor attempts at "optimized" code which saves nothing (because they compiler will do the same thing to the machine code) and detracts from readability and maintainability.

    6. Re:It's good if they don't code like 90s C++ devs by drinkypoo · · Score: 1

      If that's all the variable is used for, won't the compiler optimize it out of existence anyway? Or is that too fancy yet?

      I think a lot of people don't really understand how the compiler actually works. Not even at a basic level.

      Well, no, I don't. That's why I asked. It sounds like the answer to my question is yes?

      --
      "You're right," Fisheye says. "I should have set it on 'whip' or 'chop.'"
    7. Re:It's good if they don't code like 90s C++ devs by Anonymous Coward · · Score: 0

      Like you said, your no programmer. Adding a variable to put it in a function call is removed by the compiler who creates more efficient code.

      Code clarity over "perceived efficiency" all the time. Nowadays no programmer can beat the compiler, linker, and then the way each memory/CPU architecture deals with the compiled code anyhow. Clean-code brings you decades of easily maintainable code.

      99.99% of the "code efficiency" in code I have seen in the last decade where based on outdated assumptions from the 90's that does not apply to modern compilers and hardware.

  51. Editable by mdfst13 · · Score: 1

    One of the most important criteria is that good code be easy to modify. Readability, testability, elegance, and simplicity all lead back to that. When you change code, you should be assured that it will do what you expect. Bad code produces surprising side effects when you change it. Good code warns you (possibly through unit tests attached to the code) when you are doing something questionable. If you have to run the code to determine what it does, then that's not good code.

    Needs evolve and change over time (or simply become clearer). Good code needs to be able to follow.

  52. Easy to refactor by Anonymous Coward · · Score: 0

    Good code does exactly what it needs to do, no more, no less. It does everything in the simplest, most obvious way. It should be possible to cover every piece of business logic with tests (if not, why is the logic there in the first place?).

    Combined, these traits should make it possible to refractor across the entire codebase when somebody else has to add something new. You can't anticipate everything, so don't add complexity up front to deal with a possible future which may not come to pass - focus on making it easy to make changes.

    1. Re:Easy to refactor by ChrisMaple · · Score: 1

      It does everything in the simplest, most obvious way.

      So.......bubble sort.

      --
      Contribute to civilization: ari.aynrand.org/donate
  53. Good? by PPH · · Score: 1

    Spaghetti code is good.

    With lots of meatballs.

    --
    Have gnu, will travel.
  54. Re:Compactness and Readability by Anonymous Coward · · Score: 0

    and how would the compiler read your proof? it has to be in a compiler readable language.

  55. BS by Anonymous Coward · · Score: 0

    Windows = hugely dominant on PC + Server platforms worldwide for decades (before there were smartphone toys) so until you can show otherwise you're full of it. C & C++ are also hugely used in the *NIX world for decades before it as well before there was PHP or Java. Thus, when a language is used for so much longer and on so many things, it's going to have more users of it since that's where the money is to be made. Period. Your illogic logic astounds! It's hilarious seeing bs come out of some youngster like you that thinks he knows it all and only showing us he knows nothing since he hasn't gained any experience or wisdom yet (as is the case with youth).

    1. Re:BS by Anonymous Coward · · Score: 0

      Windows = hugely dominant on PC + Server platforms worldwide for decades

      It's 2015. The first version of Microsoft Windows that was an operating system (rather than an application running on DOS) was Windows 95, which was released in August of 1995 and didn't become dominant for some time. So not even two decades have gone by yet.

    2. Re:BS by Anonymous Coward · · Score: 0

      Windows NT 3.1 was released in 1993 and was pretty popular, and was a 'proper OS'. Windows 95 wasn't really much different from Windows 3.x 386 enhanced mode, so not sure that bit of your argument stands. Regardless, everyone with PC ran Windows, and everyone wanted GUI / mouse driven applications. Windows 3.0 was released in 1990, so well over two decades of Windows dominance have passed.

    3. Re:BS by rHBa · · Score: 1

      Fair enough Windows has been dominant in the PC market for decades but you can hardly say it's been dominant on server platforms for decades (ever?). Maybe for intranet use but as far as internet facing, mission critical servers UNIX, BSD and since the late 90s Linux has been dominant.

    4. Re:BS by Anonymous Coward · · Score: 0

      I think you'll find Windows NT predated Windows 95 by a couple of years. Windows 95 was an unholy hybrid 16/32-bit abomination that still had MS-DOS (7 IIRC) at its core. That's when I jumped ship to Slackware.

    5. Re:BS by MightyMartian · · Score: 1

      On PC platforms perhaps. Not on server platforms.

      --
      The world's burning. Moped Jesus spotted on I50. Details at 11.
    6. Re:BS by Anonymous Coward · · Score: 0

      You're replying to a typical Pro-*NIX /. troll attempting to 'spin' things with falsehoods. Ignore the dolt. He's demonstrating ignorance if he didn't know that or again, attempting to bs everyone (especially trying the "it's now, not then" failing to realize the THEN has had time to gather tons of followers/users using successful tools like C/C++ on ALL platforms).

  56. Not a single answer by swan5566 · · Score: 1

    Coding a prototype of something that's rapidly changing in huge ways should be done differently than production code that's worked on by lots of different developers. One will not be optimal for the other.

    --
    In debates about Christianity, there are two groups: those looking for answers, and those looking to just ask questions.
  57. data structures first / control flow second by mspring · · Score: 1

    Code is good when the data structures clearly model the problem domain. The algorithmic code / control flow then follows naturally and is easier understandable.

  58. :( Can you help the world? Re:Cumbered by davidwr · · Score: 1

    Take all work you've written and entrust it with someone who will publish it a few years after you die and after your estate is settled or a few years after the last company that would have any claim to it ceases to exist, or after any copyrights or patents other than yours that apply can reasonably be presumed to have expired (probably 95 years after you wrote the code), whichever comes later.

    --
    Knowledge is how to play a game, intelligence is how to win, wisdom is knowing what game to play.
  59. Slashdot Friday brought to you by ... by plcurechax · · Score: 1

    The Wayback Machine...

    Or, see the Slashdot article, "Beautiful Code Interview" that discusses an entire book about the very topic.

    1. Re:Slashdot Friday brought to you by ... by Anonymous Coward · · Score: 0

      That's a great book. I recommend it highly!

  60. The label does not read... by Anonymous Coward · · Score: 0

    "Made in India".

  61. Short modules / Clear variable naming by blueshift_1 · · Score: 1

    I agree with most of the earlier posts, but the main thing I look for is conciseness and clear & consistent naming of variables. If your methods/procedures/classes/functions/subroutines are are obnoxiously long, it makes it less readable, harder to test, and just longer to debug. Modular design also lends itself to be more reusable. I've always been of the mindset to name your variables what they are. You shouldn't have to go to a comment or read the code to see what it does. It should speak for itself - even for someone who isn't super familiar with your code/project. Or at least that's what I think...

  62. Re:Compactness and Readability by Anonymous Coward · · Score: 0

    There needs to be a compiler (not language) that can convert mathematical proofs to an optimized assembly listing. How it would work, the files it would take in, and who would use it - I don't know.

    Mathematical proof is only a tool the arithmetic optimizer can use, it's not something that you can generate code from.
    Most of the time it doesn't work, because the compiler has an obligation to follow the ISO/IEC/IEEE 60559:2011 standard and mathematical proofs that takes intermediate rounding into consideration is complicated.

  63. Nobody likes range checking? by bughunter · · Score: 1

    Yanno, it's been years since I've coded (beyond looking thru code to tweak a definition here or there anyway). Decades, even.

    But I was taught on the job that range checking of inputs and boundary conditions was essential to reliable code.

    Obligatory XKCD reference.

    --
    I can see the fnords!
  64. Beautiful, optimized, and easy to maintain by maroual · · Score: 1

    When it is done by people, code can be art sometimes. I have no good example immediately available, but I mean there is a huge difference between generated code such as jquery-1.11.2.min.js and code that can be read by humans. By optimized, I mean the lowest time and space complexity during run time. And there are basic and obvious maintenance constraints that everybody should follow like avoiding hardcoded values (unless necessary), keeping it easy to read, avoiding +1000 lines routines if not necessary, ... Regarding debates on comments vs self explanatory variables, I have no opinion on this. Depends on how it's done.

  65. Re:Compactness and Readability by Anonymous Coward · · Score: 0

    Library code is often like that. It's mostly a result of having to work on multiple compilers, and multiple versions, and numerous language options and versions.

    And most of all, they aren't used just once, so there is a reason to go back and clean up and clarify and optimize.

    For a lot of other code you write it once and forget. As long as it works there is no reason to go back and tidy up the code.

  66. the easy test by Anonymous Coward · · Score: 0

    does it do something you need done that has not been done before, or has not been done before as efficiently?

    too many people reinvent the wheel (which is why linux on the desktop is always such a huge fucking mess and will never challenge windows or mac in that arena). when something works, and it's available to use (via licensing), then use it. don't run off and do all the work all over again, or fork the shit out of it.. just use what's already there if it does the job you need done.

  67. Doesn't handle real-world conditions by Anonymous Coward · · Score: 0

    Clean, elegant code doesn't handle real-world conditions where exceptions, workaround, and hacks build up over time. "Bad" code is usually battle-tested and bullet-proof code that has been deployed in the real world and has built up screen after screen of special conditions, hacks, workarounds, exceptions, and so on to handle the conditions encountered in the wild. So good code at least has comments explaining why each hack is in place and what it works around and what problems it solves.

  68. You know your code by Anonymous Coward · · Score: 0

    You know your code is good when other developers use it with out feeling the need to rewrite it. As a software manager I find that an important trait of a successful developer is having the discipline to program to an existing interface. Cleanliness (in C++ formatting, static analysis, correctness, properly sized methods) are all important. Isolation from hardware and unit tests, are IMHO, paramount. I actively weed out the cowboys who suck all the oxygen out of the air and rewrite everything. Also, I find outside of driver development, tend to EE's make lousy developers.

    1. Re:You know your code by Anonymous Coward · · Score: 0

      Cleanliness (in C++ formatting, static analysis, correctness, properly sized methods) are all important.

      Do you mean that they all are important, or that they are all-important?

  69. Re:Compactness and Readability by painandgreed · · Score: 1

    Good code does one thing well:

    It communicates clearly what it is trying to do.

    Personally, I'd say that good code does what it is trying to do. Great code will do that and communicate what it is doing clearly.

  70. MOST IMPORTANT by Celarent+Darii · · Score: 1

    Code has to be AVAILABLE - this is the most important. That means it must be OPEN SOURCE.

    If it is CRAPPY code, it can be MADE BETTER if it is open source.
    If it is INEFFICIENT code, it can be REWRITTEN if it is open source
    If it is HARD TO UNDERSTAND code, it can be COMMENTED if it is open source.

    So any code that is OPEN SOURCE, even if it is crappy, inefficient and hard to understand, can be improved.

    But any code that is CLOSED is absolutely useless in my opinion.

  71. Here's what good code is to me.... by purpledinoz · · Score: 1
    • Functions that span 1000 lines with heavily nested if and switch statements and behaves differently depending on global variables
    • Massive 10k line classes that are more mystifying than God himself
    • Everything is an interface because you may want to create a mock for it, and you get multiple inheritance!
    • No comments. Code essentially comments itself!
    • Functions should create side effects, otherwise life would be boring.
  72. Plan B by Krishnoid · · Score: 1

    ... functional, readable, testable ...

    From the maintenance perspective, when you can't make the code meet some standard, comments describing what you missed and why (time, spec conflicts, didn't care enough) are helpful. This hints to the next maintainer that modifying a piece of code that missed some good-practices target has additional considerations or hidden pitfalls, or that it can be fixed/extended/replaced with impunity.

  73. XKCD Explains Good Code by Anonymous Coward · · Score: 0

    Good Code

    'Nuff said.

  74. Bad question. by Anonymous Coward · · Score: 0

    What are qualities of a good movie? What are the qualities of good art? How about what's good music? Nobody has been able to come to conclusions to whhat the essentials of goodness for any of the above are. Why would good code be any different?

    "Good" is inherently subjective, and will vary highly. You can phrase the question: "What do YOU think good code is?", but there's no general answer

  75. Re:You only coded what was needed, and its testabl by mr_mischief · · Score: 1

    You skipped the case in which it's not unique code but for which you don't have a library.

  76. Re:Compactness and Readability by Anonymous Coward · · Score: 0

    What the hell is this?

    /* */ uint32_t CRC32_Table[256] = { 0, 0, 0, 0, 0, 0, 0, 0, 0 }; // i.e. 0x00000000, 0x77073096,

    Why is there a block comment at the beginning that does nothing... and what the hell does that trailing comment mean?

  77. Routine code by Anonymous Coward · · Score: 0

    The best code must have something that is very special - although all good code should look simple and even boring to those not paying attention.

  78. Edge cases by Daniel+Hoffmann · · Score: 1

    Good code has comments for edge cases, I mean "why the fuck are you checking if foo is less than bar?" with "//checking if foo will not overflow because ..."

    Edge cases are by definition very unlikely, usually the code that handles them are bugfixes. Too many times I come across code that is full of bugfixes for those edge cases but no comments whatsoever, to me those kind of comments are more important than method comments (aka javadoc).

  79. Re:Compactness and Readability by Anonymous Coward · · Score: 0

    It doesn't, actually. Looking at that as someone who doesn't know what a CRC32 is I have no idea why it's doing what it's doing. Some actual useful comments might be nice.

    Well said. Also, not using Hungarian Notation in the variable names would also improve its readability.

  80. Brevity. by Anonymous Coward · · Score: 0

    Every line you add increases your maintenance burden.

  81. Re:Compactness and Readability by itzly · · Score: 1

    If you need a 64 bit hash, write a special 64 bit hash function. It's only going to take a few lines, and removes dependencies on bizarre external code, like 64 bit CRC that nobody ever uses.

    Besides, CRC functions aren't very good for hashing, as CRC(x) XOR CRC(y) = CRC(x XOR y)

  82. Re:Compactness and Readability by Dr.+Evil · · Score: 1

    Over-commenting is a very real problem, and CRC32 is CS101. If I was reviewing code which described what CRC32 was, I would remove the comments.

  83. Re:Compactness and Readability by Anonymous Coward · · Score: 0

    He was saying good code communicates clearly, not the code above.

    Also, you don't really write comments in code unless it's doing something unusual. Comments are for WHY something is being done, not what is being done. The what is already explained by the code. You don't know what CRC32 is because you don't need to (and that's ok). If you were in an industry or hobby where you did, you would know because CRC32 is pretty ubiquitous.

  84. CS is only practical by accident, but that's okay by Tenebrousedge · · Score: 1

    Computer Science is [a] a misnomer, and [b] more properly a subset of mathematics. I might characterize it more as giving you tools to reason about code rather than teaching coding practices. It is not generally meant to be a practical education. There is always time to learn the practical stuff, and the practical stuff changes often enough that it's not necessarily worth teaching.

    I'm in the opposite camp: I'm self taught, and know a bunch about deployment and the intricacies of source control, and refactoring, but very little about, oh, algorithmic complexity or parser/compiler design. The theoretical stuff isn't quite as useful on the day-to-day as the practical knowledge, but it's much more useful when trying to learn new things. Similar to how you don't necessarily need music theory to play guitar but if you want to transpose a piece of music or pick up a new instrument, it would be pretty useful. Composing a piece of music might be more like writing a compiler. In both cases you'd be relying heavily on theory.

    If you thought you were signing up to learn how to be a programmer, you've made a mistake, but it's not so bad as you think. The stuff you're learning is useful, even if it doesn't seem like it. I feel like I could stand to know quite a bit more about it myself. And the lesson is, that you need both parts, and you'll miss whatever you don't have, but you miss the practical stuff all the time, and the theoretical stuff only when it's really, really important.

    --
    Those who advocate genocide deserve every protection afforded by law, and none afforded by common human decency.
  85. What makes some web sites particularly bad? by Anonymous Coward · · Score: 0

    When one has to wade through a "slide-show" presenation, intended to maximize page clicks/ad revenue, instead of just reading an fricking article.

    And this is *after* being presented with a 20-second interstitial ad.

    BLEAGH.

  86. Absolutely. Thanks. CS and Programming are fucked. by Anonymous Coward · · Score: 0

    Absolutely. Thanks. CS and Programming are fucked.

    Nobody in power to actually improve the situation seems to understand that current programming practices and goals, exacerbated by the usual management stupidity, results in a continuous spiral downward of code quality. security, reliability, maintainability, etc.

    You cannot achieve the impossible, and aiming for it, and requiring it, simply means that defects will be hidden, often until they can cause the most possible damage.

    The profession and industry desperately need broadly applied engineering practices and requirements. Including licensing. Will never happen, because too many coding cowboys and lucky CEO's of tech companies think their shit don't stink.

  87. Do the job now and later by Ted+Stoner · · Score: 1

    The first thing is, most of us are coding as house painters rather than as Rembrandt. So it needs to do the industrial job. I tend to put as much effort into documentation and style for my personal code as for working code.

    If the code is for a micro-controller in C then the emphasis might be more on raw efficiency and preciseness. A command line utility run ad hoc with low resource usage can afford to be a little less efficient and more readable. Code for an online transaction system needs the efficiency, perhaps as a tradeoff to readability but in most cases hopefully not.

    I have written code and products and have had to go back to stuff I wrote 15 years ago. So I learned a long time ago to document as clearly as possible for the poor sod in the future (i.e. me) who will have to come back and make sense of everything. Mostly I succeed here but sometimes I fail.

    I also supported other people's assembler code for a few years. That provides lots of what not-to-do's.

    If you are coding examples for a book or website then the rules and aesthetics can be changed again. Maybe think more Rembrandt here.

    Functionally, document everything, use meaningful and consistent naming conventions, catch errors, log, provide trace capabilities where needed, be as generic as possible and think about reusability but don't obsess over it (depends on the context as always).

  88. Elegance. by DriveDog · · Score: 1

    Elegance.

  89. Re:Compactness and Readability by Kjella · · Score: 1

    Well in this case I'd say there's Google and Wikipedia, use them. The source code is not the right place to teach someone about what CRC32 is or when, where or why you might want to use it. It's almost as bad as comments that try to teach you the programming language you're in. If you're implementing something that's not in an RFC or standard of some sort, I'd agree with you.

    --
    Live today, because you never know what tomorrow brings
  90. When it pass the.... by Anonymous Coward · · Score: 0

    When it passes the modified Bechdel Test of course.

  91. Where to begin... by Anonymous Coward · · Score: 0

    Tooooo many points of uncommon good practice to mention.

    Document interfaces and algorithms, but don't over-comment.

    Make public headers CLEAN and with 100% correct descriptions. Do not put private declarations in public headers (I see this all the time and I hate it).

    What else....
    Decouple program flow code and data declaration code.
    Be CONSISTENT with names and tabs and formatting.

    Emphasize structure of DATA over structure of code.

    Don't unnecessarily copy data around or duplicate things.

    Don't re-define the language via macros.

    ( Can you tell I'm a C programmer ?? )

    1. Re:Where to begin... by MichaelMacDonald · · Score: 1

      Code headers are nice, but if code is properly written and structured they can be overkill and clutter, so I don't see them as mandatory in all cases. Otherwise, I like this :D. Divide your code into separate source files using logical divisions that make sense. Then create libraries if one of the divisions gets big enough. Try to emphasize reuse.

  92. Re:Compactness and Readability by Anonymous Coward · · Score: 0

    CRC32 is CS101

    Bullshit. I have never heard of CRC before today. I understand it and see why it's important, but it certainly didn't come up in CS101.

  93. Good Code Metircs by prefec2 · · Score: 1

    There are several metrics which can help you to identify code which is not bad. One is cyclomatic complexity. Another are connectivity metrics going over the graph your code spans. For cyclomatic complexity there are good boundaries available. However, it is a complexity metric. And complexity is not the only thing which affects code quality. Other elements are labeling operations, such as methods, functions, and procedures. There is plenty of lit. available in the area of code comprehension.

  94. It's a trick question by Anonymous Coward · · Score: 0

    It's a trick question. There is no good code.

  95. Argue w/ the numbers by Anonymous Coward · · Score: 0

    What's the server to PC ratio? Let's say a few million to 1 (it's huge): What runs the most on PC's? Windows. I've seen stats showing it's about a 50/50 split on servers vs. *NIX variants (who have to be lumped all together to compete with Microsoft products). See subject. No spin is possible vs. hard fact.

    1. Re:Argue w/ the numbers by MightyMartian · · Score: 1

      A guy whose evidence is "I've seen stats", without linking to them shouldn't be lecturing about hard evidence.

      --
      The world's burning. Moped Jesus spotted on I50. Details at 11.
  96. Obligatory? by Anonymous Coward · · Score: 0

    https://xkcd.com/844/

  97. debuggable by Anonymous Coward · · Score: 0

    Eom

  98. Re:Compactness and Readability by goose-incarnated · · Score: 1

    CRC's were in my first year of CS, in 1996.

    --
    I'm a minority race. Save your vitriol for white people.
  99. cycles to execute by Anonymous Coward · · Score: 0

    DUH! Is there any other way do judge the quality of code then through the eyes of the hardware executing it?

  100. Re:Compactness and Readability by phantomfive · · Score: 1

    If I was reviewing code which described what CRC32 was, I would remove the comments.

    Well, you are Doctor Evil.

    --
    "First they came for the slanderers and i said nothing."
  101. Ready to eat your words? by Anonymous Coward · · Score: 1

    You can see it on Netcraft's "what's that site running?" -> http://toolbar.netcraft.com/si... & for showing what academic institutions run what (that could also be done for the Fortune 100/500 & really *ANY* type of servers out there).

    I've used here a few years back to see for myself:

    http://news.slashdot.org/comme...

    & yes, to prove that very point WITH VALID DATA FROM A REPUTABLE SOURCE (2 of them, CNN list of Fortune 500 + NetCraft)...

    All that happened vs. it was downmods and ad hominem attacks (the last resort of "defeated trolls", lol, & invalid proving my points all the more).

    It works & since you demand it? Take a look for yourself there... get a list of the Fortune 100/500 & see what you see nowadays I suppose. That's only on servers though. There's millions of PC's out there vs. servers. What do PCs run the MOST (94++% of them worldwide as a KNOWN fact? Windows!)... you can't win on that note alone.

    Facts used that way work, & I've used that before here, to shut fools up on that very account + face it: The ONLY real reason say, Linux, gets used, is to keep per unit costs down (on servers AND smartphones)

    +

    Face this about that much: ALL THOSE YEARS OF "Windows != Secure, Linux = Secure" is falling apart around your ears here - ANDROID, yes a Linux, proves it for me (& I love it + hate lying bullshitters/deceivers - not because I hate Linux, I don't & ADMIRE it actually as a socio-technological phenomenon that proves folks CAN & DO work together globally doing nice things for free).

    You bullshitters don't realize 2 things: Your deceits shoot you in the foot, I make SURE it does (lol) & you can't EVER ever get the best of me - you don't HAVE what it'd take in truth & facts.

    APK

    P.S.=> However, the "noobies" inexperienced youthful stupid view here isn't aware of the fact C/C++ have been hugely successful on ALL platforms and have gained a gigantic following & momentum that other languages just do not have since time + success will do that for me (selling itself better than bs & "pr spin" that goes on around here like mad, lol, that's for sure ala my "Linux = Secure, Windows != Secure" b.s. that went on here for years)... apk

    1. Re:Ready to eat your words? by Anonymous Coward · · Score: 0

      Mighty Martian's not so mighty now is he? His own demands burnt him.

  102. Solving real problems without excessive complexity by iamacat · · Score: 1

    If the code has a useful function and exposes it with an interface that is no more complex than absolutely necessary, it doesn't matter how ugly it is inside. It will be used and, in time, there will be resources to clean it up. UNIX system calls, libraries and command line tools are a good example. There is not much in common between original code and various modern implementations, but code written on top of these over decades still works and both developers and users are able to leverage their experience.

    Also, even the best written code will have bugs. With simple interface, it's at least feasible to write good tests and find some.

  103. Compactness / infimum by TeknoHog · · Score: 2

    A designer knows he has achieved perfection not when there is nothing left to add, but when there is nothing left to take away.

    -- Antoine de Saint-Exupéry

    --
    Escher was the first MC and Giger invented the HR department.
  104. Re:It's not polite to talk with your mouth full by bbn · · Score: 3, Insightful

    FACT: The PC to Server ratio is MILLIONS to 1 alone

    This does not stand to even 5 ms of thinking. I am living in a country with 5 million people. You are claiming we have 5 servers or something like that.

    Or if you are an american: How many cities do you have with more than 5 million people? How many cities with more than 5 servers? ...

    Or ... there are about 7 billion people on the earth. Lets assume that each have a PC (many don't). You are claiming there are only 7000 servers on earth.

  105. Argue w/ the #'s & "eat your words" by Anonymous Coward · · Score: 0

    Servers running Windows vs. *NIX variants (50/50 split) http://news.slashdot.org/comme... with reliable data from CNN & NetCraft + the # of PC's running Windows vs. all others recently found (recently enough, 2012) & I haven't seen any different... you're free to check though yourself using that same data, it's all there for that much (some might have even changed in your favor, especially in the Fortune 100/500 since "money talks" & the very thing that makes Linux the MOST appealing is that it costs nothing UP FRONT (till support becomes a nightmare issue that DOES cost more typically than Windows since not as many folks are as proficient in *NIX as in Windows, since not as many run Linux vs. Windows). Common sense & fact ALWAYS win (especially when I back it solidly).

    ANY FOOL KNOWS WINDOWS *IS* MASSIVELY DOMINANT ON PC's - must I produce data on that too? It'd make a NICE "SIDE-DISH" FOR THE WORDS YOU & MightyMartian are ALREADY EATING (yours), lol...

    ABOVE ALL ELSE HERE: Your 'sampleset' is not as complete as mine, you have not produced documented facts from reputable sources as I have, & ANY fool can try those 'spinmaster tactics' only to FAIL, as both yourself & MightyMartian have... period!

    * :)

    (Took me less time to shoot you down in flames & I was "demanded" by MightyMartian to produce that data, so... lol, why don't you join him in HIS DINNER of "eating his words" that he challenged me on producing such data & I did - I love doing that to fools, everytime, since they don't think I have it from valid reputable sources & I DO!)

    APK

    P.S.=> By the way: Change your diet - EATING YOUR WORDS != GOOD NUTRITION... lol! apk

    1. Re:Argue w/ the #'s & "eat your words" by bbn · · Score: 1

      You want me to prove there are 7 billion people on earth?! You are more stupid than a kid in first grade.

    2. Re:Argue w/ the #'s & "eat your words" by Anonymous Coward · · Score: 0

      1 thing's certain. You're stupid if you think there's more servers than PC's.

    3. Re:Argue w/ the #'s & "eat your words" by Anonymous Coward · · Score: 0

      No he wants you to prove this data wrong http://news.slashdot.org/comme... and he even offered you all the opportunity to do so. It appears you're unable to apparently and that means you lose since you have to call him names rather than disprove his data.

    4. Re: Argue w/ the #'s & "eat your words" by bbn · · Score: 1

      There is no lose or win - is this the kindergarten?

      I replied to one claim and one claim only: that the PC to server ratio is in excess of a million to one. That claim is so absurd that anyone not laughing their ass off is an idiot that has trouble with big numbers.

    5. Re: Argue w/ the #'s & "eat your words" by Anonymous Coward · · Score: 0

      Your nitpicking can't prove him wrong. You failed bbn. So much for your +4 upmod.

  106. Do not add anything to the list by olau · · Score: 1

    Code needs to be easy to understand, that's all. You can't keep a long list of priorities in your head, that simply doesn't work at all. Just keep one: easy to understand.

    Of course it needs to work, but that's obvious so not really worth stating - testable is part of this obviousness, if you need to test it, and you can't, well, then it doesn't work.

    Sometimes code needs to be performant, but often this is only the case for small parts of it, so it's better not to think about it or it will tend to compete with making the code easier to understand.

    I'm deliberately using the phrase "easy to understand" and not just talking about readability, because ease of understanding often doesn't not come from just superficial readability tweaks like spacing, consistent styling, self-explanatory naming, etc. Often it may require approaching the problem at hand from a different angle, modeling it slightly differently or otherwise shuffling things around a bit to reduce accidental complexity and avoidable dependencies.

  107. Name tossing's not helping you! by Anonymous Coward · · Score: 0

    Prove your words, prove me wrong, & take a course in statistics: Your anecdotal evidence fiction isn't standing up very well vs. documented facts from reputable sources I produced that "MightyMartian" (who shut up suddenly & you shows up SUDDENLY NOW ALSO, well, lol... "Gosh Golly Gee" - you his 'sockpuppet support to the rescue' or what?) shut up quickly vs. it.

    I even GAVE YOU THE OPPORTUNITY to prove me wrong, check the data I produced yourself as it *MAY* have changed some (maybe even in YOUR favor, but I doubt it in only 2++-3 yrs) - you can't or rather I suspect WON'T (since you & he probably have finding it hasn't changed in your favor).

    * Keep name tossing - hell of a way to prove your point.

    APK

    P.S.=> Now, when I do it it's only a statement of fact since you're proving yourselves bs artists & 'spinmasters' that aren't even GOOD @ IT, lol (because it's truth & verifiable, undeniable, concrete FACT I use, especially when it's demanded of me vs. a pack of loud-mouthed "Open SORES/Pro-*NIX" morons that shot their mouths off demanding I produce valid data from reputable sources & I DID, shutting you all up, forcing you into the ONLY thing you know how to do in illogical off topic ad hominem attacks, attempting & FAILING @ attacking myself, rather than my points? Your flaccid nature BETRAYS YOU, & I know it always will - I know you ALL, better than you KNOW YOURSELVES... "Know thy enemy" & destroy him with it works... you prove that for me in fact, lol...)

    ... apk

  108. Re:Compactness and Readability by Anonymous Coward · · Score: 0

    A single reference to the literature would have been better. Most of the other comments would then be redundant. And even someone who knows C++ but not CRCs can easily review the code.

  109. What's that you say? Facts say differently! by Anonymous Coward · · Score: 0

    "Eat your words" http://ask.slashdot.org/commen...

    * :)

    (Tell us - how do they TASTE, flavored with your bullshit vomit mixed in, spiced w/ the BITTER taste of "SELF-DEFEAT", & your foot in your mouth RAMMING IT ALL down your throat?)

    I'm primarily a Windows programmer (since 1994 professionally) & yes - I've worked on most everything from mainframes/midranges, into the Client-Server world using BOTH *NIX variants + PC's (often as a full-blown network-wide admin since I can't DO my job fully unless I'm not & before being a programmer I was a network tech & admin too - can't DO the job that well, imo & yes experience, unless you run the FULL gamut).

    APK

    P.S.=> IMPORTANT: You just *MAY* be young & inexperienced, talking out your ass, with a LIMITED sampleset... & it sounds like you're working in companies with 'specialists' that don't have a lot of range OR experience...

    So, my busting your nuts?

    It's more vs. the result of the LACK OF RESULTS I've seen vs. pure bullshit spouted here vs. that links facts from reputable sources & a wide range of data from government, educational institutions, & Fortune 100/500 data proving your words incorrect (yes, includes you too BUT I think YOU may be victim to "believing the HYPE" that gets VOMITED AROUND THIS SITE LIKE NO OTHER I've ever seen online... THAT may NOT be YOUR fault, but take a lesson from it I suppose... don't believe the hype, from fools that picked a FAR LESS USED PLATFORM on PCs & Servers only to see it can't displace Windows there (same with competing less used language users vs. C/C++ too))... apk

  110. This has been well discussed by Just+Some+Guy · · Score: 1

    R. Pirsig wrote a paper on the philosophical and mental challenges in defining "quality". I suggest reading it.

    --
    Dewey, what part of this looks like authorities should be involved?
  111. Eat your words on MULTIPLE grounds vs fact by Anonymous Coward · · Score: 0

    1st: I never said "ever" (don't put words in my mouth I never uttered) & take a read of documented, concrete, undeniable & reliable data from BOTH NetCraft & CNN vs. your words http://ask.slashdot.org/commen...

    *:)

    (That's valid data from 2012 by the way, only what? 2-2.5 yrs. old or so?? Pretty SOLID evidence is what was demanded of me, I produced it... I see none disproving, & thus, I "rest my case"... some fictional anecdotal bs I shot to pieces easily, with statistics facts too (which I also took in STAT I/II since anecdotal evidence is frowned on AND with a fictional dataset one fool produced he can't backup as WAS DEMANDED OF ME no less & I did so from valid sources, with his LIMITED & yes, lol, fictional pseudo-'dataset'... pitiful!)

    What I found FUNNIER?

    These guys spout "logic" all the TIME here (how many I wonder HAVE actually taken formal logic? I had to in my CS degree work... well, how come they use illogical off-topic ad hominem attacks vs. my facts, attempting to "attack me" & failing right there, since they're unable to disprove my data??)

    ANSWER = flaccid worms shot down ALWAYS betray their TRUE nature as weak effete worms...

    What else proves it? Ok - for SUCH A SITE WITH SUCH "Freedom of Speech" fans on it I see here quite a lot? WHY do the use downmods vs. that data when it's demanded of me & it shoots them ALL down in flames -> http://news.slashdot.org/comme...

    Hmmm?

    ANSWER AGAIN = they're bullshitting liars that WILL do *anything*, including spouting MASSIVE DECEITS & downmods to "hide" truth & fact that doesn't suit their OWN failing agendas - so much for "FREEDOM OF SPEECH" in s system of "moderation" that gets MASSIVELY ABUSED by sockpuppeteering bullshit artists... prove otherwise.

    I can with valid results & proof yet again (especially when it's 'demanded' of me, & they can't!)

    APK

    P.S.=> You'd best rethink your words, & consider NOT saying them so quickly - never know WHO you're arguing with & what they are aware of + what they can use vs. those words of yours as I have (fact & truth are the greatest weapons in debate + knowing thy enemy & knowing thyself I have found @ least) - PLUS, in the end? I truly *think* MOST of you have been outright DUPED into believing the "wannabe experts" around /., who as you can see in the case of MightyMartian & others, are being SHOT TO PIECES by myself, easily - don't believe their "hype" bullshit - seriously: DO YOURSELF A FAVOR ON THAT ACCOUNT (and yes, I can state that - I haven't seen them prove me wrong with valid data from 2012 & I don't think it's changed that much IF @ all, & probably NOT in favor of Linux)... apk

    1. Re:Eat your words on MULTIPLE grounds vs fact by rHBa · · Score: 1

      Hi APK, I knew you were a hosts file fanboi, I didn't know you were a Microsoft astroturfer as well!

      FYI, I didn't intend to put words in your mouth, hence why I put "ever?" in brackets (context APK, context...).

      Also, if you want people to take you seriously then you need to learn how to summarise your thoughts and present them in a non-td;dr way.

      // Note to self, don't feed the trolls

  112. Re:Compactness and Readability by UnknownSoldier · · Score: 1

    > What the hell is this?

    The 8th entry is set to zero so that the test can verify the table was initialized properly.

    > 4))

    > Why is there a block comment at the beginning that does nothing.

    For alignment of CRC32_REVERSE, CRC32_VERIFY, CRC32_Table since /. fucks up formatting.

    > and what the hell does that trailing comment mean?

    The comments lists entries [0] and [1]. The first 8 entries are these :
    i.e. 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3,

    Whenever you generate a table it is always helpful to list _expected_ values so someone can _verify_ them with _actual_ values.

  113. Re:Compactness and Readability by UnknownSoldier · · Score: 1

    Yeah, I forgot to include

    // Reference: http://www.ifp.illinois.edu/~sarwate/pubs/Sarwate88Computing.pdf

  114. Re:Compactness and Readability by BarbaraHudson · · Score: 1

    I wrote a 64-bit crc function, and it worked fine over billions of records of random-length text, was extremely fast (written in c), only required 8 bytes of storage, and was thread-safe.

    --
    "Transparent" is a shit show that trades on every stereotype going. A man in drag is NOT a transsexual.
  115. Jealous by Anonymous Coward · · Score: 0

    When you read the code and say to yourself "God, I wish that I wrote that".

  116. Whoops, wrong link (sorry)... apk by Anonymous Coward · · Score: 0

    Take a read http://news.slashdot.org/comme...

    * Data's pretty recent (3 yrs. old ALMOST to the day) & from reputable sources as was demanded of me by MightyMartian (shot down in flames & shutting him up...)

    APK

    P.S.=> Thanks for being @ least SOMEWHAT fair (though YOU TRIED PUTTING WORDS IN MY MOUTH I *NEVER* ONCE SAID) vs. these bullshit artists here on this site...

    Oh, I can tell what they're going to do next (just like they did in that link above) - downmods!

    (It's always the "last resort" weapon of the WHIMP troll as always since I know they better than they know themselves - too bad most here browse below the bs moderation 'threshold' & see facts I use anyhow vs. their bs):

    DOWNMODS & illogical ad hominem attacks is "the best they have" vs. "yours truly", every SINGLE time & from such "champions of free speech" too (another thing I see here quite a lot & it's bs demonstrated right there alone with fact, again) - they're the BIGGEST ABUSERS OF IT THERE IS with sockpuppetry galore (to 'support themselves', lol, only shooting themselves in the foot doing so vs. facts) to mod their own posts up that are full of bs which I have demonstrated, AND to downmod those they CANNOT GET THE BEST OF... apk

  117. I can't believe nobody's mentioned these. by Anonymous Coward · · Score: 1

    All this other shit is useless unless:

    * the way the problem under solution is broken into solvable, understandable pieces is well chosen. Make a bad choice here and your code blossoms in complexity and fragility.
    * naming and spelling is consistent. Don't show me code that has shit like "frobURI()", "tweakTheURI()" and "makeUriPretty()". Components of names must be consistent. 'do', 'get', 'put', 'fetch', etc. must always mean the same fucking thing.

  118. That magic by Xenna · · Score: 1

    When with a few tiny changes you open up whole avenues of functionality that hadn't been conceived before. Sometimes you get that and it gives me immense pleasure. It opens up potential your code didn't have earlier.

    Am I babbling or does that ring a bell for anyone?

  119. Symmetry by Anonymous Coward · · Score: 0

    Code should be symmetrical. For every "put" there should be a "get", etc.

  120. The real test by Anonymous Coward · · Score: 0

    Good code doesn't allow submissions from people named Bennett. Great code uses a browser location API, exploits vulnerabilities in UAV control protocols and takes aggressive action.

  121. Contributions by manu0601 · · Score: 1

    There are many axis for rating software. One of them is how easily a newcomer can contribute. It measures simultaneously code clarity, architecture choices, software usefulness (who wants to contribute to something useless?), maintainers mindset...

  122. You're offtopic illogical & non-sequitur by Anonymous Coward · · Score: 0

    See subject: That's the "best ya got"? It ain't much vs. fact-> http://news.slashdot.org/comme... from reputable sources, now is it? Nope... lol!

    * I'm a fan of whatever works & that doesn't have a pack of spinmaster trolls spouting lies, trying (& failing) your "seize the youth & seize the future" easily destroyed by verifiable facts (as I used) from reputable sources!

    FUNNY you're all "dead silent" vs. the data in that link, eh? NOT!

    (Man, if you're going to pull your 1/2 truth + lies B.S.? BE GOOD @ IT at least - you're not, see the results vs. what's in that link above after all as my proof thereof) trying to deceive others with bullshit propoganda they can't backup validly OR being able to disprove what's in the link above (when I posted it in 2012 vs. you "Pro-*NIX fanboys"? You downmodded it - truth & facts aren't "real big" here on /., now are they?? Nope... just bullshit!))

    TL:DR? Yea,right - it's not MY fault you need "Hooked On Phonics" & have a brain-damaged "ADD/ADHD" brain!

    APK

    P.S.=> Love how you all spout "LoGiC" when what you really use, especially when you're shot down in flames, is ILLOGIC LOGIC (hence your weak failed ad hominem attack, snide b.s, & what-not vs. what I have)... & as far as "taking me seriously", Mr. weasel? When you've done MORE, & BETTER (+ earlier) than I have in the art & science of computing (such as a commercially sold code to my name, having my wares place as a finalist @ esteemed tradeshows like MS Tech-Ed, 2 yrs. in a row in its HARDEST category, SQLServer Performance Enhancement, being in books, newspapers, trade magazines, & more MANY times? THEN, you can talk the way you have to me, as a PEER... not a bullshitter off topic destroyed by REAL logic & facts troll... m'kay?)... apk

    1. Re:You're offtopic illogical & non-sequitur by rHBa · · Score: 1

      Take your meds APK

  123. rHBa take your own advice by Anonymous Coward · · Score: 0

    See subject: Quit projecting your own issue & get on topic also... m'kay?

    APK

    P.S.=> You have FAILED vs. this http://news.slashdot.org/comme... & you know it, I know it, & so does anyone else with 1/2 a brain even... apjk

  124. MY favorite code by Ryanrule · · Score: 1

    The best code is code that when you have to go in to make a change, was built in such a way that new features just slot in nicely, with little rework or fuckery. I LOVE when code I built previously means what someone thinks will take me 3 weeks takes me 1 hour (billed at 2 weeks)

  125. Holy Sheep Testicles Batman! by LostMyBeaver · · Score: 1

    Can you honestly expect to get a worthwhile answer to this question on Slashdot?

    Wouldn't it have been better to ask people to link Git repositories with examples of good, clean code instead? Better yet, make a site which allows people to link a repository instead and explain why that code is either good or bad. Let people vote as well.

    I can show you massive portions of the Linux kernel tree which is both good and bad. Good because it's functional, tested and works well. Bad because it was ransacked by the spaghetti monster. Want a great example?

    https://github.com/torvalds/linux/blob/master/lib/glob.c

    This code is fantastic because it is rock solid and has been tested to death. It's even relatively clean, but while some people can actually use it, maintaining it would be nightmarish due to lack of documentation. It's documentation isn't entirely awful, and I really wouldn't say "replace it because it's not pretty", but it's code is simply not pretty.

    It also has to be handled with care. It makes assumptions that the parameters passed are proper. Used improperly, it can cause overflows. There's no real error handling or bounds checking. It's not what I would personally call "secure code".

    But it's great code all the same.... if called from a function which ensures what is passed is valid.

  126. Depends on the requirements by TMB · · Score: 2

    The best piece of code I ever wrote in my life was nearly 100x faster than the next best algorithm ever written to do that problem. That took the expected run time down from a few days to an hour.

    It was not a particularly well-commented piece of code. If it were, it would have been even better.

    It was not a particularly obvious algorithm for solving the problem. If it were more obvious why one would choose to do it this way, it would have been even better.

    If the primary concern is runtime (because it normally takes days to run), and you literally make it orders of magnitude faster, that's good code. It could be better if it were also better commented and easier to maintain, but those aren't *always* the primary concern (yes, sometimes they are. That's the point -- criteria differ!)

    [TMB]

  127. Re:Compactness and Readability by CBravo · · Score: 1

    What is missing is the word 'design'. You may comment why you made a design (or write a paper on it). You may understand the design by reading the code. If you don't it is either too complex (because there is a possibility to write the same functionality with the same complexity with easier-to-read code) or you need to explain the design for it.

    --
    nosig today
  128. What Makes Some Code Particularly Good? by Rudisaurus · · Score: 1

    How about: it's bug-free?

    --
    licet differant, aequabitur
  129. Blueriver X32 by Anonymous Coward · · Score: 0

    Now that's a tool which really helps producing great code. If you don't know this one yet, give it a try. But don't look at the code in anything different than X32. You have been warned.

    And yes, this tool is actually being used for safety critical code (SIL3).

  130. No such thing by Anonymous Coward · · Score: 0

    In my experience, no matter what kind of code you write, there's always people who think you've done it wrong. Always.

  131. Re:CS is only practical by accident, but that's ok by Anonymous Coward · · Score: 0

    Composing a piece of music might be more like writing a compiler. In both cases you'd be relying heavily on theory.

    As for composing music, I disagree that it relies heavily on theory - and I have composed quite a bit of music. If you want a good composition, then just come up with something that sounds good (duh!). My point is: this requires no pondering of theory whatsoever. Of course, what sounds good to you is affected by what you have grown up hearing, but if that consitutes 'knowledge of music theory' then the ability to walk is 'knowledge of gravitational theory'. Whether or not the composer is aware of the theoretical underpinnings of his composition is not very relevant, the audience will never know.

    I personally view music theory mostly as descriptive of common structures in music, both harmonically and rythmically. Music theory does not say anything about what you can compose or play, or even what will sound good, it merely allows labeling it a posteriori. In most contexts, 'music theory' is effectively equivalent to, or perhaps a subset of, 'music nomenclature'.

    Much music is composed by re-using ideas typical of the genre, but is that applying theory or just imitation? I think it's the latter. People will rarely like music that is 100% novel (i.e. very unusual). It makes much more sense to most listeners if you take e.g. 10% novelty over 90% familiar sounding stuff. If you do that, you'll sound quite original since any unusual stuff stands out so much.

    In my experience, knowing music theory is most useful if you want to efficiently *communicate* to others what their parts in the composition are. Like: "Just play a I–V–vi–IV progression", or "can you play a son clave pattern on the kick where he lets that Bb7#9 chord ring?". There are of course many more uses of theory. E.g., it can help you improvise a solo over a certain progression while avoiding dissonant intervals (if you happen not to want those at that particular place and time). Very usefull in, say, jazz.

    In summary: music is an art form, and in it anything goes. Music theory expands to include whatever strange ideas people come up with, so don't worry about it when you are composing.

  132. In my opinion by Anonymous Coward · · Score: 0

    The most importnant thing is simplicity high cohesion, low coupling and VERY rarely usage of design patterns.

    Every new educated programmer sees the need for patterns everywhere- I did too.
    But after learning to write good C code- I started seeing the light- design patterns have their place but that is not often.

    My OOP coding skills have increased after ive learned to write good none OOP code.

    Everything is not an object- and everything should not be, but it is fine to use it for coupling data together- like a struct.

    Inheritance if used should be very very low in number of layers.

    Seperation of Business logic and implementation details is also always a good goal.

    Lots of comments about WHY the code does what it does- sometimes what it does- but if that is nessesary it is a sign that the code is not nice written.

  133. Easy... by Anonymous Coward · · Score: 0

    Good code is a simple as possible, but no simpler. Thank you Einstein.

  134. Re:It's not polite to talk with your mouth full by Hognoxious · · Score: 1

    Perhaps he's been listening the that IBM guy from 1968.

    --
    Confucius say, "Find worm in apple - bad. Find half a worm - worse."
  135. A Winner!!!!! by Anonymous Coward · · Score: 0

    Yes folks, we have a winner. The referenced page contains nineteen, count 'em, trackers in just one page.

  136. Reusable by MichaelMacDonald · · Score: 1

    I think re-usability and properly formed and conceived libraries and classes if it's object oriented should be in there. I've seen plenty of people meet all 8 of those requirements, but have all their code in one giant file that really should be divided up into separate logical pieces that could be used again in other projects.

  137. It's not polite to talk w/ your mouth full by Anonymous Coward · · Score: 0

    AS YOU EAT YOUR WORDS here http://ask.slashdot.org/commen...

    * :)

    FACT: The PC to Server ratio is MILLIONS to 1 alone, & what do 94.5++% (roughly) run worldwide? Windows... you can't win right there alone.

    The ONLY true reason Linux is used in a 50/50 (roughly) split vs. Windows is it's "free" (up front, try it on maintenance/support) cost keep initial per unit costs down (funniest part's all the YEARS of "FUD" around here of "Windows != Secure, Linux = Secure"'s falling apart around your ears now since ANDROID, a Linux, is being TORN UP on the security front daily for more than a decade now... lol!)

    * LASTLY: As was predicted by myself & other posts? DOWNMODS of my posts, totally unjustified (forget validly) to "hide" what you demanded, & you got, & it made you STFU easily -> http://ask.slashdot.org/commen...

    You're predictable & I know you trolls better than you know yourselves - real Sun Tzu being used on YOU - Know thy enemy & know thyself - you will never lose in a 1,000 battles.

    You're FAIRLY given the opportunity to check my data from reputable sources you demanded, as were others - my guess is you have & it hasn't changed much IF @ ALL in 3 yrs. (you fail on MULTIPLE grounds).

    APK

    P.S.=> I've already "Been There/Done That" & used it to make you eat your words in that link above - Evidence from educational institutions & the Fortune 500 ARE THAT EVIDENCE from reputable sources (CNN & NetCraft data) - funniest part? YOU "DEMANDED" I produce it, well, there you are... Change your diet - eating your words != GOOD nutrition, lol... apk

  138. CNN & Netcraft actually... apk by Anonymous Coward · · Score: 0

    See subject: Does the job on you all easily enough http://news.slashdot.org/comme... shutting you down, easily ("too, Too, TOO EASILY - just '2ezily'").

    Especially after MightyMartian "demanded" citations as I've seen he's wont to do via his posting history...

    Well, that got put to rest & so did he, along with yourself + the other off-topic illogical ad hominem attack utilizing dolts who *tried* to use "fictional data" & his partial sampleset vs. what's in the link above... which, of course (since I know you fools better than you know yourselves), was downmodded in effete 'retaliation' since it's all you can manage when shut down...

    Again - So much for the 'freedom of speech' mantra you bullshitters spout here!

    Fact is? Man - you're the WORST abusers of it there is that I've personally EVER seen, & it's hidden from others as well so there's no confronting such whimps too (says much about the character of those that created this place in fact - yes, your GHOST comes thru in the machine when you write code, & as the saying goes? "I SEE YOU"... so does anyone else)).

    * NOW GO & EAT YOUR WORDS... lmao!

    APK

    P.S.=> In the end? It's been a REAL PLEASURE knocking you boys right out, using what you yourselves demanded (proof from reputable sources) - you only did it to yourselves, as you always do, every single time you try it vs. myself... lol!

    ... apk

  139. Quoting Ultron (Avengers 2 coming & all that) by Anonymous Coward · · Score: 0

    "My programming" http://start64.com/index.php?o... has advanced BEYOND your commands: BEYOND your weakness..." Quote from https://www.youtube.com/watch?...

    (... & that weakness of yours is your inability to prove my points on hosts being superior to "the new hotness" (AlmostALLAdsBlocked by default, crippled intentionally + sold out to NOT do its job, & it only had 1 thing to do no less, & doesn't DO it very well, bolting on more bs to increase CPU use, RAM overuse massively, & messagepassing overheads...))

    Of course, you "web 2.0" fools don't *WANT* people to be blocking ads - ESPECIALLY VIA HOSTS FILES! Those ads are your "raison d'etre", & they track + infect people like mad, plus steal bandwidth etc. we pay for as online users!

    (Yes, "I see you", transparent's your FAVORITE COLOR, & I see right thru you attempting to 'further your own agenda' with pure bullshit... just like how I smoked you ALL with what you asked for - citation & proof from reputable sources!)

    APK

    P.S.=> Keep coming (what's the matter boys? "Cat got your tongues"?? Yes... but it's more you shoved your foot into your mouths to RAM your words you're eating down your throats in self-defeat - what's it taste like, washed down with the 'bitter taste of SELF-defeat", lol?)... apk

  140. Zorro-friendly: get in, make your 'Z' and get out by TheRealHocusLocus · · Score: 1

    I offer Sendmail in its mid-1990s form as an example. We had several dialup customers with Microsoft Exchange servers. They'd connect and Exchange would issue an ETRN to dequeue waiting messages. The problem was that Sendmail by default, would send a "Warning: could not deliver mail for 4 hours" reply back to sender after the email had languished in the queue that long, and they dialed in sporadically and not at all on weekends so folks who emailed them would get these messages. It was bad. I wanted to disable this warning specifically for ETRN domains but not for everyone.

    Does this feature exist? Sendmail documentation defined 'queuewarn' as a global setting but did not address this "deferred delivery by design" problem. Could there be a presently-undocumented or undiscovered workaround? Delving into the source it was visually apparent the answer was no, the warning was unconditional. The only workaround would have been to run a completely separate SMTP server on another IP address with the queuewarn off, and MX 'em to that. What a bother. Are domain-specific attributes available? Yes, these had a mailer flag of HOLD. Can it be addressed with a one-liner? Yes. So the _FFR_NODELAYDSN_ON_HOLD compile/config flag was born, off by default because we don't want to break things.

    Just a couple of hours to discover, patch and test. another hour to render it into a contrib patch where it made its way into Sendmail. Open source is cool and when you see your own contribution being proposed as a solution to solve someone else's problem years later... that is quite satisfying.

    Sendmail had the right balance of code-to-comment. What comments were there would not make sense until you understood the underlying process, and tag names were explicit enough that comments were seldom necessary.

    --
    <blink>down the rabbit hole</blink>
  141. Re:Compactness and Readability by Anonymous Coward · · Score: 0

    I don't understand the aversion you people have to comments. Comments help people understand the shitty code you've written. You may think it's great, but the rest of us don't, and your "clever" solution makes sense to no one but yourself. In the interest of the team, COMMENT YOUR F***ING CODE.

  142. Re:Compactness and Readability by Dr.+Evil · · Score: 1

    crc32 is the name of the algorithm. If you dont know what it is, what it is for or why it exists, comments aren't the place to describe it. Incorrect, misleading or unnecessary comments are worse than no comments at all.

  143. Re:Compactness and Readability by hcs_$reboot · · Score: 2

    Some actual useful comments might be nice.

    Well, when the function is named calculate_crc32()...

    --
    Slashdot, fix the reply notifications... You won't get away with it...
  144. There's less servers than PCs stupid by Anonymous Coward · · Score: 0

    You don't merit a +4 & there's far more PCs running Windows than anything else!

  145. Re:Compactness and Readability by UnknownSoldier · · Score: 1

    It will come up in your Comp. Sci. education.

    If it doesn't you have really bad teachers, or a really bad school.

    All good programmers should understand the basics of one-way-hashes.

  146. Good="Brillant" by Anonymous Coward · · Score: 0

    public class paulaBean {

        private String paula = "Brillant";

        public String getPaula() {
            return paula;
        }
    }

  147. REAL data via CNN/Netcraft shows you lose by Anonymous Coward · · Score: 0

    C/C++ are hugely used on all platforms vs. obscure bs you seem to favor (and yes, my data's REAL vs. your 'theoretical bs' blowhard) even MightyMartian, who brought us there, admits it (and I shut him up, as I have yourself, vs. the concrete, verifiable, & undeniable REAL dataset I put up, vs. your "phantasyland" crap that doesn't stand up to statistics as a valid dataset).

    FACT: Since you nitpicked? Windows on PCs & Servers COMBINED (as I initially stated it using a "+" here dimwit http://slashdot.org/comments.p... ) stands a real statistical sampleset test (vs. your theoretical nitpick BULLSHIT, whimp).

    You are a NITPICKING little BULLSHITTING done zero I can see of worth pud that I made "eat his words" like all your kind, online scumbags spouting bullshit.

    APK

    P.S.=> Last thing, for YOUR own sake: I'd wager you DO NOT toss names in illogical ad hominem attack frustration in the REAL world (if you did with me? I'd promise you 1 thing - I'd blast your FUCKING TEETH OUT for it - especially after eating your words here vs. real data anyone can verify, & YOU CALLING ME STUPID - since it's online, I don't HAVE that opportunity, so the data did it for me... you worthless little windbag - I've done things in the art & science of computing while I wager you were STILL IN DIAPERS you won't EVER manage - want proof of that too? Shoot your mouth off again, I'll make you eat your words on THAT too)... apk

  148. "Eat your words" vs. FACT blowhard by Anonymous Coward · · Score: 0

    "You are more stupid than a kid in first grade." - by bbn (172659) on Friday March 27, 2015 @07:17PM (#49358399) FROM http://slashdot.org/comments.p...

    The # of PCs + Servers on Windows combined's > than Linux by huge orders of magnitude.

    Additionally (per the ACTUAL debate here) - The use of C or C++ is huge on ALL platforms, so fools like yourself using obscure languages like Haskell and Scala which I see you seem to favor is also hugely outnumbered.

    See below - THAT explains your illogical off topic ad hominem attack since I wagered you checked & found it's what I said which even rHBa agreed on PC client desktops Windows rules also by HUGE orders of magnitude (frustrated little *NIX noob that you are, & networking menial @ best from what I see in your posting history).

    In fact, I LITERALLY gave you, & SUGGESTED YOU CHECK, all the opportunity using the very data I put up in 2012 to test it & you're running from that simple test: Actually, I'd say you looked and found it it's still much the same.

    NewsFlash: I looked again for posterities' sake (Some HAVE changed in your favor by the way OR are a "mix" of both, but it's not by that much (from the list I provided of nearly 400 varied organizations in total)):

    ---

    The sampleset data still shows tons more sites from the Fortune 500 (5 changed to Linux by the way but I am still way, Way, WAY ahead even 3 yrs. later), Government, and Educational Institutions running Windows or IIS vs. other *NIX variants combined... but I'm still ahead by roughly a 32 of 37 listed ratio.

    29/30 of "best companies to work for" in that data also STILL use MS IIS & Windows Servers too!

    The next 30 are STILL much the same as well in favor of Windows/IIS.

    State Government offices (20/52 states) are same as they were too, using Windows/IIS.

    Of 90 top universities tested? 3 changed but it's still hugely showing Windows Servers in place.

    The remaining are also MUCH the same, in favor of Windows or a mix of them, only 2 changed that I saw.

    * Feel FREE to recheck this yourself... by all means.

    ---

    Linux does apparently get used as a load balancer in some (like CISCO, Compaq Tru64, & F5 Big IP) but the servers from my list for the web & otherwise ARE favoring Windows, hugely.

    My point stands strong with valid data used from reputable sources (CNN & NetCraft) - yours? Pure fantasyland bs!

    Smallfry cash-strapped STARTUPS *may* use Linux, OR the "new hotness" languages you're into (Scala/Haskell), since they're poor, but see here http://it.slashdot.org/story/1... & that *might* explain WHY they're attacked too possibly - especially via NOOBZ running them (young folks minus experience & wisdom that comes with age).

    Still, UNLIKE you (moving the goalposts illogical bs from the ORIGINAL debate here, which languages are used most & where, etc.) - I have ACTUAL data that's verifable - NOT "fantasyland" bullshit like you & ALL the other dumbshit "penguins" attempted.

    So "argue with the numbers" dummy, not me & your nitpicking bs isn't standing up to verifiable, concrete, undeniable fact you BIG MOUTHED LITTLE BLOWHARD!

    Then again, tossing names when you can't attack my points & instead attempt to attack me proves my point you're an ignorant illogical imbecile!

    Am I tossing names now, doing what you did to me? Absolutely - you, however, prove you MERIT it in return (what's good for the shot down goose, you, is GREAT & justified for me, the gander, asswipe...)

    APK

    P.S.=> In the end, it's YOU who ARE stupid & eating your words with your fictional invalid 'sampleset' statistically & with your nitpick bullshit as well as tossing names at me (which signa

  149. Great by Anonymous Coward · · Score: 0

    Great software design is usually the incumbents...

    Chris Lukehart

  150. Cost effective by Anonymous Coward · · Score: 0

    No software is built or maintained without a reasonable return on investment (real, perceived, or expected). Even toy programs written in one’s basement are written for a return: amusement and/or education. If code isn’t cost effective none of the other factors matter.