Archive for June, 2013

Wednesday, June 19th, 2013

stock.xchng - Student Handbook 001 (stock photo by SP_AL_UK)Over the years I’ve collected some rules I keep in my head when I am coding. Some I’ve come up with on my own, others I’ve stolen from @jonwagnerdotcom and @jbright, books have provided some, and other I completely forgot where I’ve picked them up. Feel free to use them in your own head while you code.

  1. THINK

    Above all else think about what you are doing. Don’t blindly follow patterns. Make sure what you are doing makes sense. Trust your own brain.

  2. Code different things differently, same things the same.
    Don’t force a DRY pattern on something that is really different, but if the pattern is really the same use the same code for it.
  3. Better is the enemy of done.
    Code as best you can, but don’t be afraid to ship it. Code is a tool to be used. Nobody can use your code if you don’t let them.
  4. Unwritten code has no bugs.
    Don’t write code unless you have to. Nobody is perfect; your code will have unforeseen effects. Determine before hand if the problem really needs code to be solved.
  5. Do not repeat yourself (DRY).
    Make sure your code is neat and separated so it can be reused. Don’t type (or copy/paste) the same code twice. Actually any time you copy/paste code it better be for a good reason.
  6. Don’t be afraid to delete code, it’s in source control.
    (It is in source control right? Seriously it better to use bad source control over no source control). Undeleted code just clogs up the code base. Delete code that isn’t needed and lean on source control for history. Too may times have I see old code hang around because nobody was sure why it was needed in the first place.
  7. It’s just bits and bytes.
    Don’t be afraid to refactor. The raw materials for code are cheap.
  8. Take pride in your work. Don’t be sloppy.
    Coding is a craft. Pay attention to the code you wrote and take some pride in it.
  9. Bugs happen.
    Nobody can plan for the future completely. Bugs will happen and that’s OK. Fix them when they arise.
  10. Have fun.
    Not every task will be fun, but strive to find fun in what you are coding. It will keep you sane and create a better product.