CodeNPaste: Blog

What's Re-usable Code? How can it be a valuable?

  • Code Value
  • Knowledge management
  • Re-usable code
By Grégoire LEGEARD - May 29th, 2020 - Originally published on Quora

What is re-usable code ?

In our book, a re-usable code is the smallest unit of code performing a function or an action. It can be a single line of code.

It's referred to as code snippet, re-usable script, boilerplate, etc ... As the name suggests, it's usable across several projects and situations.

Essentially, a re-usable code is the expression of a basic idea, while the software is the specific application of the idea (and many others). A re-usable code represents the programming side of the abstraction. Integrating a re-usable code into larger programming modules or software includes some implementations requirement and adjustments to the intended purpose.

Recommendation for code reuse

A sound re-usable snippet has the following attributes:

  • Representing a single idea, function, or actions
  • Separate the abstraction from the specific implementation
  • Testable
  • Easily re-usable in various project
  • Enough comments & explanation

The less time you spend understanding the code, the easier it is to re-use, adjust, and implement, the better is your re-usable snippet.

Keep in mind, you may forget the solution to a problem, but you will always remember you had it and solved it somehow. Hence, our recommendation is to keep track of the knowledge you accumulate and store it in a dedicated place. It will prove useful overtime: you will know where to search and avoid the research time.

How can re-usable code be a valuable asset ?

The CodeNPaste Dev. Team recognizes re-usable code, sometimes also referred to as script or code snippet, as a valuable asset for:

  • Learning
  • Testing
  • Planning
  • Programming
  • Remembering
  • Collaborating