Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You'll write various modules (parts) when writing a relatively big project. Reusable code in practice means you'll have create libraries that other projects needing that same functionality can use.</p> <p>So, you have to identify modules that can be reused, for that</p> <ol> <li><p>Identify the core competence of each module. For instance, if your project has to compress files, you'll have a module that will handle file compression. Do <strong>NOT</strong> make it do more than <strong>ONE THING</strong>. One thing only.</p></li> <li><p>Write a library (or class) that will handle file compression, without needing anything more than the file to be compressed, the output and the compression format. This will decouple the module from the rest of the project, enabling it to be (re)used in a different setting.</p></li> <li><p>You don't have to get it perfect the first time, when you actually reuse the library you will probably find out flaws in the design (for instance, you didn't make it modular enough to be able to add new compression formats easily) and you can fix them the second time around and improve the reusability of your module. The more you reuse it (and fix the flaws), the easier it'll become to reuse.</p></li> </ol> <p>The most important thing to consider is decoupling, if you write tightly coupled code reusability is the first casualty. </p> <p>Leave all the needed state or context outside the library. Add methods to specify the state to the library.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload