CMP EMBEDDED.COM

Login | Register     Welcome Guest  
HOME DESIGN PRODUCTS COLUMNS E-LEARNING CONFERENCES CODE FORUMS/BLOGS NEWSLETTERS CONTACT FEATURES RSS RSS

Bug-killing standards for firmware coding



Embedded.com

Why coding standards?
A coding standard defines a set of rules for programmers to follow in a given language. This makes a coding standard similar in purpose to the English standard known as Strunk & White (The Elements of Style). The original version of this popular book of grammar and other rules for written English was once described as a "forty-three-page summation of the case for cleanliness, accuracy, and brevity in the use of English."

Embedded software is also better when rules for "cleanliness, accuracy, and brevity" are followed. The adoption of a coding standard by a team or a company has many benefits. For example, a coding standard increases the readability and portability of software, so that firmware may be maintained and reused at lower cost. A coding standard also benefits a team of software developers and their entire organization by reducing the time required by individual team members to understand or review the work of peers.

In my view, though, one of the biggest potential benefits of a coding standard has been too long overlooked: a coding standard can help keep bugs out. It's cheaper and easier to prevent a bug from creeping into code than it is to find and kill it after it has entered. Thus a key strategy for keeping the cost of firmware development down is to write code in which the compiler, linker, or a static-analysis tool can keep bugs out automatically--in other words, before the code is allowed to execute.

Of course, there are many sources of bugs in software programs. The original programmer creates some of the bugs, a few lurking in the dark shadows only to emerge months or years later. Additional bugs result from misunderstandings by those who later maintain, extend, port, and/or reuse the code.

The number and severity of bugs introduced by the original programmer can be reduced through disciplined conformance with certain coding practices, such as the placement of constants on the left side of each equivalence (==) test.

The original programmer can also influence the number and severity of bugs introduced by maintenance programmers. For example, appropriate use of portable fixed-width integer types (such as int32_t) ensures that no future port of the code to a new compiler or target processor will encounter an unexpected overflow.

The number and severity of bugs introduced by maintenance programmers can also be reduced through the disciplined use of consistent commenting and stylistic practices, so that everyone in an organization can more easily understand the meaning and proper use of variables, functions, and modules.

1 | 2 | 3 | 4 | 5

Rate this article: Low High
Current rating
  • .
Embedded.com Career Center
Looking for a new job?
SEARCH JOBS

Browse all jobs

SPONSOR
RECENT JOB POSTINGS



TECH PAPER
WEBINAR
WEBINAR
WEBINAR




 :