Internet-based Application Development -- copyright (c) 1998-2001 by Eric J. Braude 7/31/08-- Components -- page C.‹#›Comp 7700 – Design Principles II1Chapter 5Design Principles II:Flexibility, Reusability, and EfficiencyComp 7700 – Design Principles II2Process Phase Affected by This ChapterRequirementsAnalysisDesignImplementationArchitectureFramework Detailed DesignAdapted from Software Design: From Programming to Architecture by Eric J. Braude (Wiley 2003), with permission.Comp 7700 – Design Principles II3Aspects of Flexibility … adding more of the same kind of functionalityExample (banking application): handle more kinds of accountswithout having to change the existing design or code … adding different functionalityExample: add withdraw function to existing deposit functionality• … changing functionalityExample: allow overdraftsAnticipate …Adapted from Software Design: From Programming to Architecture by Eric J. Braude (Wiley 2003), with permission.Comp 7700 – Design Principles II4Registering Website MembersWebSiteregister()Member0..nmembersAdapted from Software Design: From Programming to Architecture by Eric J. Braude (Wiley 2003), with permission.Internet-based Application Development -- copyright (c) 1998-2001 by Eric J. Braude 7/31/08-- Components -- page C.‹#›Comp 7700 – Design Principles II5Registering Website Members FlexiblyWebSite Member0..nStandardMemberXMemberYMembermembersAdapted from Software Design: From Programming to Architecture by Eric J. Braude (Wiley 2003), with permission.Comp 7700 – Design Principles II6Adding Functionality to an Application:Alternative SituationsWithin the scope of … … a list of related functionsExample: add print to an air travel itinerary functions ... an existing base classExample: add “print road- and ship- to air itinerary ” ... neitherExample: add “print itineraries for combinations of air, road andship transportation”Adapted from Software Design: From Programming to Architecture by Eric J. Braude (Wiley 2003), with permission.Comp 7700 – Design Principles II7Adding Functionality When a BaseClass ExistsTripprintItinerary()StandardTripprintItinerary()SomeApplicationClassMethod(s) callprintItinerary()Adapted from Software Design: From Programming to Architecture by Eric J. Braude (Wiley 2003), with permission.Comp 7700 – Design Principles II8Adding Functionality Through a BaseClassTripprintItinerary()SeaTripprintItinerary()SomeApplicationClassLandTripprintItinerary()StandardTripprintItinerary()Adapted from Software Design: From Programming to Architecture by Eric J. Braude (Wiley 2003), with permission.Internet-based Application Development -- copyright (c) 1998-2001 by Eric J. Braude 7/31/08-- Components -- page C.‹#›Comp 7700 – Design Principles II9Additional Type of FlexibilityComponent technology –… configure objects of predefinedcomplex classes – or sets of classes –so as to interact in many waysComponent technology –… create and store a possibly complexobject of a class.“Behavioral” design patterns –… change, recombine, or otherwisecapture the mutual behavior of a set ofobjects“Structural” design patterns –… create variable trees of objects orother structures at runtime“Creational” design patterns –… create objects in variableconfigurations determined at runtimeDescribed in …Flexibility Aspect: ability to …Adapted from Software Design: From Programming to Architecture by Eric J. Braude (Wiley 2003), with permission.Comp 7700 – Design Principles II10Key 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.Comp 7700 – Design Principles II11Making a Method Re-usable Specify completely– Preconditions etc– Avoid unnecessary coupling with the enclosing class– Make static if feasible– Include parameterization• i.e., make the method functional• But limit the number of parameters Make the names expressive– Understandability promotes re-usability Explain the algorithm– Re-users need to know how the algorithm worksAdapted from Software Design: From Programming to Architecture by Eric J. Braude (Wiley 2003), with permission.Comp 7700 – Design Principles II12Making a Class Re-usable Describe the class completely Make the class name and functionality matcha real world concept Define a useful abstraction– attain broad applicability Reduce dependencies on other classes– Elevate dependencies in hierarchyalternativesAdapted from Software Design: From Programming to Architecture by Eric J. Braude (Wiley 2003), with permission.Internet-based Application Development -- copyright (c) 1998-2001 by Eric J. Braude 7/31/08-- Components -- page C.‹#›Comp 7700 – Design Principles II13Reducing Dependency Among ClassesCustomerReplace …Pianowith …Customer PianoPianoOrderAdapted from Software Design: From Programming to Architecture by Eric J. Braude (Wiley 2003), with permission.Comp 7700 – Design Principles II14Leveraging Inheritance,Aggregation & Dependency for theRe-use of Class CombinationsCustomercomputeBill()RegularCustomercomputeBill()CustomercomputeBill()Billcompute()CustomercomputeBill( Orders )Ordersvalue()(1) Leveraging inheritance(3) Leveragingdependency(2) LeveragingaggregationCustomercomputeBill()Adapted from Software Design: From Programming to Architecture by Eric J. Braude (Wiley 2003), with permission.Comp 7700 – Design Principles II15Basic Approaches to Time Efficiency Design for Other Criteria, Then Consider Efficiency– Design for flexibility, reusability , …– At some point, identify inefficient places– Make targeted changes to improve efficiency Design for Efficiency From the Start– Identify key efficiency requirements up front– Design for these requirements during all phases Combine These Two Approaches– Make trade-offs for efficiency requirements during design– Address remaining efficiency issues after initial designAdapted from Software Design: From Programming to Architecture by Eric J. Braude (Wiley 2003), with permission.Comp 7700 – Design Principles II16Space-Time Trade-offsSpaceTime to process one itemTypical targetAdapted from Software Design: From Programming to Architecture by Eric J. Braude (Wiley 2003), with permission.Internet-based
View Full Document