Information Technology Reference
In-Depth Information
error prone or troublesome for other reasons; the style guide may ban or discourage those
features.
Many languages have style guides of their own (Python and Puppet). Every major
open source project has a style guide for its community. Most companies have a style
guide for internal use. Google runs many open source projects and has published its
internal style guides (minus redactions) for more than a dozen languages ( ht-
tps://code.google.com/p/google-styleguide/ ). This enables community
members to participate and adhere to the current style. The Google style guides are very
mature and are a good basis for creating your own.
Additional Recommendations
Often special notations are recommended in style guides. For example, the Google style
guide recommends special notation for comments. Use TODO comments for code that is
temporary, a short-term solution, or good enough but not perfect. Use NB comments to ex-
plain a non-obvious decision. Use FIXME comments to point out something that needs to
be fixed and list the bug ID of the issue. The annotation is followed by the username of the
person who wrote the comment. Figure 12.2 shows examples.
Figure 12.2: Special-purpose comments from the Google style guide
Asmentionedin Section9.3.2 , sourcerepositoriescancallprogramstovalidatefilesbe-
foretheyarecommitted.Leveragethese“pre-submittests”tocallstyle-checkingprograms
and stop files with style violations from being committed. For example, run PyLint on
any Python file, puppet-lint on any Puppet files, and even home-grown systems that
pedanticallyreject CHANGELOG entriesiftheirentriesarenotperfectlyformatted.Theres-
ult is consistency enforced consistently no matter how large the team grows.
12.7.5 Test-Driven Development
Test-driven development (TDD) is a software engineering practice that leads to code with
minimal bugs and maximizes confidence.
Search WWH ::




Custom Search