DOC PREVIEW
AUBURN COMP 7700 - Structural Design Patterns

This preview shows page 1-2-3-4-26-27-28-54-55-56-57 out of 57 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 57 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 57 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 57 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 57 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 57 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 57 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 57 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 57 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 57 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 57 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 57 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 57 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

COMP 7700 – Structural Design Patterns1Chapter 8Structural Design PatternsCOMP 7700 – Structural Design Patterns2Design PurposeProvide an interface to a package of classesDesign Pattern SummaryDefine a singleton which is the sole meansfor obtaining functionality from the package.FacadeNotes: the classes need not be organized as a package;more than one class may be used for the façade.Adapted from Software Design: From Programming to Architecture by Eric J. Braude (Wiley 2003), with permission.COMP 7700 – Structural Design Patterns3C«not exposed»myCMethod() Façade«exposed»cMethodOfFacade()Client12Adapted from Software Design: From Programming to Architecture by Eric J. Braude (Wiley 2003), with permission.Facade Design Pattern StructureCOMP 7700 – Structural Design Patterns4Sequence Diagram for Façade:ClientcMethodOfFacade()singleton:Facade:CmyCMethod()(return if any)(return if any)Adapted from Software Design: From Programming to Architecture by Eric J. Braude (Wiley 2003), with permission.COMP 7700 – Structural Design Patterns5Using Façade for Architecture of a Video GameMyGameCharactersMyGameEngineMyGameCast«facade»MyGame«facade»MyGameEnvironmentMyGameEnvironment«facade»Adapted from Software Design: From Programming to Architecture by Eric J. Braude (Wiley 2003), with permission.COMP 7700 – Structural Design Patterns6Design Goals At Work: Correctness and Reusability Collecting customer-related classes in a package with aclear interface clarifies the design, allows independentverification, and makes this part reusable.Adapted from Software Design: From Programming to Architecture by Eric J. Braude (Wiley 2003), with permission.COMP 7700 – Structural Design Patterns7UsingFaçade toAccessBankCustomersbankCustomersClientmain() «facade»BankCustomersdoDeposit( int amt, Customer cust, Account acc )getBankAccount( Customer cust, int accNum )getBankCustomer( String custName )introduceApplication()BankCustomer BankAccountCustomergetCustomerName()getNumAccounts()getPersonalNote()getAccount( int )AccountgetAccountNum()deposit( int )getBalance()1..nIntroMessageframeworkAccountExceptionCustomerExceptionAdapted from Software Design: From Programming to Architecture by Eric J. Braude (Wiley 2003), with permission.COMP 7700 – Structural Design Patterns8Output ofFaçade BankingExampleAdapted from Software Design: From Programming to Architecture by Eric J. Braude (Wiley 2003), with permission.COMP 7700 – Structural Design Patterns9Key Concept:  Facade Design Pattern -- modularizes designs by hiding complexityAdapted from Software Design: From Programming to Architecture by Eric J. Braude (Wiley 2003), with permission.COMP 7700 – Structural Design Patterns10Design PurposeAdd responsibilities to an object at runtime.Design Pattern SummaryProvide for a linked list of objects,each encapsulating responsibility.DecoratorAdapted from Software Design: From Programming to Architecture by Eric J. Braude (Wiley 2003), with permission.COMP 7700 – Structural Design Patterns11Decorator Class Model ClientobjDecoratedDecorationdoAction()1SubstancedoAction()Componentadd( Component )doAction()void doAction(){ ….. // do actions special to this decoration objDecorated.doAction(); // pass along} Adapted from Software Design: From Programming to Architecture by Eric J. Braude (Wiley 2003), with permission.COMP 7700 – Structural Design Patterns12LinkedObjects inDecoratordecoration1:Decorationdecoration1.objectDecorated:Decoration… :Decoration….:Substanceclient:ClientAdapted from Software Design: From Programming to Architecture by Eric J. Braude (Wiley 2003), with permission.COMP 7700 – Structural Design Patterns13Sequence Diagram for Decorator:ClientdoAction()decoration1:DecorationdoAction()Decoration1.objDecorated:Decoration:SubstancedoAction()Adapted from Software Design: From Programming to Architecture by Eric J. Braude (Wiley 2003), with permission.COMP 7700 – Structural Design Patterns14Output ofCustomer/AccountExampleCOMP 7700 – Structural Design Patterns15Process Phases Discussed in This ChapterRequirementsAnalysisDesignImplementationArchitectureFramework Detailed DesignxKey: = secondary emphasisx = main emphasisAdapted from Software Design: From Programming to Architecture by Eric J. Braude (Wiley 2003), with permission.COMP 7700 – Structural Design Patterns16Decorator Appliedto Customer /Accounts ExampleClientnextComponentAccountdescribe()1Customerdescribe()BankingComponentadd( Component )describe()CheckAccountdescribe()getLastCheckNum(): intSavingsAccountdescribe()getInterestRate(): intCDAccountdescribe()getDuration(): intSetupAttemptToAddBadBankingComponentExceptionCOMP 7700 – Structural Design Patterns17Use of Decorator in java.ioInputStreamReaderInputStreamBufferedReaderReader1Adapted from Software Design: From Programming to Architecture by Eric J. Braude (Wiley 2003), with permission.COMP 7700 – Structural Design Patterns18java.io Decorator example:InputStreamReaderSystem.in:InputStream: BufferedStreamReader Adapted from Software Design: From Programming to Architecture by Eric J. Braude (Wiley 2003), with permission.COMP 7700 – Structural Design Patterns19Key Concept:  Decorator Design Pattern -- allows addition to andremoval from objects at runtimeAdapted from Software Design: From Programming to Architecture by Eric J. Braude (Wiley 2003), with permission.COMP 7700 – Structural Design Patterns20Design PurposeRepresent a Tree of ObjectsDesign Pattern SummaryUse a Recursive Form in which thetree class aggregates and inheritsfrom the base class for the objects.CompositeAdapted from Software Design: From Programming to Architecture by Eric J. Braude (Wiley 2003), with permission.COMP 7700 – Structural Design Patterns21NonLeafNodeBasis for Composite Class ModelComponent“every object involvedis a Component object”“non-leaf nodeshave one or morecomponents”leaf nodenon-leaf nodeObjectsClasses1..nAdapted from Software Design: From Programming to Architecture by Eric J. Braude (Wiley 2003), with permission.COMP 7700 – Structural Design Patterns22NonLeafNodedoIt()Composite Class Modeletc.componentComponentadd( Component )doIt()LeafNodedoIt()TypeANonLeafNodedoIt()TypeBNonLeafNodedoIt()1..nClientFOR ALL elements e in component e.doIt()COMP 7700 – Structural Design Patterns23:LeafNodenonLeaf1ChildX:NonLeafNodenonLeaf1ChildX:NonLeafNodeSequence Diagram for


View Full Document

AUBURN COMP 7700 - Structural Design Patterns

Download Structural Design Patterns
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Structural Design Patterns and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Structural Design Patterns 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?