Code bloat

Uses your system voice; voice and rate in settings.

Snapshot

≈ 2 min read

Names in other languages

No names in other languages are held for this entry yet.

Article bodies are English and are not machine-translated. A name in another language is not a translation of the article.

In computer programming, code bloat is the production of executable code (source code or machine code) that is unnecessarily long, slow, or otherwise wasteful of resources. Code bloat can be caused by inadequacies in the programming language in which the code is written, the compiler used to compile it, or the programmer writing it. Thus, while code bloat generally refers to source code size (as produced by the programmer), it can be used to refer instead to the generated code size or even the binary file size.

In computer programming, code bloat is the production of executable code (source code or machine code) that is unnecessarily long, slow, or otherwise wasteful of resources. Code bloat can be caused by inadequacies in the programming language in which the code is written, the compiler used to compile it, or the programmer writing it. Thus, while code bloat generally refers to source code size (as produced by the programmer), it can be used to refer instead to the generated code size or even the binary file size. ==Examples== The following algorithm is written in JavaScript, and can generate an HTML tag based on user input. It contains a large number of redundant code: unnecessary logic and variables, and inefficient string concatenation. // Complex function TK2getImageHTML(size, zoom, sensor, markers) { const strHTMLStart = ' '; var strFinalImage = ""; var strURL = "https://example.com/staticmap?center="; var strSize = '&size='+ size; var strZoom = '&zoom='+ zoom; var strSensor = '&sensor='+ sensor; strURL += markers[0].latitude; strURL += ","; strURL += markers[0].longitude; strURL += strSize; strURL += strZoom; strURL += strSensor; for (var i = 0; i The same algorithm above can be rewritten to be less redundant and more efficient as follows (although not as readable): // Simplified function TK2getImageHTML(sz, zm, sens, mks){ let url="" mks.forEach(mk => url += mk.addMarker()) return ` ` }

Text derived from https://en.wikipedia.org/w/index.php?oldid=1342434609 under CC BY-SA 4.0; modifications have been made.