Programming style is a set of rules or guidelines used when writing the source code for a computer program. Following a particular programming style will help programmers read and understand source code conforming to the style, and help to avoid introducing errors.[1] This activity introduces programming style and will help you apply standard programming style in a program.
Research "_____ style guide", where _____ is your selected programming language. There are typically multiple style guides available for a given language. Which source do you trust? Why?
Select a source you trust and review the style guide. Note the following:[2]
Maximum recommended line length
Line continuation character
Code block structure
Standard indentation
Blank lines
White space
Comments
Variable and function naming conventions
Search for a linter or code beautifier for your selected programming language. Run the tool on a program you have created to test your code formatting.
What are the advantages of having a standard programming style for a given programming language?
What tool can you use to validate your programming style, and when will you use this tool?
Discuss your activity experience with your classmates. What surprised you? What have you learned that you can apply to your own school or work environment?