Escolar Documentos
Profissional Documentos
Cultura Documentos
Benefits of reuse
Timeliness
Decreased maintenance effort
Reliability
Efficiency
Consistency
Lower cost
Less redundancy in the work
3
On the face of it, the lack of reuse in software makes little sense, but
there are reasons for it.
Forms of reuse
Binaries
Source code
Design patterns
Specifications
Requirements, Functional, Design
Personnel
6
Composition
Class A uses Class B
Reuse a class by creating an object and calling methods on it
The most common form of code reuse (we do this all the time)
Parameterization
Write a class so its behavior/functionality can be customized to the current
application
Generic Types
E.g., C++ templates, Java and C# generics (e.g., ArrayList<Device>)
Inheritance
To reuse a class,
1) Inherit its functionality
2) Customize superclass behavior by overriding its methods in the subclass
3) Extend superclass functionality by adding new variables/methods in the
subclass
7
Target
+Request()
Adapter
+Request()
Adaptee
+SpecificRequest()
...
adaptee->SpecificRequest();
...
10
Sort(Comparable[])
interface Comparable { int compareTo(Object o); }
11
Sort(Comparable[])
interface Comparable { int compareTo(Object o); }
Sort(Object[], Comparator)
interface Comparator { int compare(Object o1,
Object o2); }
12
Sort(Comparable[])
interface Comparable { int compareTo(Object o); }
Sort(Object[], Comparator)
interface Comparator { int compare(Object o1,
Object o2); }
13
14
16
17
18
19