Software bug: Difference between revisions

Content deleted Content added
m unpiped links using script
review: syntax hilighting. add link, clarification.
Line 120:
Some languages exclude features that easily lead to bugs, at the expense of slower performance {{endash}} the principle being that it is usually better to write simpler, slower correct code than complicated, buggy code. For example, the [[Java (programming language)|Java]] does not support [[pointer (computer programming)|pointer]] arithmetic which is generally fast, but is considered dangerous; relatively likely to cause a major bug.
 
Some languages include features that add runtime overhead in order to prevent some bugs. For example, many languages include runtime [[bounds checking]] and a way to handle out-of-bounds conditions instead of crashing.<!--[[User:Kvng/RTH]]-->
 
=== Techniques ===
Line 126:
Programming techniques such as [[programming style]] and [[defensive programming]] are intended to prevent typos.
 
For example, a bug may be caused by a relatively minor, [[typographical error (typo)]] in thesource code. For example, this code executes function {{code|foo}} only if {{code|condition}} is true.
 
<syntaxhighlight lang="c">if (condition) foo();</syntaxhighlight>
 
But this code always executes {{code|foo}}:
 
<syntaxhighlight lang="c">if (condition); foo();</syntaxhighlight>
 
A convention that tends to prevent this particular issue is to require braces for a block even if it has just one line.
 
<syntaxhighlight lang="c">
if (condition) {
foo();
}
</syntaxhighlight>
 
Enforcement of conventions may be manual (i.e. via [[code review]]) or via automated tools.<!--[[User:Kvng/RTH]]-->
 
=== Specification ===