CSC/ECE 517 Fall 2009/wiki2 7 cn: Difference between revisions
No edit summary |
|||
Line 10: | Line 10: | ||
=='''Interfaces'''== | =='''Interfaces'''== | ||
Reuse is not always functional code that needs to be applied in more than one place. It can be obtained through the use of interfaces and generics as well. By using a solid interface design to allow any type of object with a compatible set of methods to be used in a piece of your application, you allow for everything on both sides of that interface to be easily interchangeable. Other type of interface-like methods that promote architectural reuse are generics, tag libraries, and dozens of frameworks out there that allow pieces to be easily decoupled and injected into the application. | Reuse is not always functional code that needs to be applied in more than one place. It can be obtained through the use of interfaces and generics as well. By using a solid interface design to allow any type of object with a compatible set of methods to be used in a piece of your application, you allow for everything on both sides of that interface to be easily interchangeable. Other type of interface-like methods that promote architectural reuse are generics, tag libraries, and dozens of frameworks out there that allow pieces to be easily decoupled and injected into the application. | ||
=='''Advantages of Code Reuse'''== | |||
1. Reusing code saves programming time, which reduces costs. | |||
2. Sharing code can help prevent bugs by reducing the amount of code that needs to be written to perform a task. The shared code can also be tested separately from the end applications. | |||
3. Separating code into common libraries lets programmers specialize in their particular strengths. A security library, for example, can be built by security experts while a user interface which uses the library can let UI experts focus on their tasks. | |||
4. Delegation of tasks into shared modules allows offloading of some functionality onto separate systems. | |||
=References= | =References= |
Revision as of 00:57, 8 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.
Code Reuse - A Brief Overview
Code reuse, also called software reuse, is the use of existing software, or software knowledge, to build new software. Code reuse in software development is something assumed literally through re-using bits of code in more than one place. It is truly achieved through using common libraries and interfaces accessible to both the entire application and to other applications in the domain. Here are some of the features of code reuse.
Reuse is not duplication
Duplicating code is the result of a copy-paste scenario. The moment you have 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 original code & duplicated it in multiple locations, the bug has now been instantiated in more than one place. Reuse is different from duplication. In code reuse the logic or work that a module does in multiple areas of the application can be reused from one place.The code doesn’t have to physically reside in all of those places to get reused.
Interfaces
Reuse is not always functional code that needs to be applied in more than one place. It can be obtained through the use of interfaces and generics as well. By using a solid interface design to allow any type of object with a compatible set of methods to be used in a piece of your application, you allow for everything on both sides of that interface to be easily interchangeable. Other type of interface-like methods that promote architectural reuse are generics, tag libraries, and dozens of frameworks out there that allow pieces to be easily decoupled and injected into the application.
Advantages of Code Reuse
1. Reusing code saves programming time, which reduces costs. 2. Sharing code can help prevent bugs by reducing the amount of code that needs to be written to perform a task. The shared code can also be tested separately from the end applications. 3. Separating code into common libraries lets programmers specialize in their particular strengths. A security library, for example, can be built by security experts while a user interface which uses the library can let UI experts focus on their tasks. 4. Delegation of tasks into shared modules allows offloading of some functionality onto separate systems.
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.