Tech moves fast! Stay ahead of the curve with Techopedia!
Join nearly 200,000 subscribers who receive actionable tech insights from Techopedia.
Cruft is a slang term for useless, redundant, or poorly written code. Cruft includes any code that is not necessary for an application to perform the task it was designed for. It also can be used in the context of code that is so poorly written, that you might as well throw it out and start from scratch.
Cruft isn't necessarily a bug, but rather makes the code harder to read and maintain. A code or piece of software suffering from cruft may be called "crufty" or "cruftier than the previous version".
Consider the following section of code in Java which illustrates the existence of code.
The problem associated with the above code is the redundant usage of String statements. This is a simple example of cruft. More complex forms of redundant code are not easily identified until the testing phase. By that time, a considerable amount of resources and finance of the organization has been wasted due to the processing applied on the extra redundant blocks of code.
The crufty code can include unwanted packages that are not referenced anywhere, unwanted public access methods that are not referred within the same class or a different class.