From Section 7.3.2:
Multiple accesses, by more than one programmer, to a common repository of components.
Handling product families, in which a component may exists in multiple versions.
// version 1
class Library {
Enumeration getTitlesSortedByAuthor(CallNo start, CallNo end);
}
// version 2
class Library {
Title[] getTitlesSortedByAuthor(CallNo start, CallNo end);
}
Discuss the relative benefits and shortcomings
of each approach (if any),
referring to software qualities and principles.
The weakness of version 2 is that it either exposes an internal data structure (the sorted array), or it is inefficient, because an array will have to be constructed. Version 1 shows greater qualities of information hiding and abstraction.
[You had to give techniques alluded to in the article.]
Displays and user interfaces were built first, rather than last.
-- separation of concerns, user-friendliness
The system was split into small segments and the riskiest
ones were done first.
-- anticipation of change, modularity
Off-the-shelf software and large sections from other systems were
used.
-- reusability, modularity
Programmers peer-reviewed one another's designs and code, catching
more that 200 major design errors while they were still easy to fix.
-- understandability, incrementality
The engineers had to perfect each segment before moving on.
-- correctness, verifiability, incrementality
Frequent contact with users.
-- user-friendliness, validity of requirements, possible visibility
Will be updated once a year, rather than replaced once a decade.
-- incrementality, maintainability, anticipation of change
First in a product line of related systems.
-- reusability, anticipation of change, planning for a software
family
Assume that the sumMaxAndMin method is invoked elsewhere in the program with this statement: System.out.println(sumMaxAndMin(i, j, k));, where i, j, and k are integers.
int sumMaxAndMin(int x1, int x2, int x3)
{
boolean med1 = false, med2 = false, med3 = false;
if ( (x2 >= x1 && x1 >= x3) || (x2 <= x1 && x1 <= x3) )
med1 = true;
if ( (x1 >= x2 && x2 >= x3) || (x1 <= x2 && x2 <= x3) )
med1 = true;
if ( (x2 >= x3 && x3 >= x1) || (x2 <= x3 && x3 <= x1) )
med3 = true;
if (med1)
return x2+x3;
if (med2)
return x1+x3;
if (med3)
return x1+x2;
}