Slashdot Mirror


Ask Slashdot: Getting Feedback On Programming?

jm223 writes "I'm currently a student at a major university, where I do IT work for a fairly large student group. Most of my job involves programming, and so far everyone has been happy with my work. Since we're students, though, no one really has the experience to offer major advice or critiques, and I'm curious about how my coding measures up — and, of course, how I can make it better. CS professors can offer feedback about class projects, but my schoolwork often bears little resemblance to my other work. So, when you're programming without an experienced manager above you, how do you go about improving?"

196 comments

  1. Contribute to open source projects by dwmw2 · · Score: 5, Insightful

    Contribute to open source projects. You'll get plenty of feedback. Some of it might be quite, erm, 'robust', especially with certain projects. But it'll almost all be useful, and you'll be doing something worthwhile.

    1. Re:Contribute to open source projects by buchner.johannes · · Score: 4, Interesting

      Contribute to open source projects. You'll get plenty of feedback. Some of it might be quite, erm, 'robust', especially with certain projects. But it'll almost all be useful, and you'll be doing something worthwhile.

      In open source projects, there are problems of all scales. As a newbie, and unfamiliar with the code base, you will only be able to tackle few bugs. So choose a project and a bug you are interested in, and get into it. Bug after bug, you will be able to tackle bigger problems, improving your programming skills (reading code, design, implementation, testing, communication, etc.).
      Don't get bummed if your first code contribution doesn't work out or a interesting project isn't communicating with you. Just move on or do your own thing if you really think it is worth it.

      --
      NB: The message above might reflect my opinion right now, but not necessarily tomorrow or next year.
    2. Re:Contribute to open source projects by Anonymous Coward · · Score: 0

      I was going to say there the best way to improve wpuld be to solve problems, eligantly and concisely, but parent is exactly right solve open source problems elegantly and consicely. Mod parent +1.

    3. Re:Contribute to open source projects by wrook · · Score: 5, Informative

      When asked this question, I often think, "How do aspiring writers learn their craft?" People who study English read ridiculous numbers of books. This gives them a base to start from when they are writing.

      Writing your own code is invaluable, but when you are just starting out it helps not only to contribute to open source projects, but also to read, read, read. I recommend going through some interesting projects and then forming an opinion about which ones have the best code. Don't just look at it superficially; try to form opinions on specific practices, idioms and designs. Then choose a project to work on and try to follow those ideas. From that point the feedback will be more valuable.

      One of the things that Kent Beck said one time (possibly in an interview with Floss Weekly; I can't remember) was that his level really improved when he sat down and really thought about what he was doing. He just kept writing things over and over again until he could say exactly why he did everything. IIRC, he wrote down all his ideas and put it in a book on Smalltalk coding practices (which I haven't read yet...) I've been trying to do the same thing lately and it is really beneficial. Forming your own ideas and *then* getting feedback seems to be more productive than writing "just to make it work" and getting feedback.

      Just be open minded when you think you have it all sorted out, but someone else thinks your ideas suck ;-)

    4. Re:Contribute to open source projects by TheRaven64 · · Score: 0

      Ask before you make a change. The open source projects I work on all have some projects that can be tackled by a less-experienced programmer with a little bit of hand holding, but which aren't yet a high enough priority for any of the experienced developers to get around to. Often there's a public list of these projects (although it may be out of date), but if you ask you can probably find someone willing to help you make a start, review your code, and give feedback and directions. These days I seem to spend more time doing that than actually writing code...

      --
      I am TheRaven on Soylent News
  2. Try coding for OSS by JoeMerchant · · Score: 2, Informative

    It's going to be nigh impossible to get anyone to review your work code, even though they should.

    If you want some brutally honest critiques of your code, along with a healthy dose of nit-picking and "cultural bias", try writing for one of the major open source projects like FFmpeg, Gimp, KDE, Qt, etc.

    1. Re:Try coding for OSS by W3BMAST3R101 · · Score: 5, Funny

      Your "idea" doesn't work within his original request. Is that all you fucking retards know is to caw on about open source? A bunch of fucking jokers. If you can't offer up advice to adhere to the original request then shut your fucking ass. Fuck you and fuck your open source. Fucking retarded bitch ass cunt.

      Please don't sugar coat it. Tell us how you really feel.

    2. Re:Try coding for OSS by Anonymous Coward · · Score: 3, Insightful

      The quality of open source is usually pretty high, and there is a ton to choose from - from trivial to major projects. Telling someone to look at properietary or closed source code is likely to lead to a dead end.

      Contributing to open source is a different issue: there are usually barriers to entry and a degree of "cliqueness", but thats understandable. Open source projects provides a good vehicle for understanding how groups of people interact. Sometimes its not just about coding and algorithms, but also about acceptance by peers.

    3. Re:Try coding for OSS by wrook · · Score: 5, Insightful

      It's going to be nigh impossible to get anyone to review your work code, even though they should.

      This is unfortunately all too true in most cases. Most organizations do not understand the benefit of rigorous code reviews. If they review code at all, they often only look to see if there are bugs, or if (usually fairly arbitrary) coding standards are followed. I've been lucky enough to work on a few teams with brutally honest reviews. It can be intimidating, but in the end it is incredibly useful for developing yourself. Things like pair programming can also be very useful in this regard.

      One of the things that always bugged me as a programmer was that never once in 20 years did anyone ever evaluate my performance on the basis of the quality of my code. In fact, it was unbelievably rare when the person who evaluated my performance ever even looked at my code. Many of my immediate superiors would not have had the ability to judge one way or another, but even then they never bothered to ask my peers to look at my code and comment.

      For some reason, I often think about programming teams as if they were sports teams. The way most teams are run, you have a manager who knows little about the game you are trying to play and never watches a game. There are no coaches. You performance is loosely evaluated on whether or not your team wins games, but even then the manager usually tries to make it appear that the team won every game whether they did or not. When they try to get new players, they don't bother looking at the success of the player on their previous teams, or even watch them play. At most they set up some artificial 5 minute drill and evaluate that, but usually they base their decisions on a feel-good interview.

      It's quite literally crazy IMHO. In the case of sports it is obvious that this isn't going to work. I'm not sure why it isn't obvious for programming teams.

    4. Re:Try coding for OSS by Anonymous Coward · · Score: 2

      Codebases are of vast different quality. For example,

      mplayer - not very nice code base - something I would not want to immitate. Not for beginners.

      Qt - fairy good, sometimes rushed. Reasonaly good architecture. Most recommended out of these 3 for beginners - plenty of documentation.

      Linux - mostly top-notch, especially the core stuff. Recommended for experts - code is documentation.

    5. Re:Try coding for OSS by bloodhawk · · Score: 4, Insightful

      telling someone that wants critique of his current work to go and do a whole new swag of work on some other project while would provide him with feedback (much of it negative and argumentative about style rather than real substance) is really about the hardest possible way to go about this.

      If you really want comments on your work you need to find someone with experience that is willing to give up some time to mentor/review your work. "Sometimes" you may even find the odd lecturer that has some industry experience, though they seem to be pretty rare and many have a highly inflated (and unexplanable) opinion of there own work. Or perhaps look at some of the online programming forums, many people want peer reviews and swapping code for review not only gets your own work reviewed but gives you exposure to what others produce.

    6. Re:Try coding for OSS by Anonymous Coward · · Score: 0

      Your comment is very similar in style and content to the feedback the OP can expect to receive from the OSS community when submitting any patches.

    7. Re:Try coding for OSS by philip.paradis · · Score: 3, Insightful

      On the Internet, nobody may know you're a dog, but everybody knows you're an asshole.

      --
      Write failed: Broken pipe
    8. Re:Try coding for OSS by Anonymous Coward · · Score: 0

      You should, however, imitate the proper spelling of imitate.

    9. Re:Try coding for OSS by JoeMerchant · · Score: 4, Interesting

      If you really want comments on your work you need to find someone with experience that is willing to give up some time to mentor/review your work. "Sometimes" you may even find the odd lecturer that has some industry experience, though they seem to be pretty rare and many have a highly inflated (and unexplanable) opinion of there own work. Or perhaps look at some of the online programming forums, many people want peer reviews and swapping code for review not only gets your own work reviewed but gives you exposure to what others produce.

      This would be great, if you can make it happen. In the world I live in, the number of people available to think about anything - programming, or otherwise, decreases like an e^(-x) curve, thousands will give you the 30 seconds it takes to whip off a quick sound-bite of "what they think" after skimming over your question, hundreds will give an extra 60 seconds to actually read the question skim the reference material and cogitate about what you might want to hear rather than what they want to say, tens might take the time to look at a one page program and think about what you're trying to do, by the time you get to 10 pages of code you'll be lucky to find one (experienced, knowledgeable) person who will actually do it. If he's been programming for long, I assume his projects are getting up there in size.

      At least the arrogant pricks defending their OSS fiefdoms will read your code most of the time, if you've submitted it in the proper form. Sure, they'll throw it back in your face if you've used superfluous parenthesis or non-style compliant indenting without even checking to see if it works; but, occasionally, they really do want that bug fixed and they will give you some substantial feedback about your methods. And, if you keep submitting to different projects long enough, you'll eventually find a reviewer who isn't an arrogant prick. The guys at Qt were rather nice about it when they said "oh, nice fix, but we're deprecating that whole branch for version 5, so we're not going to take the time to regression test your code and just leave the 4.x trunk broken for every Intel laptop graphics chipset made in 2008-2010, after all, it's actually Intel's drivers that are buggy."

    10. Re:Try coding for OSS by phantomfive · · Score: 4, Interesting

      One of the things that always bugged me as a programmer was that never once in 20 years did anyone ever evaluate my performance on the basis of the quality of my code. In fact, it was unbelievably rare when the person who evaluated my performance ever even looked at my code. Many of my immediate superiors would not have had the ability to judge one way or another, but even then they never bothered to ask my peers to look at my code and comment.

      It's so hard to do this. I had one coworker who wrote basically unreadable code, that was riddled with bugs. He knew that he had problems, but wasn't sure what. I tried to suggest a few things, but he was really defensive. He disagreed with me, and argued every step of the way. So I took a slow approach, and gave him extremely mild suggestions over time. Eventually he started to improve, but then he quit.

      It is really hard to give programmers coding advice, because usually they are defensive, and will defend their code. On the other hand, I did have one coworker who actually asked for advice from time to time, and when I saw places he could improve, I emailed them to him.

      --
      "First they came for the slanderers and i said nothing."
    11. Re:Try coding for OSS by cowdung · · Score: 4, Insightful

      Unprofessional programmers are defensive. A good programmer will listen and learn when he can.

    12. Re:Try coding for OSS by Anonymous Coward · · Score: 0

      There are plenty of sites that support swapping of code for reviewing, you don't have to rely on someone reading a forum post and saying "sure I'll help". In fact even the forum post would be a better option that most OSS projects as he is extremely unlikely to get helpful advise, especially if his stuff isn't up to scratch, no one has time to help out a coder that isn't up to scratch, it will just get rejected as garbage or he will get abused for wasting there time as none of the arrogant pricks will take the time to educate him.

    13. Re:Try coding for OSS by firewrought · · Score: 1

      For some reason, I often think about programming teams as if they were sports teams. The way most teams are run, you have a manager who knows little about the game you are trying to play and never watches a game. There are no coaches. You performance is loosely evaluated on whether or not your team wins games, but even then the manager usually tries to make it appear that the team won every game whether they did or not. When they try to get new players, they don't bother looking at the success of the player on their previous teams, or even watch them play. At most they set up some artificial 5 minute drill and evaluate that, but usually they base their decisions on a feel-good interview.

      Hate to throw in a "me too" response, but wow... I know exactly what you are talking about. Our interviews have like 1 or 2 questions that vaguely touch on technical expertise, but it's a total joke. The whole interview is only 9-10 questions long, and any schmoozer without an ounce of skill can dance right thru it.

      Part of the problem is HR keeps an iron grip on interview formats out of fear of discrimination suits. You can't give out a quiz that--for example--sees if the candidate is capable of writing SQL statements (like they'd have to do EVERY DAMN DAY if they're hired), because the quiz hasn't been certificated as anti-discriminatory.

      --
      -1, Too Many Layers Of Abstraction
    14. Re:Try coding for OSS by Anonymous Coward · · Score: 0

      awww...did no one sign up to volunteer on your sourceforge project?

    15. Re:Try coding for OSS by Anonymous Coward · · Score: 0

      If you want to be get in at the leading edge of an up-and-coming FOSS project involving creative work, there's Linux Multimedia Studio. (Don't let the name fool you, it's also multi-platform in regards to OS.) Not quite where Gimp or Blender is yet, but then again it's audio and music rather than graphics and video. Software is already impressive and easy to use despite its rough edges. Unlike some software, it's also a niche application so the userbase tends to smaller and more focused too.

      A lot of requests coming from the user side are still not implemented. Most of which seem reasonable/useful. And it's likely the core code still needs to be redone in some areas in order to make implementation of such features possible. So it's going to be more challenging than easy. The releases seem to take a good while, so I'm sure there's a lot of review and debugging going on. (Either that or it's short on manpower. Sometimes I wonder.)

      I'm coming from the user side btw, so I don't know all the details. Just offering something to look at which still seems to be a relatively small and interesting project. If you're musically inclined in any way, it might be one to check out.

    16. Re:Try coding for OSS by PJ6 · · Score: 1

      One of the things that always bugged me as a programmer was that never once in 20 years did anyone ever evaluate my performance on the basis of the quality of my code. In fact, it was unbelievably rare when the person who evaluated my performance ever even looked at my code. Many of my immediate superiors would not have had the ability to judge one way or another, but even then they never bothered to ask my peers to look at my code and comment.

      It's so hard to do this. I had one coworker who wrote basically unreadable code, that was riddled with bugs. He knew that he had problems, but wasn't sure what. I tried to suggest a few things, but he was really defensive. He disagreed with me, and argued every step of the way. So I took a slow approach, and gave him extremely mild suggestions over time. Eventually he started to improve, but then he quit. It is really hard to give programmers coding advice, because usually they are defensive, and will defend their code. On the other hand, I did have one coworker who actually asked for advice from time to time, and when I saw places he could improve, I emailed them to him.

      He quit because after a lot of work he was finally able to realize just how bad he was.

      This guy was unusual because that almost never happens.

    17. Re:Try coding for OSS by Anonymous Coward · · Score: 0

      Learning not to be personally invested in your own code is a skill that takes time. When someone is new and insecure it is easy to view critiques as attacks. A good reviewer can help insecure coders by making it clear that everyone is still learning and most people look at there own code of a few years past and are aghast.

    18. Re:Try coding for OSS by phantomfive · · Score: 1

      He quit because he got a job offer that paid more.

      --
      "First they came for the slanderers and i said nothing."
    19. Re:Try coding for OSS by Spugglefink · · Score: 1

      Most organizations do not understand the benefit of rigorous code reviews.

      Or they do understand this benefit, but they realize that no matter how many hundreds or thousands of hours they spend improving their code quality, they're never going to make any money, get famous, or get laid, so they just say fuck it and stop caring.

      The crap I gave you for free isn't good enough to suit your rigorous standards? Fuck you. Take a crowbar to your wallet and buy some of the commercial stuff, or go jump off a cliff. Or both, preferably. And fuck you.

      --10-year open source burnout victim

    20. Re:Try coding for OSS by Anonymous Coward · · Score: 0

      Don't worry. One day you'll get laid. Probably.

  3. Post it by datavirtue · · Score: 5, Funny

    Go ahead and post it. We'll offer plenty of........critique.

    --
    I object to power without constructive purpose. --Spock
    1. Re:Post it by Anonymous Coward · · Score: 4, Interesting

      Seriously, though, the problem is that so, so much about programming structure and form is debatable. Since he's a student, he probably does have some obvious rookie mistakes that can be corrected, but he'll still get told many absolutes that are really not at all absolute among good programmers. Some people will correct you for having variable names over, say, 10 characters; others will tell you NEVER use a goto; others will give you a very hard limit on the number of lines any method should be -- on /., I've seen someone claim no more than 10, which is ludicrous to me. A result of all this is that you should ask for advice but judge the reasoning of the advice rather than accepting it blindly (and re-judge it again when you have more experience), and doing that while also pleasing the person giving you advice can be a tricky social situation.

    2. Re:Post it by NicknameAvailable · · Score: 1, Funny

      So, when you're programming without an experienced manager above you, how do you go about improving?

      More easily.

    3. Re:Post it by TheRaven64 · · Score: 1

      Some people will correct you for having variable names over, say, 10 characters

      Variable length limits are important if you are using a language like C, where the compiler is not required by the spec to use more than the first 31 characters of an external identifier (which is great for obfuscating code with old compilers, where you can use multiple names to refer to the same identifier). This limit exists for some old binary formats that placed a hard limit on symbol table entries. If you are targeting an embedded system, long names for externals can still chew up a lot of space in the headers, so they're worth shortening to save memory. Elsewhere, the length won't have a detectable impact on performance (except sometimes in load times for large dynamically linked C++ programs).

      Beyond that, it's a question of how much information do you need to provide. People need to read your code. Your identifiers should be long enough that people can tell what the identifier is for, but not so long that it is redundant. For example, tmpFile and handleForTemporaryFile (or handle_for_temporary_file) are equally expressive, so there is no advantage in taking one of the longer ones for a local variable. It is conventional to use i, j, and k for loop induction variables in nested loops, so these don't need to be anything different either.

      others will tell you NEVER use a goto

      Very often the use of goto is a sign of other bad style. For example, I recently reviewed some code that contained a loop with some code at the end to proceed to the next element and a set of gotos at the start to skip over the body. This was easy to refactor by moving the increment to the start and turning the gotos into continues. The resulting code was smaller but, much more importantly, you needed to read less of it to understand what each line was doing. You could read the guard clauses at the top totally independently of the rest of the loop (if this condition is matched, skip to the next loop iteration), you no longer needed to find the goto target and work out what it was doing. I wouldn't say that you should never use goto, just that every time I've seen it used has been hiding some other form of bad style.

      others will give you a very hard limit on the number of lines any method should be

      The correct limit is that each method should be short enough that you can understand it in isolation. It can do a few complicated things, or a lot of simple things. Hard limits, like the 10 lines you mention, are not bad advice for new programmers: if your method is more than 10 lines long then you should be able to justify why it needs to be so long and why it can't be shortened or split. This is the most important rule of programming: if you can't justify why you're doing something, it's probably wrong.

      --
      I am TheRaven on Soylent News
    4. Re:Post it by Anonymous Coward · · Score: 0

      The proper length of a method depends on how many paths you are willing to write a unit test for. White box testing (very few paths) versus Black box (too many paths to test) testing. This is why the same programmer always writes the unit test when writing the code. There is no magic number of lines. Many things in coding are relative to your other coding practices so critiques without the context of the person doing the critique are often incorrect.

    5. Re:Post it by Peristaltic · · Score: 1

      ... others will tell you NEVER use a goto

      NOooo! That is the word the knights who say "Knuth" must never hear!

  4. quite obvious by miknix · · Score: 0

    get involved in a opensource project, the bigger the better, they often do QA reviews and force you to adhere to their guidelines and coding practices. Your ultimate test will be pushing something into kernel.org.

    1. Re:quite obvious by buchner.johannes · · Score: 1

      get involved in a opensource project, the bigger the better, they often do QA reviews and force you to adhere to their guidelines and coding practices. Your ultimate test will be pushing something into kernel.org.

      X is more difficult than the kernel, and probably more important too.

      --
      NB: The message above might reflect my opinion right now, but not necessarily tomorrow or next year.
    2. Re:quite obvious by marcosdumay · · Score: 1

      If dificulty of understanding code and getting it accepted is the metric, aim directly to Open SSH or Free BSD.

    3. Re:quite obvious by pclminion · · Score: 1

      X is more difficult than the kernel, and probably more important too.

      You gotta understand that with X, they have to be extremely careful what they accept, or they might end up modernizing the system. Nobody wants that.

  5. dont worry so much by Anonymous Coward · · Score: 5, Informative

    don't worrry so much about improving. you've probably been coding for 2 years or so (given you're in college) and have made amazing progress in those 2 years. the most important thing you can do is use existing libraries. when you reinvent the wheel, no one understands your code. when you use standard libraries, people still may not understand it, but it's going to be faster and more stable than equivalent code you wrote.

    i've been coding for 8 years and as long as your code is maintainable, works, commented, and capable, you're doing a good job. also, for the love of god, don't hardcode your file paths or operating system. use a standard library, never do a system call. when you have do, error check it.

    1. Re:dont worry so much by History's+Coming+To · · Score: 4, Insightful

      You're right, and I agree, but please humour me with a little devil's advocate...

      I recently worked on a pub website that needed to change to reflect the weather (they've got a big beer garden). My first stop was some code I'd written a couple of years back which parsed METAR data from airport weather stations - I'd already done most of the work I needed to do, but there were a couple of bits that I needed to add. Not wanting to use a bunch of (billable) time I had a look around and found a PEAR module that did much the same, plus a lot more. But it was pretty heavyweight for what I wanted, it was producing four dimensional arrays for example, when all I needed was $wind[speed], $wind[direction] and so on.

      In the end it turned out to be far simpler to hand code my own, an entire PEAR module was replaced by 20 odd lines of code.

      As I said at the start, I generally agree, it's important to be aware of resources like PEAR, CPAN and the like, but (especially when you're learning) you can progress by leaps and bounds by doing some things yourself. Plus sometimes there's a 5 minute solution compared with 20 minutes figuring out how Module-X works and how to integrate the results.

      --
      Please consider this account deleted, I just can't be bothered with the spam anymore.
    2. Re:dont worry so much by phantomfive · · Score: 3, Insightful

      It's a tradeoff. You need to be able to estimate the amount of time required:

      1) to write, debug, and maintain your own code
      vs 2) to understand, debug, and maintain (your integration with) someone else's code

      The way to get good at estimating those things is to try it. Try integrating someone else's code, and try writing from scratch. After a while, you get a feel for how long each one will take.

      --
      "First they came for the slanderers and i said nothing."
    3. Re:dont worry so much by wrook · · Score: 4, Insightful

      i've been coding for 8 years and as long as your code is maintainable, works, commented, and capable, you're doing a good job. also, for the love of god, don't hardcode your file paths or operating system. use a standard library, never do a system call. when you have do, error check it.

      It's hard to comment based solely on what you have written because I've never seen your code. But I have to question the level to which you are aspiring. There is a huge gulf in quality between code that works and code that is minimal and obvious. You say "maintainable, works, commented and capable". Unfortunately, that could describe code that is barely acceptable all the way up to excellent. I don't really know what you mean, so this might be superfluous to you.

      Code that works and is understandable is the minimum quality of code that I think is acceptable. But when you are designing (or refactoring) code, the decisions you make can have a large impact on the rest of the system. Because I read a lot of the original papers on design patterns, I tend to think of code as having a shape (a lot of the earlier descriptions used this kind of metaphor). Code that has an appropriate shape fits nicely with the rest of the code. It has a minimal complexity (i.e., the code is no more complex than the problem it is trying to describe). It also doesn't complicate other code that needs to talk to it.

      On the other hand, code with a shape that is not appropriate does not fit in. It introduces complexity based on its shape alone (independent of the problem it is trying to solve). Code that needs to talk to it often has to do something extra, or carry around some extra data to make it work. This creates an inappropriate shape for this new code. When you have one thing that doesn't fit well, it can have a ripple effect that increases complexity all through the code. Not only that, but there can be a multiplying effect. Each work-around that you introduce to accommodate inappropriate code causes more and more complexity.

      When I look at large software projects, most of the complexity usually comes from dealing with other code rather than solving the problem. The more code you have, the more complex your system becomes. Most software projects actually solve simple problems, but are still very, very complex. You might think that there is nothing you can do about this, but if you look at system libraries they often simplify your life. This seems opposite to the "more code = more complexity" argument. The difference is that these system libraries usually have an appropriate shape for what they are doing.

      Your advice is generally sound. Learning to use appropriate idioms, learning to use appropriate reuse libraries, writing understandable, working code is the basis of programming. But there is another level beyond this. Choosing appropriate code shapes, keeping complexity to a minimum, understanding trade-offs of coupling and cohesion -- This is quite hard and requires a fair amount of practice. Excellent code is not just maintainable and documented, but also minimal and obvious. When other code interfaces with excellent code, it is easy to do so and it introduces a minimum of extra complexity.

      IMHO, you should strive for this. If you think that you already accomplish this without thinking about it, then I invite you to look again. I suspect you may be overlooking something.

    4. Re:dont worry so much by Capt.+Skinny · · Score: 1

      as long as your code is maintainable, works, commented, and capable, you're doing a good job

      I strongly disagree. Anyone in a CS program can debug code that doesn't work, or refactor code that looks bad. The benefit of experience is being able to anticipate what might go wrong in the future or under different conditions. It's about knowing what to look out for before it becomes a problem.

      I'm sure all the newbie coders whose work adorns The Daily WTF thought their code was maintainable and functional, but it shows up on TDWTF because it broke when conditions changed and someone had to go fix it. Bottom line: if you don't have a lot of coding experience, you don't have the experience to judge your own work.

    5. Re:dont worry so much by Anonymous Coward · · Score: 1

      I completely agree. you have to pick and choose which modules you reuse excessively. eventually you'll get a feel for it.

      however, if you ever parse a nastran file (a structural analysis fortran based format), you can use a library that supports everything or you can code exactly what you want to support. it's a library dependency vs .100 buggy lines of code. i've replace so many of the 100 lines of code with the sledgehammer library that i've learned while it may not always be as fast, it's always going to be more robust. you'll end up fixing bugs you didnt even know you had.

    6. Re:dont worry so much by Anonymous Coward · · Score: 0

      Thank God not everyone believes in not reinventing the wheel. Imagine where we'd be if we were still using the original STL implementations...

    7. Re:dont worry so much by Anonymous Coward · · Score: 0

      if you want an example of my code, check out pyNastran. it's my little open source project. it's not perfect, it's got plenty of areas that are hackish, but "perfect" is the enemy of "good enough". that said, because it's open source, i have infinite budget and can rework those areas. on open source projects, "perfect" is the enemy of a "new features".
      http://code.google.com/p/pynastran/

    8. Re:dont worry so much by wrook · · Score: 1

      Not sure you will see this, but I wanted to say that I looked at your code. I didn't spend nearly enough time on it to make a fair comment on it, but writing open source code is a great way to get feedback on your code. I definitely get the same feeling on my own project (http://jldrill.rubyforge.org/) with respect to "perfect is the enemy of new features". Often I need a feature and I simply don't have enough time to implement it well. Those kinds of short term and long term tradeoffs are tricky. The term "technical debt" is a popular one and describes the issue well, I think. Sometimes you can dip into debt, but if you don't repay it quickly enough, it can sink your project.

      If there's one thing that I would suggest thinking about it's that there is almost certainly a sweet spot where attention to detail, while initially slower, improves productivity throughput overall. Things like writing unit tests can double your implementation time, but over the long run it may end up being significantly faster than not doing it (Actually, I will say that when done properly, this is almost certainly true). Additionally, there are subtle design issues that if you make a mistake, it can cost you a fair amount of time either through the resultant complex code, or though the need to refactor.

      Training is really important. My little project is training for me. There is lots of crap code in there, either from failed ideas, experiments gone wrong, or just plain being too tired to do it correctly. But by working on it and being very attentive to what sucks I can make pretty good gains in my own ability to find appropriate designs quickly. You can't really do that on a work project because it is inappropriate to experiment that way. Looking at your code, I get the impression that you also get a lot of personal benefit from working on your project.

      Thanks for the conversation!

  6. It's all in the comments... by History's+Coming+To · · Score: 3, Insightful

    Ask somebody else to make changes to your code. You'll see plenty of arguments over pre-v-post incrementing or whatever, but the big thing is how well laid out and commented your code is...commercially, the chances of you being the only maintainer in perpetuity are practically nil, so it has to be readable to humans as well as computers. I'm well aware it's my major issue as a programmer, and one that I'm constantly working to improve.

    --
    Please consider this account deleted, I just can't be bothered with the spam anymore.
    1. Re:It's all in the comments... by Anonymous Coward · · Score: 0

      Ask somebody else to make changes to your code. You'll see plenty of arguments over pre-v-post incrementing or whatever, but the big thing is how well laid out and commented your code is...commercially, the chances of you being the only maintainer in perpetuity are practically nil, so it has to be readable to humans as well as computers. I'm well aware it's my major issue as a programmer, and one that I'm constantly working to improve.

      If you have to write comments, your code is not readable nor understandable by another person. So long as you have not written a compile error, the computer will always be able to understand your instructions. Write for the poor fool that has to come behind you and figure out what your code is doing. If you stay with a job long enough it may just be you.

    2. Re:It's all in the comments... by UnknownSoldier · · Score: 1

      > If you have to write comments, your code is not readable nor understandable by another person.

      That's nonsense.

      _Proper_ commenting tells _why_ you did something. I want to know _how_ you did something I can [usually] read the code.
      i.e.
        * Did you work-around an existing design flaw that would be too big to fix?
        * Was this a result of fixing another bug that exposed a new issue?
        * Is the code doing something tricky / non-obvious?
        * It also doesn't hurt to give a -reference- for the algorithm, because sometime it is not obvious WHY the code is doing what it is.
      e.g.

      // Reference: http://en.wikipedia.org/wiki/Fowler%E2%80%93Noll%E2%80%93Vo_hash_function
      uint32_t HashFNV1a( int8_t * pData ) { ... }

  7. github by Anonymous Coward · · Score: 0

    (open source contribution)

  8. Learn from others by Anonymous Coward · · Score: 4, Insightful

    No matter how experienced a coder you are, you can only learn from others. Your code should meet the standards of others - eg look at equivalent source (open source projects). If your code is less than 1000 lines of code, then it can be considered "trivial" - by all means compare with other small projects. But look at 10,000-100k+ line projects and try to understand them. Now, look at your own code, and does it have the same modularity.

    Is your code "clever"? Then its wrong. (Vast generalisation, apologies).

    Learn the tools to debug and look at memory leaks, bad constructs, coverage etc. Try them - as many as possible, on your code.

    And when you have done all of this, if you believe your code is good, then go back to the start of this subject and start again.

    Additional points: measure your code quality after you have written 100-500 scripts/programs.

    Those doing professional programming are never happy with their own code - they want to enhance and improve it continuously. Often, there is not the time to do this.

    1. Re:Learn from others by phasmal · · Score: 1

      I think the "only learn from others" here is overselling it a bit.

      On one hand you'll miss something is you only learn when others learn from your code. You'll miss the ability to learn from how others code. I suggest reading about developing software. Note that this doesn't mean "read about X language" - I mean read articles and blogs about what makes code good.

      To take it further, though, you'll miss an opportunity to learn *more* from others, as well as learn on your own if you don't take it further and be introspective about your performance and your code.

      The idea is to try an idea or technique out - even take it too far - and simply see what the results are yourself. Read your code after writing it. Read it straight away, and read it much later after you've been doing something else. Spend time thinking about coding, how you've approached things and what the result has been.

      Put these three things together (learning from others looking at your code from parent post + looking at others ideas + developing your own) and you'll become a better programmer.

    2. Re:Learn from others by Anonymous Coward · · Score: 0

      No matter how experienced a coder you are, you can only learn from others....

      Uh huh. Never crashed the most important system in the enterprise, now have you?

    3. Re:Learn from others by phantomfive · · Score: 1

      Is your code "clever"? Then its wrong.

      No one ever thinks their own code is clever. Other people's code is clever.

      --
      "First they came for the slanderers and i said nothing."
    4. Re:Learn from others by Brian+Feldman · · Score: 1

      Nah, you can learn from yourself.

      --
      Brian Fundakowski Feldman
    5. Re:Learn from others by skarpik · · Score: 1

      Additional points: measure your code quality after you have written 100-500 scripts/programs.

      Those doing professional programming are never happy with their own code - they want to enhance and improve it continuously. Often, there is not the time to do this.

      The jobs I do take 2 or 3 months to complete. If I waited for 100 "scripts/programs", it would be 25 years before I'd review my work. Consequently I think more frequent review makes sense for some of us. I find that I can look back at my work a year or so after doing it and get a good sense of what I've done well and what I need to do better. Looking at the code closer to finishing it, I just don't have the objectivity to see my work clearly. Looking at my work after enough time has passed, I sometimes think "that was pretty good" or more often "I could have done things a bit better here". I'm not referring to things like memory leaks etc. (which I consider bugs that should be ironed out before the code is released) but rather the overall structure and logic of my approach to the problem my code is trying to solve.

    6. Re:Learn from others by CaptSlaq · · Score: 1

      Is your code "clever"? Then its wrong.

      No one ever thinks their own code is clever. Other people's code is clever.

      No humble person thinks their code is clever.

    7. Re:Learn from others by phasmal · · Score: 1

      An eg blog is Coding Horror - and a good starting out post is: http://www.codinghorror.com/blog/2004/10/a-pragmatic-quick-reference.html

  9. Guaranteed way to improve your programs ... by petes_PoV · · Score: 4, Insightful

    So, when you're programming without an experienced manager above you, how do you go about improving?"

    Document them.

    Write man(1) pages, describe the source code, include hints about WHY you chose the algorithms you used (and which techniques didn't work). Have a high-level document to say what a program is intended to do, in what environment, with what limitations and how the output should be used (this works for "batch" right through to web pages and apps). Show how it should be built, what test data you used, what the results were and how the tests were performed.

    If nothing else, yo will learn that writing source code is the easiest 10% of being a professional programmer and that the other 90% is a hard, dull slog. However, it's that other 90% that separates the "play" programmers from the professionals.

    --
    politicians are like babies' nappies: they should both be changed regularly and for the same reasons
    1. Re:Guaranteed way to improve your programs ... by Anonymous Coward · · Score: 1

      Rather than man pages, he should write executable documentation, a.k.a. unit tests.

      If you can't write unit tests easily, it's likely that your code has problems. If you notice where you're having problems writing tests, it will point you to where the problems are in your code. On the other hand, if you've got comprehensive tests and they're easy to write, chances are your code is maintainable, which is 90% of the way to being good.

    2. Re:Guaranteed way to improve your programs ... by Anonymous Coward · · Score: 1

      petes, your comment about writing out documentation is crap. To the OP, while others are riding the waterfall down to irrelevancy, try MAKING SOMETHING. See if it works. Better yet, test it. Also, instead of WRITING A BUNCH OF CRAP DOCS THAT WILL BE OUTDATED, why not write tests (a la Test Driven Development). Then give it to your peers and see if they can USE it. I'm not talking about the whole program, I'm talking about your code/libraries/mixins/macros/WTFelse you write.

    3. Re:Guaranteed way to improve your programs ... by Anonymous Coward · · Score: 0

      Documentation is like sex. When it's good, it's really good, but when it's bad, it's still better than nothing.
       
      Saying "But what if the program changes later?" is not a good excuse to avoid documenting. If 90% of it is right, it's still massively more useful than no documentation at all.

      One thing I discovered when I started documenting is that it forced me to think about how I was structuring my code, and I spotted lots of overarching inconsistencies that I would never have found otherwise.

      Commenting code is a good start, but that only helps to understand individual methods or files. If you want your whole program to be cohesive and consistent, try writing a doc.

  10. Code Review Stack Exchange by Anonymous Coward · · Score: 5, Informative

    You can try posting at least some of the code here:

    http://codereview.stackexchange.com/

    1. Re:Code Review Stack Exchange by Anonymous Coward · · Score: 1

      How do I accept this as the answer?

  11. Time and features/improvements by sunderland56 · · Score: 4, Insightful

    Several ways: one is time. When you go back and look at a routine you haven't seen for six months, does it still look good? Or are you tempted to rip it apart and rewrite it? Did you put in adequate comments, so that you can remember necessary details after that length of time? Sure, coding styles change, but you shouldn't hate your old code.

    Another is features. When you need to add/change/improve something, how easy is it? Do you need to rip apart old code, or can you just drop in something new with minimal changes? Does it work when the OS is updated?

    Another is *user* feedback. If the project works, doesn't crash, and is easy to use, great. If you get questions about "how do I..." or "why does it..." then think about how your code could change to help the end user.

    1. Re:Time and features/improvements by Anrego · · Score: 1

      Totally this!

      I'll also add that when you find something that you later decide was written poorly, or is unmaintainable .. don't just bin it and move on.. really look at _why_ it's bad and how you got to that point. Sometimes you were just having a bad day, sometimes it was lack of understanding, but sometimes there are things in your design process that should be fixed. Is the problem due to something you could have foreseen? Why didn't you foresee it then! What can you do in the future so this won't happen again.

      Don't agonise over it though. Sometimes it's just bad luck, lack of sleep, lack of time, etc..

      General advice wise, I like to keep checklists .. and tend to add steps from previous mistakes. A quick little "have you ..." list takes very little time to run through, and can catch a _lot_ of stuff!

  12. Walk-throughs by Anonymous Coward · · Score: 1

    When I was working IT, we would schedule "walk-throughs", a meeting where other programmers would examine the code and offer suggestions. They never became "walk-ons". It was one of the best experiences I had. I gained respect for other's perceptiveness, creativity, and constructive criticism. Since everyone would eventually have a walk-through, we were professional and gentle, because we knew that we'd be in the hot seat sometime.

  13. Code Review Stack Exchange by Anonymous Coward · · Score: 2, Informative

    There is a Stack Exchange site for this -- codereview.stackexchange.com

  14. Why so rigid? by hackwrench · · Score: 1

    The professors work for the university. If the dean tells them to help[ with non-academic projects, they should be willing to help. At least that's how it works in many workplaces.

  15. Stick it in a box by phantomfive · · Score: 4, Insightful

    Stick your code in a box, then forget about it for six months. Then come back, look at it, and figure out what parts make sense, and what parts don't make sense. And what parts you think are entirely horrible. Sometimes this works on a timescale much shorter, I've seen code I've written the day before, and thought, "what idiot wrote this??" Usually it's not that bad, though.

    Three principles to follow, though, and if you get them, your code is gold. Make it:

    - Work (if your code doesn't work, or is too buggy, nothing else matters, the code is useless).
    - Readable (if no one else can read it, then your design principles won't matter because no one will figure them out).
    - Flexible (if your code is flexible, then you can easily deal with changing requirements)

    If you can get the first principle, make your code functional and mostly bug-free, then you're already in the top 50% of professional coders. If it's readable, you're in the top 1%. If it's also flexible on top of that, then you can write a book that people will admire for decades. Or a programming language. Sad but true.

    --
    "First they came for the slanderers and i said nothing."
  16. Read "Code Complete 2" by Anonymous Coward · · Score: 0

    Read Steve McConnell's "Code Complete 2", then do everything it says. It's like packing 5-10 years of experience into 1 book, and it is by far the best book on the subject.
    http://www.amazon.com/Code-Complete-Practical-Handbook-Construction/dp/0735619670

  17. read professional work by Anonymous Coward · · Score: 0

    Find and read bodies of code you really like. Compare it with your own work. If you want to sound like a rockstar you might not be able to get them to comment on your demo tape, but you can listen to thier work. Also when joining a team the first thing you should do is survey the scene and adapt.

  18. Why not professors? by buzzsawddog · · Score: 2

    Why can't you ask your professors to look at non classwork? I on more than on occasion went to my professors for non class related things. It really helped out in their classes, often times they were helpful due to the fact that I took interest outside of class in what they did. Open source is one way to have code review as posted by several other people. I find that my wife is not a good resource... She says things like "You did all that just for that, why not just use something thats already out there..." Work with upper and lower clansmen... While its true they may not have much more experience than you they do have different experience. They often times can see things different than you. Look for mentors in the industry or at work. Lots of people like to hear themselves talk so they are more than willing to ramble on to you.

    1. Re:Why not professors? by Anonymous Coward · · Score: 0

      You can ask professors, but as a study of PhD-Comics you know that they do not have time for this.

  19. bit of reading by lynnae · · Score: 2

    If you haven't been taught, or feel you haven't been taught, enough about coding conventions (god knows I wasn't), try reading Clean Code by Robert Martin and also Refactoring by Martin Fowler.

    A good knowledge of design patterns is also very useful to cultivate. It makes problems easier to handle and solutions faster to devise.

  20. forrst by Anonymous Coward · · Score: 0

    You could try posting on forrst to get constructive feedback.

    https://forrst.com/

  21. get a summer internship by Surt · · Score: 1

    That's pretty much the way to both start networking, and get some feedback on your skills so you can improve.

    --
    "Who is the Journal of Quantum Physics going to believe?" --Stephen Hawking
  22. Read lots of other peoples code, rewrite it by Anonymous Coward · · Score: 0

    See what makes other peoples code hideous and hard to read, go about properly formatting/commenting it as you are trying to understand it, and see if there are better ways to reorganize it and possibly refactor duplicate code with defines or templates; basically, spend a lot of time cleaning up crap code.

  23. Manager??? by stanlyb · · Score: 1

    Experienced? Manger? Experienced Manager??????? Man, i am still waiting to see these two qualities in one man, but nevertheless, what this "manager" wants is to have the program at time, even if it is barely working......eventually...

    1. Re:Manager??? by Dogbertius · · Score: 1

      I generally tend to agree with this sentiment, save for the case of my current employer, with whom I've stuck around for several years. First time I've worked in an environment where all managers have bachelors and masters degrees in engineering, physics, or biochem; and either a Ph.D. in engineering or an MBA. Best place I've ever worked at, and could not be any closer to the polar opposite of the typical Dilbert-style office.

    2. Re:Manager??? by Anonymous Coward · · Score: 0

      Yep, managers tend to be glorified schedulers. They will pop in occasionally with their spreadsheets asking when the current project will be done, or to ask you to estimate some half-baked idea for a feature. They typically know nothing about programming or evaluating talent.

  24. Coop by Dogbertius · · Score: 2

    Doesn't your university offer coops or internships? A few months of work in industry should help, even if the wage is shit.

  25. Generic advice by Anonymous Coward · · Score: 1

    Study hard and stay in school!

  26. Crap by SnarfQuest · · Score: 1

    It's crap. If you continue on programming, come back in seceral years and you'll agree. Very few people write code in their first few years that they don't come back later with that opinion.

    --
    Who would win this election: Andrew Weiner vs Andrew Weiner's weiner.
  27. Internal code review by gratuitous_arp · · Score: 3, Insightful

    > Since we're students, though, no one really has the experience to offer major advice or critiques

    See how the other students would feel about internal code or design reviews. They may or may not know what it is and they may take it the wrong way or not like the perceived criticism from peers, depends on your relationship with them.

    About none of you having much experience -- maybe not, but part of college is wrestling with challenging questions that you don't know the answer to with people who don't know the answers either. If you're working for the college, even better. It may only lead to marginally better code, but hopefully you would all learn from each other. And it would look good on a resume to say you "improved coding standards and helped foster growth among colleagues by proposing and implementing a peer code review system."

    1. Re:Internal code review by msobkow · · Score: 1

      Aside from asking your peers about whether they'd like to do peer reviews, you could also ask them how much experience they have. Just because someone is a student doesn't mean they have no programming experience.

      I and two first-year friends of mine, for example, pretty much skipped our entire first year programming course except when exams were scheduled (with the blessings of the prof) because we'd all been programming machine language since we were 14-15 years old. By the time we hit university, we had 3-4 years of programming experience and were way beyond our classmates who were still learning basics like how to work with arrays and how to code loops.

      Keep in mind, though, that we had no experience with the professional aspects of code. In other words, we didn't know how to document worth shit.

      --
      I do not fail; I succeed at finding out what does not work.
    2. Re:Internal code review by msobkow · · Score: 1

      I'll never forget wishing I could just walk out during the first 2-3 classes before I knew attendance wasn't mandatory. We sat through 30 MINUTES of some stupid humanoid trying badgering the prof as to when and where semi-colons were required. It was a brutal, brutal discussion. This individual was as dumb as the proverbial post, and could not grasp the basic idea that you needed a semi colon at the end of every statement except the last one in a code block. It was scary to think this individual might some day be a programmer.

      But we need not have worried. The bozo was failing so bad two months into the course that they quit. The classmates who had to attend lectures to learn the details of programmer were greatly relieved to have monkey-brain gone. None of them could ask real questions because yoyo would not STFU and let anyone else ask a question that went beyond the most basic syntax clarification.

      BTW, despite wasting 30 minutes of the prof's time, wank-meister got a whopping 5/50 on their first lab because even with feedback from the compiler, they could not figure out where to put the semicolons. It was pretty pathetic. They'd done so bad the lab instructor held up their work and used it as an example in front of the whole class of how not to write code.

      --
      I do not fail; I succeed at finding out what does not work.
    3. Re:Internal code review by msobkow · · Score: 1

      Sorry for all the typos and grammar errors. I've got a migraine from hell and I'm having trouble seeing due to auras, so I'm pretty much touch-typing with my eyes closed.

      --
      I do not fail; I succeed at finding out what does not work.
    4. Re:Internal code review by Anonymous Coward · · Score: 1

      please do yourself a favor and turn off everything with a blue led then go to bed !

    5. Re:Internal code review by Daniel+Dvorkin · · Score: 1

      This individual was as dumb as the proverbial post, and could not grasp the basic idea that you needed a semi colon at the end of every statement except the last one in a code block.

      While it's true that the semicolon at the end of the final statement is unnecessary, it's also true that relying on the final statement you write to be, well, final is a really bad idea. Taking "advantage" of shortcuts like this is IMO a terrible programming practice and ought to be avoided. Honestly, sometimes it's easier to deal with out-and-out idiots like your classmate than "clever" programmers who write unmaintainable code full of traps for the person who inherits it.

      --
      The correlation between ignorance of statistics and using "correlation is not causation" as an argument is close to 1.
    6. Re:Internal code review by msobkow · · Score: 1

      Dude, we're not talking "C". We're talking a much, much older language called PL/C. If you put a semicolon at the end of every statement as you suggest, the compiler would barf.

      --
      I do not fail; I succeed at finding out what does not work.
    7. Re:Internal code review by TheRaven64 · · Score: 1

      Umm, no. The grandparent is talking about a language like Pascal, where semicolons are statement separators, not statement terminators. Placing the extra semicolon at the end may significantly alter the semantics of the code, often in quite subtle and difficult-to-debug ways.

      --
      I am TheRaven on Soylent News
  28. Interact with people you respect by Yoik · · Score: 4, Insightful

    You must know other students who code, trade reviews with friends.

    One problem is that to do a decent job of reviewing code, you need to know what it is supposed to do. Practice writing requirements, program specifications, design documents or whatever fits the development style you are being taught, but you will probably have to explain a lot verbally to your friend unless you are amazing. Then he can give you a meaningful review and your users will have a more valuable product.

    Doing the reviews of a friends code will teach you as much as getting yours reviewed does. You may be surprised at how much work it takes to make good suggestions for improvement. Also, there is a skill to offering criticism in a way that it will be accepted instead of generating anger.

    There are development styles based on this practice, I hope you have good luck with it.

  29. learn by refactoring.. by Anonymous Coward · · Score: 0

    look at your code and honestly answer the question: can someone else understand this? refractor your code until you answer yes.
    are there any duplicated code? I.e. cut and pasted or similar code? refractory till answer is no.
    this will help you to improve. good luck!

  30. Start reading TheDailyWTF by MrEricSir · · Score: 4, Insightful

    You should start reading TheDailyWTF. If your code ends up there, you are doing something very, VERY wrong.

    And if it doesn't, even better -- you can learn from others' mistakes.

    --
    There's no -1 for "I don't get it."
  31. Well... by Anonymous Coward · · Score: 0

    When I was having a particularly difficult time writing poetry, my professor told me: stop writing and read. Maybe it works for code, too.

    I don't know about feedback per se, but for improving (and learning fun math along the way) try Project Euler. You'll be able to see how other people completed the same problems (and in different languages). It's not really about "what is the right way to do this" but "why is it done this way and not that way."

  32. Read popular software already written by Anonymous Coward · · Score: 0

    I learned a LOT by reading the MediaWiki and WordPress sources.

  33. Review it yourself by Anonymous Coward · · Score: 0

    After you write a block of code, wait six months and then go back and review it. Chances are if you're improving and learning and gaining experience as you should be, it'll look terrible. You'll be able to critique your own work, learn from your mistakes and learn to avoid problems in the future.

  34. Review your old code!!! by Anonymous Coward · · Score: 0

    Read code you wrote 6 months ago, a year ago and two years ago. If you don't see the difference you have not improved....

  35. befrend a professor you respect by Anonymous Coward · · Score: 0

    Outside of the intro classes (run by people usually just happy to get the paycheck) there are usually a few professors that actually do open source coding and/or research into programming... they seem to usually teach advanced coding/algorithms. Just network with them, find/ask for something you can maybe help them with and/or ask for suggestions in code that you've written.

    Usually these people don't want to withhold knowledge, they wouldn't be in academia if they did, and as long as you aren't completely annoying about it they will most likely be happy to help you with whatever questions they can spare time for. They are there to teach you after-all.

    The one regret I have in my college experience was that while I was better then most of my peers at stuff like coding the concepts discussed in class, it meant I wouldn't hit up professors in office hours like the suckup morons, that were in there every time they had office hours to suck up and try and get their programs done for them. Those same professors can be very helpful in recommending smart people later on, since most universities serve a regional community plus a lot of ex-students now in hiring positions looking for people from professors they stayed in contact with.

  36. Review your own code!!! by CiarnOS · · Score: 1

    Re-read code you have previously written.

    Start with code two years old, then a year old, then 6 months old. If you do not see an improvement you probably have not improved....

    1. Re:Review your own code!!! by Anonymous Coward · · Score: 0

      My thesis advisor told me this. There is no such thing as good writing. There is only good rewriting. The same applies to code. Go back over old stuff and try to improve it.

  37. Find a mentor by SQLGuru · · Score: 2

    Find a mentor.

    Join a local user group for the language/technology of your choice and make friends. Find one that is quite experienced and learn everything you can from them.

    1. Re:Find a mentor by xhrit · · Score: 1

      IRC is a good place to network with programmers. FreeNode in specific has a large community of very helpful people who populate the programming channels. slap a snippit of your code up on a pastebin, post the link in a busy programming chan and ask "What am I doing wrong?". Chances are you will get a handful of insightful comments on areas you didn't even know you had a problem with. ^^

  38. I work in the industry by Ryanrule · · Score: 1

    It doesnt matter. You wont be attached to any project long enough to make a difference. Keep your head down, and leave for 20% more pay in 2 years.

  39. Document with care by Anonymous Coward · · Score: 2, Interesting
    There are a couple of problems with documentation:
    1. Too much documentation in the code renders it harder to read.
    2. The documentation will eventually become wrong because people change the code but do not then fix the documentation.
    1. Re:Document with care by Anonymous Coward · · Score: 3, Insightful

      Too much documentation in the code renders it harder to read.

      Only if you're doing it wrong. If you're doing it right, you won't be adding too much. It just won't happen.

      The documentation will eventually become wrong because people change the code but do not then fix the documentation.

      Those people should be fired. Preferably out of a cannon.

      Man pages - yes

      Documentation at the beginning of the file telling how to use it - yes

      Those are okay.

      Documentation within the code - mostly no - learn to write self documenting code.

      This is absolutely wrong and inept. Comments are not for telling what the code does; they tell why it does it. You will never write good code until you purge yourself of the stupid that comes from this fundamental misunderstanding. Once you get this straightened out, you will never produce bad comments again.

  40. Stop caring. by Ryanrule · · Score: 2

    You make more money if you dont care. And you make less stress.

  41. Try this experiment by Tim+Ward · · Score: 3, Interesting

    (1) Print out your code

    (2) White out all the actual code, using Tipp-Ex, leaving just the comments visible

    (3) Give the result to one of your fellow students, and ask him to rewrite your code in a different language.

    If s/he fails, you didn't write enough comments.

    1. Re:Try this experiment by dwmw2 · · Score: 2
      Hm, I'd have said that if s/he succeeds then you're almost certainly guilty of overcommenting your code. A lot of good code is completely self-explanatory. You really don't want to litter it with pointless comments that just detract from the value of the comments that should have been there.

      Nobody needs to see comments like:

      /* Add one to the count */
      count++;

      Yet without that kind of thing, it would be hard to reimplement the code from the comments alone. (Yes, if you have decent JavaDoc-style comments describing each function, and you have small self-contained functions, then perhaps they could reimplement each function from scratch just by knowing its arguments and behaviour — they don't need the contents of each function at all. But that's not quite the same thing.)

    2. Re:Try this experiment by marcosdumay · · Score: 1

      Yes, if you have decent JavaDoc-style comments describing each function, and you have small self-contained functions, then perhaps they could reimplement each function from scratch just by knowing its arguments and behaviour — they don't need the contents of each function at all.

      Now you got what the GP meant.

      Anyway, I don't know if I agree. Writting such kind of comments sometimes takes more time than writting the code, and the function name should be self explanatory most of the times. For an API, surely, the docs are a must have, but for internal code that only one module will touch? I think the answer is not universal.

    3. Re:Try this experiment by pinkeen · · Score: 1

      This should be modded funny or I my world view has just been shattered.

    4. Re:Try this experiment by msobkow · · Score: 2

      That depends what your goal is. If your goal is maintainable code, try deleting all the comments and ask people to tell you what the code does.

      If they can't figure it out from the function and variable names, you need to stop using non-descriptive names like "i".

      --
      I do not fail; I succeed at finding out what does not work.
    5. Re:Try this experiment by Anonymous Coward · · Score: 0

      The last time i checked, comments were tossed by the compiler. All this is just intellectual masturbation. The other way around is more useful. Strip out the comments, and if someone can't piece together what each function is doing, you coded it incorrectly.

    6. Re:Try this experiment by rthille · · Score: 1

      /* Add one to the count */

      Is useless, yes. But a comment explaining why isn't. Rationale is the thing missing from the code, and the thing you need most when it goes wrong. I don't need a comment as to what the code is doing, I need a comment as to what it's trying to achieve by doing what it's doing, and why.

      And comments like "returns the current time in microseconds. Can never go backward" which was patently false can fuck right off! :-)

      --
      Awesome furniture, accessories and cabinetry in Santa Rosa, CA: http://humanity-home.com/
  42. Look for professional meetups by Junior+J.+Junior+III · · Score: 2

    In my area, I'm lucky that we have a large number of self-organizing developer groups. I found a bunch through meetup.com, and since I started going I've gotten much in the way of advice and encouragement, and picked up some insight. If you participate, don't just go and hang out -- put together presentations, and ask the audience for their thoughts. Probably lurk a while before doing that, but once you get the flavor of how they are run, put something together that you feel strong at, and present on it.

    --
    You see? You see? Your stupid minds! Stupid! Stupid!
  43. Re:Don't listen by Samantha+Wright · · Score: 2

    We have a saying in bioinformatics: "sadly, that's typical of academic software." It means that the standards the submitter is coding to depend on what field he or she goes into; since we don't know, we can't really say!

    --
    Bio questions? Ask me to start a Q&A journal. Computer analogies available for most topics!
  44. If it's small, crowdsource it by Anonymous Coward · · Score: 0

    There's a lot of people on http://codereview.stackexchange.com/ that are happy to critique your code.

  45. imitate, assimilate, innovate. by mevets · · Score: 1

    I'm certain Terry Clarke would never expect his advise to apply to something as humdrum as making a computer more useful; but this is the mantra of all artistic endeavours.

    If you can find talented people to work with, so much the better. Either way read! Read good code. Read bad code. Learn to tell the difference. Open source is a treasure trove; it covers the range. Closed source isn't any better; in fact it is often 'secret' because its embarrassing.

    Read some books on the topic. Not algorithm books - although you should read those too - but "Elements of Programming Style", "Software Tools", "Programming Pearls" ( the latter has nothing to do with that baroque version of awk, btw). These books focus on developing the craft.

  46. Yeah by Ryanrule · · Score: 1

    "So, when you're programming without an experienced manager above you, how do you go about improving?" You dont, you either do jackshit, or change jobs.

  47. LKML by Anonymous Coward · · Score: 1

    Post to LKML.

  48. Clean coding by Anonymous Coward · · Score: 2, Interesting

    The most useful thing that I've recently discovered in my 3 years of professional programming is "Clean Code" by Robert C. Martin. It covers most of the lessons that I've learnt the hard way.

    The things that don't necessarily seem important when you're striving to get something working are usually the things that make a difference. Naming of classes, methods and attributes so that code describes what it's doing, keeping your in-code documentation up to date so it doesn't lie and adhering to SOLID principles (http://en.wikipedia.org/wiki/SOLID)

    I'd thorougly urge you to read it. My colleagues (whom I respect greatly) have also recommended "The Practice of Programming" by Kernighan and Pike, that's probably also worth a look too.

  49. Run your code, and analyse it by Anonymous Coward · · Score: 0

    One of the best ways to measure the quality of your code is to run it. This might sound obvious, but in a corporate environment there is a lot of pressure to develop software quickly. If you spend a lot of time making your code perfect to read, and extend, you may not be making the best use of your time.

    The iterative development methodology is a good way to develop software, I feel. You write enough to get your software working, and deploy it to be tested as soon as possible. If it works, then you are doing a good job. If it doesn't you still have time to improve it. You will need to monitor the performance of your code when it is running, and make adjustments, if it's not meeting your expectations though.

    Next time you go to write a similar functionality, you will know from experience what worked, and what didn't.

  50. If it does what it is supposed to... by Anonymous Coward · · Score: 0

    and doesn't crash randomly while doing it, I am sorry to say you will be ahead of almost everyone these days, proprietary and open source alike. It really pains me that computers seem to becoming slower and less stable, even as hardware becomes faster and more resiliant.

  51. static analysis by Anonymous Coward · · Score: 1

    Look for a static analysis tool for the language you are using. That should give you plenty of feedback that is generally accepted among veteran software developers.

  52. The answer by Anonymous Coward · · Score: 0

    Let me save you alot of time. Your code is shit. Does it work? If so its passable shit. Does it make us money? If so, its good shit.

  53. Just use me as a reference by Billly+Gates · · Score: 1

    I am a badass coder and here is some of my awesome code from my login page in php 4 that is super secure

    $query_login="select * FROM user";
    $result_login = mysql_query($query_login) or die("Your passwrod is might be bad I think"); //$login_check = mysql_num_rows($result_login);
    while($row=mysql_fetch_array($result_login))
    {
    $username=$row["username"];
    if ($username==$username1)
    {
    echo "";
    echo "window.location.href='login_error.php?rec=qq';";
    echo "";
    exit;
    }
    }

  54. Document each entry point. It'll save your behind. by tepples · · Score: 1

    Writting such kind of comments sometimes takes more time than writting the code

    But it can save your behind when you try to use code that you had written months ago. Documenting each method's pre- and post-conditions has saved mine several times. It may take more time than writing the code, but it takes less time than trying to troubleshoot why it's not doing what you expect and ending up discovering that the caller had not met a pre-condition.

  55. Certification by Anonymous Coward · · Score: 0

    Certifications, such as Oracle Certified Professional Java Programmer, aren't extremely popular, but studying OCPJP (then SCJP) forced me to learn a lot of bizarre intricacies of Java we glossed over in college (i.e. { byte a, b; a = b = 1; a = b + a; } fails to compile because + returns an int, so you need a cast a = (byte) b + a;).

  56. Read other people's code. by darkwing_bmf · · Score: 1

    I learned the most just by reading the code of people who are good coders. Especially if they're the type to put good comments in.

  57. Two ways by lightknight · · Score: 1

    There are two ways to improve your coding that I know of, that can be done without someone else's input.

    1.) Download code from the many online repositories, and study it. More experienced programmers have interesting tricks that help make your code both better, and more readable. For instance:

    When I was a novice programmer, I would wrap entire statements in an if{} like:

    if(var == true) {
              doSomething();
    }

    which at first seems ok, until you run into bigger blocks of code. By the time you get to:

    if(var == true) {
              doSomething();
              doSomething2();
              doSomething3();
              doSomething4();
              doSomething5();
              doSomething6();
              doSomething7();
              doSomething8();
    }

    you start to lose track of the trailing curly bracket.

    After studying some code, I realize it is simpler to do this:

    if(var == false) {
              return;
    }
    doSomething();

    where you find the conditions that would not trigger a block of code to run, and return early.
    It makes the code so much easier to work with.

    Additionally, if you are dealing with multiple errors, such as when you are dealing with users entering information into a database app, it's easier to just declare a more global string, append the errors to it (when validating), then check if the string is empty before sending the data to the database (if it's not empty, just display the string in a simple textbox at the top, with bold red font).

    2.) Read books on the language / books containing good code. I think O'Reilly has a book called "Beautiful Code" which may help you there.

    Since I program primarily in a MS environment, it has helped me to realize, after dealing with their APIs and what not for quite some time, that you need to balance between abstraction and pragmatism. Too much abstraction, as I've encountered in a Java environment, and you are chasing methods, constants, and fields all over the place. It can take hours to understand some piece of code with one too many layers of abstraction. On the other hand, not enough abstraction results in VBish code, with God-functions, which are also a headache. You want to segment your code so that you can get work done, and still be able to understand what you are doing without having to read the comments.To that end, think of good, but relatively short, variable and method names. Do not be afraid to give a variable a lengthier, but descriptive name. In today's day and age, you don't need to save disk space by sacrificing readability.

    --
    I am John Hurt.
    1. Re:Two ways by Travelsonic · · Score: 1

      To further simplify that code slightly, would

      if(!var)
      {

                return;

      }

      doSomething();

      be as equally valid as the latter example you showed?

      --
      If you believe in privacy, and believe you have "nothing to hide" at the same time, you're a goddammed idiot
  58. Your code sucks eggs! Go to law school!!! by Anonymous Coward · · Score: 0

    Oh, maybe you wanted constructive feedback... ?

  59. Form a critique group ... by Anonymous Coward · · Score: 1

    > When asked this question, I often think, "How do aspiring writers learn their craft?"
    > People who study English read ridiculous numbers of books.
    > This gives them a base to start from when they are writing.

    True, but those who want to write do something else. They get together in small "critique groups" at their favorite coffee shop and discuss each other's work. I've never tried this with code, but with a couple of people of comparable but qualitatively different skills, I think it would be an interesting approach.

    1. Re:Form a critique group ... by wrook · · Score: 2

      Coding dojos do something similar.

    2. Re:Form a critique group ... by TheRaven64 · · Score: 1

      True, but those who want to write do something else

      Yes, we post on Slashdot. After being savaged by grammar nazis and had our arguments ripped to shreds, while getting into the habit of writing several thousand words a day with no proof reading, writing a book seems pretty easy in comparison...

      --
      I am TheRaven on Soylent News
    3. Re:Form a critique group ... by phantomfive · · Score: 1

      It truly is amazing how much one's writing can improve on Slashdot.....

      --
      "First they came for the slanderers and i said nothing."
  60. You don't need reviews. by bored · · Score: 2

    You just need to maintain/extend the same piece of code for 10+ years. That means calls at 3AM when it doesn't work. It also means having assorted 3rd parties come in and extend pieces of functionality on a regular basis and then leave.

    That will teach you more about code maintainability and stability than letting a bunch of self righteous, clever idiots, "review" your code.

    Of course, in the meantime... stick to the basics, clarity, consistency, and simplicity. Also, read a lot of other peoples code, you will discover what you like about their code, as well as what you dislike. Then don't write code like the stuff you find hard to understand. One of the big problems with software is that the KISS principle should reign supreme, but everyone thinks they are the next Mozart, and Einstein rolled into one. Rather than building the next Eiffel tower they end up creating the next Rube Goldberg contraption.

    1. Re:You don't need reviews. by Anonymous Coward · · Score: 0

      No offense, but you didn't start writing 10+ year maintainable code in/fresh out of school. Your rather smug comment makes you come off as out of touch.

    2. Re:You don't need reviews. by Anonymous Coward · · Score: 0

      holy mixed metaphors, batman

  61. Less is more by Anonymous Coward · · Score: 0

    One of the best guiding principles I use (been writing code for over 15 years) is to think of the code like a Japanese haiku...less is more. Experienced programmers, especially ones who've had to work on big projects through several iterations and revisions, know that the more code you write, the more you have to maintain. This means making the lines code you have to write really count. Be succinct, avoid repetition, and have the code get to the point of what is trying to do. Use modular practices not only for re-use but to make clear the intent of the code. Above all else, remember that complex problems do not require equally complex code. There is a real art, almost Zen like, in rendering complex problem into understandable code. Computers never get confused but programmers can, so it is vital that you maintain intellectual control over what you are building.

  62. Some questions to ask yourself by Yogs · · Score: 1

    Is the problem broken down into high level pieces you can quickly describe?

    Is what any given snippet of code does and why easily understandable little to no searching?

    Are there tests in place to validate the program's behavior?

    Are there clear boundary lines that prevent erroneous input, error appropriately and minimize corner cases you have to manage?

    Are all side effects cleanly sandboxed and limited to what is necessary to solve the problem?

    Has repetition been avoided?

    Have standard approaches and standard libraries been used whenever possible?

    At the end of the day, is this something you feel good about having done and good about someone else inheriting?

  63. My criteria... by rthille · · Score: 1

    My criteria for software:
    Is it correct?
    Is it performant (enough)?
    Was it produced in a timely manner?
    Can you or someone else go back in 6-12 months and understand it well enough to extend/fix it?

    --
    Awesome furniture, accessories and cabinetry in Santa Rosa, CA: http://humanity-home.com/
  64. Dont comment. by Anonymous Coward · · Score: 0

    The best way to improve your code is to not allow yourself to write comments.

  65. Program more by holophrastic · · Score: 1

    Programming is little more than staring at the computer and telling it that it's not good enough. If you can tell the machine, you can tell yourself. Just don't stop. It's all really easy, just keep going.

  66. Ask Your Professors by Anonymous Coward · · Score: 0

    Your CS professors are there for more than school-related work. If you bring them a project that you've been working on they'll be thrilled to offer you critique on every aspect of the project. You may want to take your work to several different professors to get different opinions, too.

    They're a good resource and they can mentor you in more than writing yet another sorting algorithm.

  67. Been there, Done That by jfz · · Score: 0

    As a self taught guy, people won't code review for free. People may use it, but they won't review it. The only time that people will review your code is if a bug through use is found, or they are trying to learn from it. After having my work taken and used over the years, I just tend to follow the silence is golden rule. And FYI, professors (at-least at my public state university) aren't there to do code review, and the TA graders are often underpaid and under qualified. They are there to check a box to make sure you did the assignment/project. Joining an OSS effort can be an inadvertent source of code review, but this often comes in the form of competing designs and if you're lucky, actual patches to your code. As an example, If my code was understood to the point that someone was able to write a patch, I would consider this an affirmative plus.

  68. What I do by The+Dancing+Panda · · Score: 1

    I've been a professional for a few years now, so I work with other people and we work in the same code framework. Code reviews with others are okay, but I think your best critic will be yourself. Go over your old stuff that you don't remember well, and ask yourself "Does this suck?". It probably does. Fix it.

    A programmer is never happy and never considers anything a finished product. Everything can be improved. Also, go to The Daily WTF and make sure you don't do those things.

  69. jm223 by roman_mir · · Score: 1

    Looked up jm223, because combined with the fact it was the first comment by him, it seemed to be a strange nick, a type of a nick that is used by many local trolls, when they are banned, they take the same base nick and add some numbers to it. However there is no 'jm220' , there is no 'jm100' but there is this character, just jm UID 18663, and based on his ID and a few comments it didn't seem like he is a student in search of a better form.

    So it seems it could be a legitimate question.

    The answer is to work with people who are better than you and learn from them, you need to observe them work or at the minimum you need to look at their products and learn by reading, this is the only true answer.

    The best option is of-course to learn by working with somebody like that and learn by doing while working with them.

  70. Join Google by Anonymous Coward · · Score: 0

    You'll then realize how foolish your desire to have your code reviewed really was. Hint: at Google, a punctuation mistake in a comment is a valid reason to reject a changelist.

  71. Re:Don't listen by tempest69 · · Score: 1

    Bioinformatics software is horrible. I've written way too many data format converters/massagers for software that doesn't like to comply with standards. My adviser has changed up the specs on the software -which I've been coding over that last two years- to now ignore the data format standards in order to add a minor function.

    Somehow my adviser doesn't understand why changing the specs to a non-standard data format would be upsetting

  72. stackoverflow by pamar · · Score: 1

    Have you tried posting this same question on stackoverflow.com?

  73. Comments mean your code is BAD by locopuyo · · Score: 1

    For some reason people on slashdot are super anti anyone that says comments are bad. Even though comments are bad. They add extra junk to sift through and should be completely redundant if you are naming things properly. If you need a comment your functions and variables are not named well enough and don't explain what the code is doing. When your code isn't named well enough and you have comments when you do go to refactor or change things you have to change both the name of the function or variable and the comment, but you only change one and the code and comments become confusing. If you don't understand this through years of programming experience you can always read books. "Clean Code" by Robert C. Martin explains it quite well.

    1. Re:Comments mean your code is BAD by Lord_Naikon · · Score: 1

      IMHO depending on algorithm complexity comments should be used to explain WHY code is structured in a certain way, so that the next guy who refactors the code doesn't break all kinds of invariants or opens up new race conditions.

    2. Re:Comments mean your code is BAD by TheRaven64 · · Score: 3, Insightful

      For some reason people on slashdot are super anti anyone that says comments are bad

      We are, because it's a stupid opinion to hold. Comments are not bad. Redundant comments are bad. There is a really good, simple, way of judging the quality of a codebase: Picking a random function, how much more code do I need to read before I understand what this function is doing and why it's working that way? Clearly named functions and variables go a long way towards explaining what the code is doing, but not necessarily why. Doc comments mean that you don't need to read any of the other functions that are called, just their documentation.

      Comments are also invaluable when the code is buggy. They tell you what the author of the code was thinking and therefore what they intended to write, which makes fixing the code much easier.

      I've had to maintain code written by people who think comments are bad. In general, I would consider removing their keyboards a good way of improving overall code quality.

      --
      I am TheRaven on Soylent News
    3. Re:Comments mean your code is BAD by Anonymous Coward · · Score: 0

      Even though comments are bad. They add extra junk to sift through and should be completely redundant if you are naming things properly.

      People who hold this opinion generally don't understand what comments are for. If you've only seen bad comments, you will naturally think all comments are bad.

    4. Re:Comments mean your code is BAD by locopuyo · · Score: 1

      I have yet to see one example of code with algorithms so complex that can't be named well enough to make comments redundant. I challenge you to give an example because I can guarantee the code is just poorly written.

    5. Re:Comments mean your code is BAD by UnknownSoldier · · Score: 1

      It is obvious you've never spent much time writing nor reading heavily optimized code, such as loop unrolling, removing branching, NOR fixing bugs. WRT the later a proper bugfix will contain a comment to the bugzilla number AND make a note about other potential issues / work arounds, test cases, edge cases, design flaws, etc.

      Sometimes you also deal with code because the original programmer couldn't spend the time to properly name things (either function and/or variables), and only provides a few comments (if you are lucky.)

      Without using the function names would you be able to
      a) Describe how these work without googling them?
      b) Rename the variables to more descriptive ones?

      i.e.

      int popcount (unsigned int n)
      {
          n = (n & 0x55555555) + ((n >> 1) & 0x55555555);
          n = (n & 0x33333333) + ((n >> 2) & 0x33333333);
          n = (n & 0x0F0F0F0F) + ((n >> 4) & 0x0F0F0F0F);
          n = (n & 0x00FF00FF) + ((n >> 8) & 0x00FF00FF);
          n = (n & 0x0000FFFF) + (n >> 16);
          return n;

      or


      float rsqrtf( float x)
      {
          float xhalf = 0.5f*x;
          int i = *(int*)
          i = 0x5F375A86 - (i>>1);
          x = *(float*)
          x = x*(1.5f-xhalf*x*x);
          return x;
      }

    6. Re:Comments mean your code is BAD by trewornan · · Score: 1
      int i = *(int*)

      I don't understand this can you explain?

    7. Re:Comments mean your code is BAD by Lord_Naikon · · Score: 1

      Slashdot ate his code. It's supposed to reinterpret_cast x as an integer. Same goes for the second cast, where it should reinterpret_cast i as a float. See http://betterexplained.com/articles/understanding-quakes-fast-inverse-square-root/ for an explanation.

    8. Re:Comments mean your code is BAD by Lord_Naikon · · Score: 1

      Challenge accepted ;-)
      I would like to show you some complex asynchronous and multithreaded I/O code I've written for $job but that wouldn't fit in a slashdot comment so here's another example.
      This is an excerpt from some code I wrote a while ago for a friendly competition about calculating the number of primes below 1000000000. It is highly optimized.

      static void countPrimes(block *b, uint8_t data[BLOCK_SIZE_HALF]) {
        const prime_t start = b->start;
        const prime_t end = b->end;
        const prime_t max = (int)ceil(sqrt(end));
        const prime_t bsize_half = (end - start) >> 1;

        for(int i = 0; primeDivisors[i] <= max; i++) {
          const prime_t prime = primeDivisors[i];

          prime_t multiple = ((start + prime - 1) / prime) | 1;
          if(multiple < 3) {
            multiple = 3;
          }

          prime_t index = (multiple * prime - start) >> 1;
          while(index < bsize_half) {
            data[index] = 0;
            index += prime;
          }
        }

        int count = 0;
        for(prime_t i = 0; i < bsize_half; i++) {
          count += data[i];
          data[i] = 1;
        }
        b->count = count;
      }

      The actual code has documented in comments:
      - preconditions: data should be initialized to all 1s, primeDivisors should contain all primes up to ceil(sqrt(b->end)), except the prime 2, etc.
      - postconditions: data will contain all 1s, b->count the number of primes.
      - why data is a parameter and not allocated on the stack/heap
      - what the meaning of multiple and index is and how they are calculated
      - how the inner loop works.
      - why the function works in the exceptional case of b->start = 0 and why that even is an exceptional case.

      This code is optimal (it won the competition). It has comments so that when I read this code in say 6 months time I can still understand it.

    9. Re:Comments mean your code is BAD by trewornan · · Score: 1

      Wow that's CRAZEEEEE!!!"

    10. Re:Comments mean your code is BAD by UnknownSoldier · · Score: 1

      Whoops, look like I didn't properly format my html code.

      Should be:

      int i = *(int*) & x;

      and

      x = *(float*) & i;

      Thus, the proper code should be:

      float rsqrtf( float x)
      {
              float xhalf = 0.5f*x;
              int i = *(int*) & x;
              i = 0x5F375A86 - (i >> 1);
              x = *(float*) & i;
              x = x*(1.5f - xhalf*x*x);
              return x;
      }

    11. Re:Comments mean your code is BAD by Tassach · · Score: 1

      It has comments so that when I read this code in say 6 months time I can still understand it.

      Exactly - comments are messages to Future You.

      How many times have you looked at your old code and said "WTF was I thinking when I wrote this?" Comments are there so you can answer that question. You may have done something dodgy or non-intuitive because you didn't know any better at the time, but on the other hand you may have done it for a very good reason.

      I often write comments BEFORE I write the code, especially for smaller projects - the comments are the design document.

      --
      Why is it that the proponents of "one nation under God" are so eager to get rid of "liberty and justice for all"?
  74. Re:Don't listen by sjames · · Score: 1

    That problem is throughout academic software. The problem is that most of it is written by domain experts who had a few quarters of programming (often in fortran). They get the job done more or less, but naturally have no idea of good practices, maintainability, and such. Alas, going the other way around would also be problematic since you'd get an excellent programmer who will need a year or two to understand the problem. That could be an interesting specialization for a contract programmer except that academic software is written by grad students, not contracted professionals.

  75. TDD by Anonymous Coward · · Score: 0

    Test Driven Development will help you a lot on getting better abstractions, structures, etc. when developing software. Now you need a good understanding of unit testing.
    Also, there are many tools which should help you on doing QA on your code. This tools allow you to configure different 'features' your code should follow for it to be valid.
    Code review is a pain.

  76. Simple.. by Anonymous Coward · · Score: 0

    Go back and look at your code after several months, when it isn't fresh in your mind. Does the code look good? Is it easy to read? Is the complexity level low? Are the method/function names appropriate? Are comments needed to point out any information that may not be apparent?

    But don't just do rework without a good reason and following proper processes to make changes. Fixing unbroken code on your spare time because you don't like it will interject problems you don't need. And finally, don't rewrite other peoples work because you don't like it. Review it with them and discuss it but rewriting other peoples work based on your opinion will make enemies and even worse.

  77. A few suggestions with TDD at the top of the list by Anonymous Coward · · Score: 0

    At the very least, write your tests before you write your code. You'll be amazed by how much better the development experience can be.

    Read lots of other people's code (look for the good and the bad, you'll see lots of the latter and can learn to avoid it).

    Code in several languages. Java isn't enough to make someone a real programmer. Learn to script bash, ruby and python. Learn C. Learn one of the functional programming languages (Erlang, Haskell, Clojure) to see how differently some problems can be approached. Learn C.

    Don't be afraid of the command line, too many professional programmers I work with are novices when it comes to doing things on the command line.

  78. If it works,is scalable,and not overly complicated by Anonymous Coward · · Score: 0

    Beware of those who have objects comming out of their ears and love to overly complicate the most simple process.

  79. One thing missing by Rambo+Tribble · · Score: 1

    While I agree with many of the preceding comments, particularly the ones regarding documenting your code, one thing I would add: Always take the time go back to your code and ask yourself how you could make it more compact and more efficient, both in execution and resource demands. As you realize new efficiencies, they will inform and optimize your thinking process.

  80. I've give my pat advice by NotSoHeavyD3 · · Score: 2

    Mostly because this is something basic you can do for yourself. Can you come back to your old code 6 months later figure out what it does without completely reverse engineering it? I've pointed this out before but I'll say it again. You probably threw away your code 5 seconds after it was graded, right? Well the first thing you'll learn if you go on to be a professional is that you or someone else will be coming back to that code to do fixes and add new features. Ok, it's one of my serious pet peeves is that programmers, codes, software engineers, or whatever you want to call them not writing code to be in any respects readable. So you come back to the code and you can't figure it out without wasting days completely reverse engineering it. (Which is frustrating as hell.) If you can learn to write readable code(so that you can come back some time afterwards and quickly pickup where you left off) you'll be way ahead of the game.(IE you'd be a better developer than most pro's. At least that's been my experience.)

    --
    Did you know 80 to 90% of the moderators on slashdot wouldn't recognize a troll even if one dragged them under a bridge.
  81. Trolling by Ambitwistor · · Score: 1

    Post your code and brag about how it's superior to everything else out there. This will enrage all the "someone is WRONG on the Internet" types and you'll get tons of feedback about your code's flaws.

    This was also an effective strategy to get the attention of experts on Usenet groups.

  82. Design Pattern and The Art of Programming by Anonymous Coward · · Score: 0

    The quality of programming has two major aspects. First, there are objective metrics which can be used to determine the quality of code. In the Java domain you might use Checkstyle to determine if your code complies to certain accepted standards. There are other tools which support style checking. They work on lines of code, length of lines and identifiers, number and style of methods and classes. Advanced tools also try to identify design patterns. If they were not covered in your studies you might look them up in your library or if you cannot find any book on that topic in your library use [http://en.wikipedia.org/wiki/Software_design_pattern] as a starting point.

    Second, there is also an esthetic aspect in good programming. This aspect is merely subjective. However, certain properties as symmetry can also be measured. but it is more important to know them, then to be able to measure them. but there is more to esthetics than measurable qualities. Some people like functional programming. It has its advantages and together with object-oriented programming it can be very useful. However, other people think more in procedures, they most likely prefer imperative programming. Mixing both styles can cause unreadable code. As functional programming avoids states, imperative programming enforces states. While the imperative programming makes intensive use of side effects. Functional does not. So mixing is bad style. However, there might be situation where this is not avoidable or even the best solution.

    There two aspects occur on every level of software development. There are elegant algorithms, which are esthetically pleasing and efficient. On the other end there are application designs or even deployment models which look well-formed and conceptually sound. to every level, there exists extensive literature and to become a good software designer and programmer you might consider learning all accepted patterns and style guide will improve your skills. Everything beyond that is subjective and only and opinion. Just like: is a Van Gogh better then a Da Vinci?

  83. Re:Don't listen by pclminion · · Score: 0

    A good way to tell if somebody's code looks like line noise is to ask them if they have a Ph.D.

  84. Integration with other code is the trickiest thing by pnadeau · · Score: 1

    Evaluating code today is more complicated than it used to be.

    When I started learning programming in the mid eighties, the OS and system libraries that your program used were documented in a book and didn't change often.

    Even if you didn't own the book, the release cycle of the code your program depended on was stable enough that you could rely on it and it was produced by large companies that generally produced stable/reliable code.

    Nowadays we have google and can find all sorts of useful libraries, the problem is that:

    1. These libraries are of varying quality. So you have to evaluate the quality of the library code.
    2. You often have to integrate the library with your code and with other libraries as well. You have to manage dependencies.
    3. The libraries may change frequently. Meaning that you have to re-evaluate the library and how it integrates with everything more often.

    This whole problem is compounded if you deal with frameworks. A framework is a type of library that typically imposes some level of 'inversion of control' on your code.

    In cases where the framework is mature and solving it's problem well, and is sufficiently extensible, this saves you a lot of work.

    A bad framework though is worse than code you wrote from scratch, because you lack the control to make it do what you want.

    I'd say that the most valuable skill today in programming is to get good at evaluating and integrating with outside frameworks.

    In the area of Java/J2EE web development I find I have to revisit the 'framework' question every 18 months and see if it is really worth upgrading Hibernate/Spring/Spring Security and various other components of my project template.

    Upgrading may allow me to obtain certain benefits and new features but also introduces the possibility of new bugs.

    --

    --
    Can't buy what I want because it's free.

  85. it programming by Anonymous Coward · · Score: 0

    is an oxymoron

  86. Experience the pain... by Anonymous Coward · · Score: 0

    I have found that very effective ways to become a better programmer are:

    1) Maintain other people's code for a couple of years, you will see/learn what are good coding techniques and what aren't, if you pay attention, I guarantee you. Learn to recognize good techniques.

    2) Try modifying/updating/maintaining code you've written, after not having looked at it for a year or more. They see what you think of your coding style, documentation and comments in your own code.

    3) Comment, comment, comment your code. BUT the comments shouldn't be about what the code does, that should be obvious, the comments should explain WHY the code is doing what it's doing. What was tried and didn't work, what worked and why...

    4) Make your code no more complex than it needs to be. This sounds simple, but it's really not that easy to do. There are constant trade-offs to be made when designing/coding/maintaining software. The trade-off between time (amount of code to be written) and its short/long term benefit. In most cases I've encountered, this aspect ultimately determines if a project is successful or not (but only in the commercial world).

  87. Asking questions and lot of the methods mentioned by Anonymous Coward · · Score: 0

    Most of the method mentioned above are quite useful.
    Ask questions. One of the best questions I learned to ask at work was, "What are you working on?". Then following up. How does it work? What are the hard parts? Anything you might not know how to do easily are good things to ask about.
    If you can form a group to do peer review that would be great. Reading others code will help you learn what is hard to read and maintain as well as good habits and good techniques. In a group, the more novice coders learn just as much from reviewing more experience coders as from being reviewed. More experienced coders still learn. I have been impressed to see how rapidly best habits propagate.
    Reading general articles or specific examples are always good. Open source is fine but there are lots of source. blogs or tips on anything you find interesting will help move you forward.
    The question raised in another comment was, "how do writers learn to write". One response is "by writing". Side projects can be great. Tackle somehting that you will want to maintain over time. Write a project from soup to nuts, and defintiely maintaining over time are great learning tools.

  88. do your own analysis by chizor · · Score: 1

    as you work, collect lists of everything you think went wrong in your programs and programming practices (both practical and academic). you will then be prepared to sit down with your notes from the last quarter and identify broader themes. once you can frame issues in common terms - e.g. your web API mangles UTF-8 input, or you find that you are creating new bugs at an unpleasant rate, or your users aren't understanding your documentation well - you can look up how others have addressed these problems. then the action items will become apparent (eliminate operations that assume input is 8859-1, or adopt a unit testing framework, or work with a technical writer to clarify the text).

    --
    ... !
  89. Epic rant is epic by shiftless · · Score: 1

    Come on , mods! This was funny, if for no other reason the perfect use of "caw on"... bravo sir.

    P.S. you're wrong.

  90. Crucible reviews by Anonymous Coward · · Score: 0

    In my organization (disclosure: big bank) we use a marvelous atlassian product, Crucible, for code reviews. It's wonderful. You use a browser to put out your review, choosing the contents from your check-ins into your SCM (Subversion and Git at least, that I know of). You and your colleagues can put comments, replies to comments, replies to replies, etc .. and directly into the source code (something link post-its). You can summarize with general comments as well. Keep track of who reviewed (and who didn't). It's a nice interface that keeps the whole team involved in "owning" the code and gives each individual the opportunity to make his "critiques", suggestions, rants, etc.

  91. Good OO programmers use generics by shiftless · · Score: 1

    Unprofessional people are defensive. A good person will listen and learn when he can.

    FTFY

  92. The flaw in your argument by shiftless · · Score: 1

    And encyclopedias are bad too, because instead of getting quick overview on a subject and going on about my life, I should spend 10x the time and effort reading through all the available literature on a given subject and learn every detail about it, whether I needed all that information or not.

  93. Don't worry about it by syrinx · · Score: 1

    As long as it works, just fire it off and forget about it. If it sucks, that's a maintenance programmer's problem.

    --
    Quidquid latine dictum sit, altum sonatur.
  94. One word - Refactor by tarpitcod · · Score: 1

    Ask yourself - what is 'great' code. If you haven't seen 'great' code then you need to read more code. It exists. You will know it when you see it.

    If you haven't already exposed yourself to languages that embrace re-factoring as a way of life you should. One of the best is Forth. Good Forth is like poetry. Chuck Moore has written several things about software and they are well worth consideration.

    Good code I've read has usually got the following in common:

    - It's correct - It does what it says it does and sounds like it does.
    - It is side effect free.
    - It has been re-factored extensively.
    - It is as short as it can be without making it more difficult to understand or introducing structures which are fragile or do bad things if you don't use the correct magical incantations which may be non-obvious.

    Here's a couple of concrete things you can do with your existing code:

    Imagine you wrote a 1000 line program.

    Ask yourself can this be a 999 line program? When you get to the 999 line program, ask the same question.

    Eventually you will reach a point where you can't reduce the length of the program without making it less clear. At that point ask yourself, can I re-factor it in a larger sense to make it MORE clear while keeping it correct.

    Ask yourself if each method, function, class does what it says it does, and sounds like it should do. Check the program is still correct. Is the program robust? How does the code behave when its inputs are changed. If it's production code that will get hammered on then maybe you should add a comment about the time and size complexity.

    One of the worst places to find bad code is API's. Experienced programmers know it's truely difficult to write a good API for a non-trivial program that stands the test of time. A good API isn't just sticking a bunch of public methods like so many people think it is. Find an API that's stood the test of time. Read up on it. If the programmer has written about the design decisions then read up on them.

    Finally, think critically about what you KNOW and don't KNOW. Learn something new. Don't just skim it, read it and study it till you grok it. It can be something others take for granted say floating point. Read up on floating point arithmetic. Read about its pitfalls. You'd be amazed how many people who say they are good programmers don't understand precision, accuracy or that floating point numbers are imprecise.

  95. Don't be a Programmer by snoopy911 · · Score: 1

    Don't become a Programner, you have too much inteligence. - Programmers' are just translaters. Use you knowledge and skills to define what you need and then get a code monkey to translate it for you

  96. I've been in the biz 25 years and it's the same... by Anonymous Coward · · Score: 0

    I've never had a competent manager that could review my code. Managers, specifically project managers, know jack about code. The only thing they know is schedules and the fact that we're running late (and that it's all your fault and not theirs for underestimating...).

  97. Code Review by Anonymous Coward · · Score: 0

    I spent my first five years in software getting hold of the code of the world's most celebrated programmers (in my own field) and seeing if I could emulate them. That's great but not easy. My feeling these days is that the best thing you is swap code reviews. Get a friendly experienced programmer to code review your work. Return the favour.

    I'd be happy to review your work & give you my thoughts. You may need to do the same back :) Steve ... sfkleach@gmail.com.

  98. follow the 'personal software process" by Rsriram · · Score: 1

    The Personal Software Process (PSP) is a structured software development process that is intended to help software engineers understand and improve their performance, by using a "disciplined, data-driven procedure".

    It sounds a little esoteric for programmers who like to code and not collect any data, but in my experience, it works.

    https://en.wikipedia.org/wiki/Personal_software_process

    --
    O this learning! What a thing it is - William Shakespeare
    1. Re:follow the 'personal software process" by proggoddess · · Score: 1

      I agree with this, wish I had mod points. We used it heavily in my Master's program in software engineering. You can get feedback on your code in 2 ways - 1) functional improvements, such as faster algorithms or more efficient memory usage, or 2) code hygiene improvements, such as meaningful comments, plugging memory leaks. Option 2 is way more useful in the long run - it applies to all code you write, unlike option 1 that may only apply to a particular domain or OS or application. Also good code hygiene helps avoid many of the bugs that the compiler will never catch - timing errors and race conditions, one-off/fencepost errors, and stuff that generally doesn't appear in testing unless you've run your program for 25 days straight and it then mysteriously crashes.

      It is a bit strange, working through the problems in the book because they are so simple, but really the output of the exercises is a checklist of your own personal improvement points.

      --
      --The Programming goddess from Gorflaz
  99. Negative is Positive by ios+and+web+coder · · Score: 2

    I can (and will) speak only for myself

    However, I have the basic philosophy that negative feedback is what improves a product. Kudos feel good, but criticism is what I need to make whatever it is I do, better.

    Feels worse, but the results are what I'm after.

    Takes a lot of humility, and the ability to look past invective and puerile garbage, to unearth the truth.

    Put your stuff out there. There's nothing that geeks like to do more than throw feces at each others' work. Some of that stuff will have merit. Be careful about what you dismiss. Also, be grateful for strokes and positive reinforcement, but also measure that against your own developing sense of aesthetics and style.

    You will rapidly learn that there are dozens of ways to do things right. There's a ton of sacred cows and third rails in the IT world (A sacred cow is a concept that is so "holy," that it cannot be attacked, and a third rail is a concept that is so toxic that it should never be touched).

    Most of these "hard and fast" rules come from singular events, or as a result of abuse by folks that don't know how to use the tools properly.

    Take, for example, C++. There are folks that believe the language is The Manifestation Of All That Is Evil, but I make my living running a C++ shop. I get to hear all the ranting and raving about how I'm contributing to the downfall of civilization, yadda, yadda..

    However, it is a very dangerous tool, in the hands of an idiot. Because lots of idiots have blown their legs off with C++, they declare that it is evil.

    In some ways, they have a point. If you don't know what you're doing, you can make a fearsome mess with C++. If you decide to become a C++ programmer, then, PLEASE listen to all the negative feedback, and keep it in mind. Be careful in the use of things like multiple inheritance. The Design phase is critical. Far more so, for C++ than for languages like Objective-C.

    Know your tools, and put your code out there. Do open source work. Make something that other folks would use. This will result in de facto code review.

    --

    "For every complex problem there is an answer that is clear, simple, and wrong."

    -H. L. Mencken

  100. Read Books, then Criticize by DudeFromMars · · Score: 1

    Code Complete by Steve McConnell
    Refactoring: Improving the Design of Existing Code by Kent Beck, Martin Fowler and Akira Hirasawa

    Get a colleague to read books and then criticize each other's code.
    It gets amazing results.

    I had the same problem, no senior level programmers to teach the craft. We had once per week lunch meetings and had one programmer show his work, and the others criticize. Our code became much clearer and our bug counts went way down.
    Good Luck!

  101. Test Driven Design by TheSkepticalOptimist · · Score: 1

    Now is a good time to start good habits rather then developing bad coding habits.

    Read up on test driven design.

    The biggest fail of any developer is in thinking they should write more code then is required to solve a purpose. Many developers love to create grandiose architectures in order to solve simple problems, and every line of code you write (whether it is impeccable or absolute garbage) can result in a defect.

    Test driven design changes your mindset from "Hey, lets dump a bunch of code into an application and eventually it will work." to "What are the requirements of this application".

    You design unit tests according to the requirements of the application (and it forces you to identify exactly what the application should achieve). You design the unit tests to fail at first and then you write your code to make them pass successfully. By doing this you only write "enough" code to match the requirements of the application because you are only focused on making the unit tests pass. This avoids over-architecting and because your code is unit tested, adding new code in the future will ensure it is always self-reviewed because the tests will fail and you have to fix your code.

    This is a hard concept to understand at first (and most developers will always baulk at the idea), but a very useful coding practice when you get the hang of it.

    In the end, its not about reviewing lines of code and confirming that, yes, this is good code. Its about writing good applications that do what they are supposed to do with a minimum (or no) defects. This is a fundamental flaw of most code developers in assuming they have to write gobs of code and expect to be patted on the back because it looks nice or conforms to some coding standard; I have seen some beautifully written code that is full of defects, as well as have seen some of the worst looking code ever execute flawlessly.

    Peer review does not prevent defects. Mostly what happens in a peer review is a bunch of nit-picking and a false sense of security when someone "more senior" signs off on a a code review. They want you to follow their coding "standards", make your code look like theirs. Bottom line is, if you write unit tests first and those unit test pass, then there is nothing a code reviewer can say negative about your code except to nit-pick, because the code simply "works", meets the expectations of the software requirements, and is protected from future defects because it is tested.

    Test driven design is the only way I can see an individual developer writing good applications without having a mentor, it focuses on writing code that works, not about style or design.

    --
    I haven't thought of anything clever to put here, but then again most of you haven't either.