wissel.net

Usability - Productivity - Business - The web - Singapore & Twins

If you think decomposition is from CSI, stop writing code!


I like coaching developers to write better code, but sometimes it is too much. So here it goes:

If you think decomposition is from CSI, STOP writing code!

So, it is off my chest. Simples rule of thumb:
  • if a function doesn't fit on a printed page, it is too long
  • A function does one thing. If you loop through a document (or record) collection call a function with the individual document as parameter
  • Use objects and inheritance with a factory class instead of monster case structures with copy/paste code duplication
  • Refuctoring was meant as a joke
  • The functions that declare a variable clean it up, not the called functions
  • Global variables are evil unless you have 7 good reasons to have them
When you write your code in JavaScript use JSHint (someone port this to SSJS please), when you write Java, look at Crap4J. Unfortunately there is no free one for LotusScript, but you could use Visustin to visualize your functions - 3m image size would definitely be too long.

Want to improve? Attend a computer science 101 class at a good university and some programming lessons. This is the 21st century, it won't cost you (other than your time): Keep in mind: for every function line you write over 100 lines a kitten must die.
Update: Lydia advised me on broken links with CodeAcademy asking to link to her Phython courses article in return. Thank you Lydia

Posted by on 15 October 2012 | Comments (3) | categories: Software

Comments

  1. posted by Thimo Jansen on Tuesday 16 October 2012 AD:
    Great advice. I learned a lot on this subject by reading "Clean Code" from Robert C. Martin It's hard to follow his advice to the letter and I can't say I'm doing that, but it has made me a better programmer.
  2. posted by Ben Poole on Saturday 27 October 2012 AD:
    Excellent post, lots of resources to pick over. One minor point: Crap4J seems to be a project in the doldrums, no updates for a long time and its plugin doesn't work in any of the recent versions of Eclipse, alas.
  3. posted by Stef Durs on Sunday 14 April 2013 AD:
    Stop warning. NO kitten is going to die. Or children in Africa are going to starve to death.