Repeatable Code - a Step Up From Reusable Code
I think a generally acceptable definition of reusable code could be "code or functionality that will probably be useful in one or more future projects." It's a category of code that few managers or developers, in my experience, seem to pay much attention to until they need it.
This is unfortunate since, in my opinion, reusable code, when upgraded to repeatable code, has the potential to save big on development costs.
What Is Reusable Code?
From what I can gather, there are five primary sources of reusable code.
* Components (objects) that expose their functionality through an interface.
* User controls.
* Repositories that use a database and accept a limited number of languages.
* Web sites where code snippets and sample projects are freely exchanged.
* Other projects.
Components and user controls are great if the reusable code is appropriate for encapsulation. You don't have to be concerned with reusing code, only with reusing functionality. There is, however, a plethora of reusable code that would be very nice to have handy, but, doesn't work in a component or user control. Code repositories address this type of reusable code.
Unfortunately, code repositories tend to be limited. They can usually only be used with a few languages (normally one). In addition, repository programs typically use a database which makes the sharing of stored code less than easy.
While code repositories are typically very intelligent with the language they are designed to store, they are, in my opinion, usually not known for their flexibility when preparing that code for insertion into a new project. The ability to easily adapt reusable code to new situations "on the fly" is essential, in my option, if code is to be truly repeatable.
Exchange sites make reusable code readily available to anyone with access to the Internet. This free exchange of knowledge and specific coding solutions is ideal in concept. The usual implementation, however, has, in my opinion, room for improvement. Retrieving immediately useful code snippets from exchange sites is great when it happens. Unfortunately, code that can be retrieved and plugged directly into the project you are working on is, in my opinion, rare on exchange sites.
Similar to exchange sites, the store of fully or partially completed projects that a developer has worked on provide a gold mine of reusable code. However, this type of reusable code, like gold, must be found and then mined.
The search for, and mining of reusable code in other projects is normally done only by the developer of the project because that person is usually the only one who has any idea what nuggets are to be found. This "one person show" type of reusable code makes this buried code of limited availability to anyone else.
Components and user controls serve well for their intended purpose. I think the main shortcomings in the reusable code arena are with repositories, exchange sites and other projects. Repeatable code addresses the shortcomings of these code sources by taking the entire concept of reusability to a new level.
Repeatable Code Is A Step Up
Repeatable code extends the concept of reusability by incorporating the advantages of speed, simplicity, predictability, portable documentation and ease of sharing. These advantages are realized with a well written repeat text writer.
* Speed. Repeatable code is stored in libraries that are easy to navigate. Source libraries are organized in any way that makes sense to the user. Once a library has been opened in the repeat text writer, the duplication of any source file in that library can be started with one mouse click.
Markers embedded in the source text enable customization of repeated code "on the fly" every time a source file is repeated. Ready-to-compile code can be generated with a very few keystrokes.
* Simplicity. Markers in source files can be set up such that duplication and customization of source files requires little, if any, knowledge of the language in which the source text is written. Repeatable code thus becomes even more valuable by extending the reusability of complex code to entry level developers.
* Predictability. Code stored in repeatable source files remains unchanged even though each new duplicated version of the code can be very different. How much repeatable code can be customized "on the fly" depends on the embedded markers.
Regardless of how much repeated code is changed, as long as the code in the source file is sound, each new duplication of the code can usually be counted on to be ready to compile.
* Portable Documentation. A source library overview feature lets you write any documentation you feel is needed for users of the source files that you create. Users of the library can view this documentation as a reference whenever they are duplicating files by opening the Float Overview window. Each time a library is packaged and sent to someone else, the overview can travel with the code.
In addition to the library overview, there can be a note pad for each source file, plus inline messages within source files. Note pads can be used to keep file specific information that is accessible from the program's main window. Inline messages are embedded in source files and can optionally be displayed whenever encountered during each duplication.
* Ease Of Sharing. Entire libraries (including the overview, source files and note pad files) can be easily packaged and sent to other repeat text writer users.
With built in packaging and unwrapping functions, entire libraries can be packaged into one file with a few mouse clicks. Recipients of library exchange files can unwrap packaged libraries just as quickly. The recipients of packaged source libraries can immediately begin repeating ready to compile code from newly unwrapped libraries.
Conclusion
When I finish writing reusable code that I've never written before, I make an effort to store that reusable code in a repeatable library. Using a repeat text writer has had a profound effect on the way I think about, and do my coding.
I honestly don't think I would enjoy developing software nearly as much if I didn't have a tool for repeating customizable code so easily. Code that I use often, or code that is complex to integrate into new projects is made readily available and simple to use with a repeat text writer.
George Gilbert writes software for personal computers. Titles include myOwn10-Key, myOwnPayday, Person On Call, Trend Importer and Double Text. Find out more about these innovative, award winning programs at 2goodsoftware.com.
Article Source: ArticlesBase.com - Repeatable Code - a Step Up From Reusable Code