HOME

TheInfoList



OR:

Code cleanup refers to the act of writing
code In communications and information processing, code is a system of rules to convert information—such as a letter, word, sound, image, or gesture—into another form, sometimes shortened or secret, for communication through a communication ...
so that it cleans up leftover data structures and other unwanted materials from memory and the filesystem. It is sometimes treated as a synonym of
refactoring In computer programming and software design, code refactoring is the process of restructuring existing computer code—changing the '' factoring''—without changing its external behavior. Refactoring is intended to improve the design, structu ...
code, which involves making the source code itself easier to understand, maintain, and modify.


Examples


C++

In
C++ C, or c, is the third letter in the Latin alphabet, used in the modern English alphabet, the alphabets of other western European languages and others worldwide. Its name in English is ''cee'' (pronounced ), plural ''cees''. History "C" ...
, code cleanup involves deallocating previously allocated
dynamic memory Memory management is a form of resource management applied to computer memory. The essential requirement of memory management is to provide ways to dynamically allocate portions of memory to programs at their request, and free it for reuse when ...
. This is usually done with the C++ delete and delete[] operations. int x = 15; int* mySequence = new int[x]; for (int i = 0; i < x; i++) mySequence = -127; delete[] mySequence;


Python

In Python 3, explicit deletion of variables requires the del
keyword Keyword may refer to: Computing * Keyword (Internet search), a word or phrase typically used by bloggers or online content creator to rank a web page on a particular topic * Index term, a term used as a keyword to documents in an information syst ...
. x = 15 my_sequence = for useless_variable in range(x)my_sequence = -127 del my_sequence


JavaScript

In JavaScript, objects are garbage collected if they are unreachable from the global object. One way to make an object unreachable is to overwrite the variables or properties that reference it. let x = ; // The variable x is declared and set to an object x = null; // x is overwritten and the object becomes unreachable


Java

In Java, variables cannot be truly deleted. The most that can be done is to set the variable to null, which works with any Java object, including arrays. int x = 15; int[] my_sequence = new int[x]; for (int i = 0; i < x; i++) my_sequence = -127; my_sequence = null;


Other meanings

Code cleanup can also refer to the removal of all computer programming from source code, or the act of removing
temporary file A temporary file is a file created to store information temporarily, either for a program's intermediate use or for transfer to a permanent file when complete. It may be created by computer programs for a variety of purposes, such as when a progra ...
s after a program has finished executing. For instance, in a web browser such as
Chrome browser Google Chrome is a cross-platform web browser developed by Google. It was first released in 2008 for Microsoft Windows, built with free software components from Apple WebKit and Mozilla Firefox. Versions were later released for Linux, macOS ...
or Maxthon, code must be written in order to clean up files such as
cookies A cookie is a baked or cooked snack or dessert that is typically small, flat and sweet. It usually contains flour, sugar, egg, and some type of oil, fat, or butter. It may include other ingredients such as raisins, oats, chocolate chips, nuts ...
and storage. The deletion of temporary files is similar to the deletion of unneeded lists and arrays of data. However, a file is treated as a permanent way to store a resizable list of
byte The byte is a unit of digital information that most commonly consists of eight bits. Historically, the byte was the number of bits used to encode a single character of text in a computer and for this reason it is the smallest addressable uni ...
s, and can also be removed from existence.


Loop cleanup

Another technical term sometimes called "code cleanup" is
loop Loop or LOOP may refer to: Brands and enterprises * Loop (mobile), a Bulgarian virtual network operator and co-founder of Loop Live * Loop, clothing, a company founded by Carlos Vasquez in the 1990s and worn by Digable Planets * Loop Mobile, an ...
cleanup. /* 'The i++ part is the cleanup for the for loop.' */ for i = 0; i < 100; i++ print i end import type list = 0, 20, 30, 40, 50/* 'Even in a for each loop, code cleanup with an incremented variable is still needed.' */ i = 0 for each element of list list ^= 2 // 'Squares the element.' print string(element) + " is now... " + string(list i++ end


References

{{Reflist


Other Resources


HTML Code CleanupFormatting and Cleaning Up CodeCode Formatter
Source code