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?

12 of 298 comments (clear)

  1. 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.
  2. 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...

  3. 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!".

  4. 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.
  5. What would you add to this list? by QuietLagoon · · Score: 3, Insightful

    That it works.

  6. 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.

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

  8. 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.

  9. 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.
  10. 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
  11. 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.

  12. 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