General Code Quality

« Return to the Chapter Index

Table of contents
  1. General Code Quality
    1. Key Idea
    2. Best Practices
    3. Summary
    4. Chapter Summary
  2. Next Step

Key Idea

Programmers should always try to create efficient, readable, and maintainable code. It’s not that hard to do it right.

Best Practices

Good formatting, indenting, and consistency of style are important to maintaining a large code base. Many organizations will dictate these types of things.

  • Indents are 2 or 4 spaces
  • Braces at the end of lines or on a new line
  • Parameters on one line or multiple lines
  • The list goes on. There are best practices, but while many are agreed upon, some are preferences.

Rule number 1: be consistent.

Summary

When coding, remember you are not the only one who will look at your code. Others will be responsible for maintaining, updating, or using the code you produce. Writing well comments, well named, clear and consistent code is critical to success as a software developer.

Chapter Summary

In order to write better programs, we must handle exceptional cases. The exception handling process (try/catch/finally) gives us a mechanism to easily handle these cases.

Code should be readable, maintainable, and understandable. Good comments are critical. Naming of functions, classes, and variables so that their names represent the information they will hold or action they will take is also important.

Next Step

Next we’ll examine testing: Testing »


Back to top

Created by Greg Silber, Austin Cory Bart, James Clause.