LMU COMPUTER SCIENCE
Coding Guidelines

Writing bad code is like showing up late to a job interview poorly dressed and telling the interviewer that he or she is an idiot. If you don’t care enough about your code to write it well, why in the world should anyone care to read it?

Comments

“Nothing can be quite so helpful as a well-placed comment. ... Nothing can be quite so damaging as an old crufty comment that propagates lies and misinformation.” — Robert C. Martin

Testing

Not writing unit tests is not an option.

Formatting and Naming

Sloppy formatting shows you don’t give a crap about yourself. Perhaps you are just as careless with your personal hygiene or personal finances?

DRY Code

Excessive copy-paste shows you don’t give a crap about yourself.

Efficiency and Security

Sometimes a readability versus performance tradeoff pops up, but quite often the most readable code actually is the most efficient. And sometimes, your code may be prone to efficiency attacks, so watch out.

Compactness

Often, compact code is more readble than drawn-out code.

C Specifics

C is hard, but if you keep some things in mind, you can avoid the common problems.