Making Friends: Clean Code
A brief guide on loving yourself and
others through better programming
Brendan Bakos
Outline
Writing readable programs
Improving comments
Making friends
Writing Readable Programs
Key Concept
Minimize the time it would take someone else
to understand
Write tidy, consistent code
Choose specific names that describe the value or
purpose of the variable/dataset
Key Concept
Minimize the time it would take someone else
to understand
Write tidy, consistent code
Choose specific names that describe the value or
purpose of the variable/dataset
Key Concept
Minimize the time it would take someone else
to understand
Write tidy, consistent code
Choose specific names that describe the value or
purpose of the variable/dataset
Case Study
Case Study
Case Study
1. Make a statement
Case Study
1. Make a statement
2. Tab
Case Study
1. Make a statement
2. Tab
3. Tab tab tab
Case Study
4. Descriptive variable names
Case Study
4. Descriptive variable names
BE CONSISTENT
General Guidelines
Programs should look neat
General Guidelines
Programs should look neat
Use white space
General Guidelines
Programs should look neat
Use white space
Indents
General Guidelines
Programs should look neat
Use white space
Indents
Match do/end
General Guidelines
Programs should look neat
Use white space
Indents
Match do/end
One statement per line
General Guidelines
Programs should look neat
Use white space
Indents
Match do/end
One statement per line
Consistency
/* Program Comments */
Key Concept
Write comments that help the reader
understand the code more easily
Why
What
How
Comments
Useless comments
Comments that make friends
Headers
Tying it all together
Summary
Make friends by being consistent, using white
space, and using indents
Make friends with insightful comments
/* Thank you */
Boswell D, Foucher T. The Art of Readable Code. "O'Reilly Media, Inc."; 2011.
Lafler KP. Best Practicing Programming Techniques for SAS Users. 2017.
https://support.sas.com/resources/papers/proceedings17/0175-2017.pdf
Winn TJ. Guidelines for Coding of SAS Programs. 2004.
http://www2.sas.com/proceedings/sugi29/258-29.pdf
Martin C, Martin L. Clean-up, Comments and Code Making it Maintainable. 2004.
https://stats.idre.ucla.edu/wp-content/uploads/2016/02/ap2004.pdf