Main Pagehttp:/pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE 517 Fall 2009/wiki2 7 cn: Difference between revisions

From Expertiza_Wiki
Jump to navigation Jump to search
Line 7: Line 7:


=='''Code Reuse is not Duplication'''==
=='''Code Reuse is not Duplication'''==
Duplicating code is the result of a copy-paste scenario. The second you’ve copy-pasted a module of code to two locations in your application you’ve just created an additional maintenance point. Also if you have coded a bug into the “beautiful” piece you pasted everywhere, now that bug is also in every place you pasted it.'''Reuse is different from duplication.'''In code reuse you can relocate the logic or work that a module does in multiple areas of the application to one place. It doesn’t have to physically reside in all of those places to get reused.
Duplicating code is the result of a copy-paste scenario. The second you’ve copy-pasted a module of code to two locations in your application you’ve just created an additional maintenance point. Also if you have coded a bug into the code that is being duplicated, that bug instantiates itself in every place you pasted it.'''Reuse is different from duplication.'''In code reuse you relocate the logic or work that a module does in multiple areas of the application to one place. The code doesn’t have to physically reside in all of those places to get reused.
 
 


=='''Interfaces'''==
=='''Interfaces'''==

Revision as of 23:16, 7 October 2009

Problem Statement

Different languages have different mechanisms for "code reuse". Assembly and low level languages have macros, C/C++ has includes, Ruby has mixins and modules, Java has packages, and there are many other concepts around reuse and extension. Here is a page that describes the various mechanisms, groups the mechanisms into logical categories, and discusses the advantages and disadvantages of the various schemes, in terms of simplicity, performance, reliability, or other factors.

A Brief Overview of Code Reuse

Code reuse, also called software reuse, is the use of existing software, or software knowledge, to build new software.Code reuse is the idea that a partial or complete computer program written at one time can be, should be, or is being used in another program written at a later time. The reuse of programming code is a common technique which attempts to save time and energy by reducing redundant work.The software library is a good example of code reuse. Programmers may decide to create internal abstractions so that certain parts of their program can be reused, or may create custom libraries for their own use. The following sections elaborate more on code reuse.

Code Reuse is not Duplication

Duplicating code is the result of a copy-paste scenario. The second you’ve copy-pasted a module of code to two locations in your application you’ve just created an additional maintenance point. Also if you have coded a bug into the code that is being duplicated, that bug instantiates itself in every place you pasted it.Reuse is different from duplication.In code reuse you relocate the logic or work that a module does in multiple areas of the application to one place. The code doesn’t have to physically reside in all of those places to get reused.

Interfaces

References

http://www.refactoring.com
Refactoring: Improving the Design of Existing Code by Martin Fowler.


References

http://www.refactoring.com
Refactoring: Improving the Design of Existing Code by Martin Fowler.