Hacker News new | ask | show | jobs
by edw519 5523 days ago
Oh, what the heck, here are mine...

1. Start with the answer, then work back.

2. It worked. You changed something. It doesn't work. It's probably something you did.

3. The answer is always "yes". Sometimes, "yes, but", but always "yes".

4. Never write the same line of code twice.

5. All names (variables, functions, routines, etc.) should accurately describe what they represent as closely as possible. i.e. an intelligent user should be able to read your code and get a fairly good idea what it does.

6. No variable name should be fully self-contained within another variable name.

7. Indent however many spaces you want and use white space however you want. Who gives a shit.

8. Shop standards only count if they are published.

9. Only enter your IDE if you have actually have something to code. Otherwise go back to your pencil/paper/whiteboard (or whatever you use for analysis and design) and don't come back until you're ready.

10. Prototype something and let the user rip it to shreds. Funny how much less bashful they become when they have something to critique. It's much easier to criticize something that exists than to imagine something that doesn't.

2 comments

These are wonderful, thank you. What is your rationale for item 6?

  for(a=0;a<aa;a++){
   if(bbb[a]<bbbb[aa]){
    bbb[aa]=bbbb[aaa]
   }else{
    bbbb[aaa]=bbb[aa]
   }
  }
  
I'll be out of jail in 30 days.

The original programmer will be fine once the stitches are removed.

Actually, all kidding aside, yesterday I enhanced a 1700 line program with these variables:

  Cust
  CustCmmts
  CustComments
  DelCmmts
  CustNbr
  DelDate
  Cmmts
  CustID
  Comments
  CustDel
  Del
The variables "Cust", "Cmmts", "Comments", and "Del" should have different names. What are they? I spent half a day just trying to figure out what everything was, one line at a time. You can't globally locate, edit, cut, paste, or change without fucking up everything else. (And please don't ask me to use a fancier IDE. Just name your variables so the next guy doesn't have to suffer.)
Just structure your data so the next guy doesn't have to suffer.

Cust.Name

Cust.Cmmt (commit?)

Cust.Comments

Cust.Number

etc.

Meh, just downvoted accidentally on the iPhone.