jagomart
digital resources
picture1_Gof Design Patterns Pdf 187257 | Designpatterns 10


 202x       Filetype PDF       File size 0.25 MB       Source: people.cs.vt.edu


File: Gof Design Patterns Pdf 187257 | Designpatterns 10
design patterns more design patterns gof structural adapter bridge facade creational abstract factory singleton behavioral observer iterator state visitor design patterns 10 cs431 f06 bg ryder a rountev 1 design ...

icon picture PDF Filetype PDF | Posted on 02 Feb 2023 | 2 years ago
Partial capture of text on file.
                                                      Design Patterns
                                • More design patterns (GoF)
                                    – Structural: Adapter, Bridge, Façade
                                    – Creational: Abstract Factory, Singleton
                                    – Behavioral: Observer, Iterator, State,
                                       Visitor
                                Design Patterns-10, CS431 F06, BG Ryder/A Rountev                          1
                                                      Design Patterns
                                   • Design patterns have become very popular
                                      in the last decade or so
                                   • Major source: GoF book 1995
                                           • “Design Patterns: Elements of Reusable Object-
                                             Oriented Software”
                                           • Gamma, Helm, Johnson, Vlissides (gang of 4)
                                   • Patterns describe well-known solutions to
                                      common design problems
                                           • Used in Java libraries, especially in the GUI
                                             libraries
                                Design Patterns-10, CS431 F06, BG Ryder/A Rountev                          2
                                                                                                                               1
                                          Design Patterns (LAR Ch26; GoF)
                                   • Structural
                                            • Concerned with how classes and objects are composed to
                                              make larger structures (Adapter, Bridge, Composite,
                                              Façade)
                                   • Creational
                                            • Abstract the instantiation process to make a system
                                              independent of how its objects are created & represented
                                              (Abstract Factory, Singleton)
                                   • Behavioral
                                            • Describe patterns of communication and interaction between
                                              objects (algorithms and responsibility assignment) (Observer,
                                              State, Strategy, Mediator)
                                 Design Patterns-10, CS431 F06, BG Ryder/A Rountev                         3
                                Adapter Pattern: Interface Matcher
                                 • Problem: incompatible interfaces
                                 • Solution: create a wrapper that maps one
                                    interface to another
                                         • Key point: neither interface has to change and they
                                           execute in decoupled manner
                                             – Think of how you use a power plug adaptor when you travel
                                               to Europe
                                 • Example:
                                     – Client written against some interface
                                     – Server with the right functionality but with the
                                       wrong interface
                                 Design Patterns-10, CS431 F06, BG Ryder/A Rountev                         4
                                                                                                                                2
                                                              Example
                                          Client        Abstract                     ZServer
                                                          Server                      bar(int)
                                                           foo()                             1
                                       Server1           Server2          ZAdapter
                                          foo()             foo()            foo()         1
                                    • Option 1: Change the client, bad
                                    • Option 2: Change Zserver, too hard
                                    • Option 3: Create an adapter to wrap Zserver to
                                       obtain necessary functionality, good soln
                                 Design Patterns-10, CS431 F06, BG Ryder/A Rountev                          5
                                                    Sample Java Code
                                    abstract class AbstractServer { abstract void foo();
                                       }
                                    class ZAdapter extends AbstractServer {
                                       private ZServer z;
                                       public ZAdapter() { z = new ZServer(); }
                                       public void foo() { z.bar(5000); }//wrap call to
                                       ZServer method
                                    }
                                    …
                                    somewhere in client code:
                                    AbstractServer s = new ZAdapter();
                                 Design Patterns-10, CS431 F06, BG Ryder/A Rountev                          6
                                                                                                                                 3
                                                Hierarchy of Adaptees
                                    Client         Abstract
                                                     Server
                                                      foo()
                                  Server1           Server2          ZAdapter                ZServer
                                     foo()            foo()             foo()        1 1 bar(int)
                                                            BetterZServer              BestZServer
                                                                  bar(int)                 bar(int)
                                 Design Patterns-10, CS431 F06, BG Ryder/A Rountev                          7
                                                    Sample Java Code
                                    abstract class AbstractServer { abstract void foo();
                                       }
                                    class ZAdapter extends AbstractServer {
                                       private ZServer z;
                                       public ZAdapter(int perf) {
                                            if (perf > 10)           z = new BestZServer();
                                            else if (perf > 3) z = new BetterZServer();
                                            else                     z = new ZServer();
                                       }
                                       public void foo() { z.bar(5000); }
                                    }
                                 Design Patterns-10, CS431 F06, BG Ryder/A Rountev                          8
                                                                                                                                 4
The words contained in this file might help you see if this file matches what you are looking for:

...Design patterns more gof structural adapter bridge facade creational abstract factory singleton behavioral observer iterator state visitor cs f bg ryder a rountev have become very popular in the last decade or so major source book elements of reusable object oriented software gamma helm johnson vlissides gang describe well known solutions to common problems used java libraries especially gui lar ch concerned with how classes and objects are composed make larger structures composite instantiation process system independent its created represented communication interaction between algorithms responsibility assignment strategy mediator pattern interface matcher problem incompatible interfaces solution create wrapper that maps one another key point neither has change they execute decoupled manner think you use power plug adaptor when travel europe example client written against some server right functionality but wrong zserver bar int foo zadapter option bad too hard an wrap obtain necessa...

no reviews yet
Please Login to review.