Chapter 5 Design Principles II Flexibility Reusability and
Chapter 5 Design Principles II: Flexibility, Reusability, and Eficiency
Requirements Analysis Process Phase Affected by This Chapter Design Framework. Architecture. Detailed Design Implementation Adapted from Software Design: From Programming to Architecture by Eric J. Braude (Wiley 2003), with permission.
Aspects of Flexibility Anticipate … 1. … adding more of the same kind of functionality Example (banking application): handle more kinds of accounts without having to change the existing design or code q … adding different functionality Example: add withdraw function to existing deposit functionality o … changing functionality Adapted from Software Design: From Programming to Architecture by Eric J. Braude (Wiley 2003), with permission.
Registering Website Members Web. Site register() members 0. . n Member Adapted from Software Design: From Programming to Architecture by Eric J. Braude (Wiley 2003), with permission.
Registering Website Members Flexibly Web. Site members YMember XMember 0. . n Member Standard. Member Adapted from Software Design: From Programming to Architecture by Eric J. Braude (Wiley 2003), with permission.
Adding Functionality to an Application: Alternative Situations Within the scope of … 1. … a list of related functions Example: add print to an air travel itinerary functions 2. . an existing base class Example: add “print road- and ship- to air itinerary ” 3. . neither Example: add “print itineraries for Adapted from Software Design: From Programming to Architecture by Eric J. Braude (Wiley 2003), with permission.
Adding Functionality When a Base Class Exists Some. Application. Class Method(s) call print. Itinerary() Trip print. Itinerary() Standard. Trip print. Itinerary() Adapted from Software Design: From Programming to Architecture by Eric J. Braude (Wiley 2003), with permission.
Adding Functionality Through a Base Class Trip print. Itinerary() Some. Application. Class Standard. Trip print. Itinerary() Land. Trip print. Itinerary() Sea. Trip print. Itinerary() Adapted from Software Design: From Programming to Architecture by Eric J. Braude (Wiley 2003), with permission.
Additional Type of Flexibiliy Flexibility Aspect: ability to … Described in … … create objects in variable configurations determined at runtime “Creational” design patterns – chapter xx … create variable trees of objects or other structures at runtime “Structural” design patterns – chapter xx … change, recombine, or otherwise capture the mutual behavior of a set of objects … create and store a possibly complex object of a class. “Behavioral” design patterns – chapter xx Component technology – chapter xx … configure objects of Adapted from Software Design: From Programming to Architecture by Eric J. Braude (Wiley 2003), with permission.
Key Concept: Flexibility We design flexibly, introducing parts, because change and reuse are likely. Adapted from Software Design: From Programming to Architecture by Eric J. Braude (Wiley 2003), with permission.
Making a Method Re-usable q Specify completely o Preconditions etc (see figure xx) q Avoid unnecessary coupling with the enclosing class o Make static if feasible o Include parameterization o i. e. , make the method functional o But limit the number of parameters q Make the names expressive o Understandability promotes re-usability q Explain the algorithm o Re-users need to. Software know how the algorithm works Adapted from Design: From Programming to Architecture by Eric J. Braude (Wiley 2003), with permission.
Making a Class Re-usable q Describe q Make the class completely the class name and functionality match a real world alternatives concept o See section xx q Define a useful abstraction o attain broad applicability q Reduce classes dependencies on other Adapted from Software Design: From Programming to Architecture by Eric J. Braude (Wiley 2003), with permission.
Reducing Dependency Among Classes Replace … Customer Piano with … Customer Piano. Order Piano Adapted from Software Design: From Programming to Architecture by Eric J. Braude (Wiley 2003), with permission.
Leveraging Inheritance, Aggregation and Dependency for the Re-use of Class Combinations Customer compute. Bill() (1) Leveraging inheritance Customer compute. Bill() (2) Leveraging aggregation Regular. Customer compute. Bill() (3) Leveraging dependency Customer compute. Bill( Orders ) Bill compute() Orders value() Adapted from Software Design: From Programming to Architecture by Eric J. Braude (Wiley 2003), with permission.
Basic Approaches to Time Efficiency q Design for Other Criteria, Then Consider Efficiency o Design for flexibility, reusability , … o At some point, identify inefficient places o Make targeted changes to improve efficiency q Design for Efficiency From the Start o Identify key efficiency requirements up front o Design for these requirements during all phases q Combine These Two Approaches o Make trade-offs for efficiency requirements Adapted from Software Design: From Programming to Architecture by Eric J. Braude (Wiley 2003), with permission.
Space-Time Trade-offs Time to process one item Typical target Space Adapted from Software Design: From Programming to Architecture by Eric J. Braude (Wiley 2003), with permission.
Space-Time-Development Trade-offs Convenience of Development unacceptable values Limiting acceptable value Space better than acceptable values Time Adapted from Software Design: From Programming to Architecture by Eric J. Braude (Wiley 2003), with permission.
Impediments to Speed Efficiency o Loops o while, for, do o Remote operations o Requiring a network o LAN o The Internet o Function calls o -- if the function called results in the above o Object creation Adapted from Software Design: From Programming to Architecture by Eric J. Braude (Wiley 2003), with permission.
Volume retrieved at each access Trade-off Between Number of Remote Calls and Volume Retrieved at Each Call Typical target Number of remote Adapted from Software Design: From Programming to Architecture by Eric J. Braude (Wiley 2003), with permission.
Storage Locations Runtime RAM Code base Disk storage required at runtime Disk storage required between runtimes Adapted from Software Design: From Programming to Architecture by Eric J. Braude (Wiley 2003), with permission.
Attaining Storage Efficiency q Store only the data needed o Trades off storage efficiency vs. time to extract and reintegrate q Compress the data o Trades off storage efficiency vs. time to compress and decompress q Store in order of relative frequency Adapted from Software Design: From Programming to Architecture by Eric J. Braude (Wiley 2003), with permission.
Trading off Robustness, Flexibility, Efficiency and Reusability 1 A. Extreme Programming - or - Approach Design for sufficiency only 1 B. Flexibility-driven Approach Design for extensive future requirements Reuse usually a by-product 2. Ensure robustness 3. Provide enough efficiency Adapted from Software Design: From Programming to Architecture by Eric J. Braude (Wiley 2003), with permission.
Extreme vs. + Job done faster (usually) + Scope clear + More likely to be efficient non-Extreme + Future applications more likely to use parts + Accommodates changes in requirements --------------- Future applications less likely to use the work - Refactoring for --------------- Scope less clear - Potential to waste effort Adapted from Software Design: From Programming to Architecture by Eric J. Braude (Wiley 2003), with permission.
More Flexible Design for Calculator Application New Design Existing Design Command. Line. Calculator main() execute. Additions() solicit. Number. Accounts() get. An. Input. From. User() interact. With. User() Calculator solicit. Num. Accounts() Calc. Display display() Calc. Operation execute() Add Multiply Divide Adapted from Software Design: From Programming to Architecture by Eric J. Braude (Wiley 2003), with permission.
Summary of This Chapter q Flexibility o == readily changeable q Reusability o in other applications q Efficiency o in time o in space (These add to Correctness & Robustness, covered in Adapted from Software Design: From Programming to Architecture by Eric J. Braude (Wiley 2003), with permission.
- Slides: 25