Oxbow code: Difference between revisions

Content deleted Content added
m get wikilink name right
m change source to syntaxhighlight
 
(16 intermediate revisions by 15 users not shown)
Line 1:
In [[computer programming]], '''oxbow code''' refers to fragments of program code that were once needed but which are now never used. Such code is typically formed when a program is modified, either when an item is supercededsuperseded with a newer version but the old version is not removed, or when an item is removed or replaced, but the item's supporting code is not removed.
 
Such code is normally removed unless sufficiently amusing or educational.
Similarly, variables and data structures can be left around after the last code that used them has gone, though these are more commonly called [[unused variables]] or [[unreferenced variable]]s.
 
Similarly, variables and data structures can be left around after the last code that used them has gonebeen removed, though thesethis areis more commonly called [[unused variables|unused]] or [[unreferenced variable]]s.
The term ''oxbow'' is taken by analogy with [[oxbow lake]]s, which form in nature when a river meanders by eroding its margins and depositing the residue on other banks, becoming ever more contorted until the water breaks through from upstream to downstream, "short-circuiting" one loop of the river. Further deposits cut the old loop off from the main flow, leaving behind a horseshoe-shaped lake with its points toward the river.
 
The term is taken by analogy with [[oxbow lake]]s which are formed in nature when
Such code is normally removed as a sanity check that a superceded item is indeed not being used any more.
a bend in a river becomes so pronounced that the water breaks through
from before the bend to after it, making the river straight again.
When the sides of the new course silt up, a curved lake is left,
disconnected from the main stream.
 
== Examples ==
(from
[http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/Global.cpp?rev=1.46&root=gnash&view=markup gnash/server/asobj/Global.cpp 1.46])
<syntaxhighlight lang="Cpp">
static void
as_global_escape(const fn_call& fn)
{
// List of chars we must convert to escape sequences
const string strHexDigits = "0123456789ABCDEF";
string strInput = fn.arg(0).to_string();
URL::encode(strInput);
fn.result->set_string(strInput.c_str());
}
</syntaxhighlight>
In this, "strHexDigits" is oxbow code (or oxbow data).
 
==See also==
* [[Dead code]]
* [[Unreachable code]]
 
<!--Categories-->
[[Category:Source code]]