Software bug: Difference between revisions

Content deleted Content added
fix double space
Zewas (talk | contribs)
grammar, style, added links
Line 107:
is syntactically correct, but fails type checking since the right side, a string, cannot be assigned to a float variable. Compilation fails {{endash}} forcing this defect to be fixed before development progress can resume. With an interpreted language, a failure would not occur until later at runtime.
 
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 iscan generallybe very fast, but ismay consideredlead dangerous;to relatively[[memory likelycorruption]] toor cause[[Segmentation afault|segmentation majorfaults]] bug.if not used with great caution.
 
Some languages include features that add runtime overhead in order to prevent somecommon bugs. For example, many languages include runtime [[bounds checking]] and a way to handlerecover from out-of-bounds conditionserrors instead of crashing.
 
=== Techniques ===
 
Programming techniques such as [[programming style|Style guidelines]] and [[defensive programming]] arecan intendedprevent easy-to-miss preventtypographical errors (typos).
 
For example, amost bug[[List_of_C-family_programming_languages|C-family mayprogramming belanguages]] causedallow bythe aomission relativelyof minorbraces typographicalaround erroran (typo)instruction inblock theif code.there's Foronly a single instruction. example,The thisfollowing code executes function {{code|foo}} only if {{code|condition}} is true.:
 
if (condition)
foo();
 
But this code always executes {{code|foo}}:
 
if (condition);
foo();
 
Using braces - even if they're not strictly required - reliably prevents this error:
A convention that tends to prevent this particular issue is to require braces for a block even if it has just one line.
 
if (condition) {
foo();
}
 
Enforcement of conventions may be manual (i.e. via [[code review]]) or via automated tools such as [[Lint_(software)|linters]].
 
=== Specification ===