Example: tourism industry

Design Patterns, Architectural Patterns - nyu.edu

11 Software 8 Sub-Topic 1 Design Patterns , Architectural PatternsDr. Jean-Claude FranchittiNew York UniversityComputer Science DepartmentCourant Institute of Mathematical SciencesDesign Patterns , Architectural A System of Pattern Bushmann et All Design Patterns Gamma et All Concurrent Programming in java D. Lea. Distributed Objects Orfali et All Applying UML and Patterns Patterns help you build on the collective experience of skilled software engineers. They capture existing, well-provenexperience in software development andhelp to promote good Design practice Every pattern deals with a specific, recurring problem in the Design or implementation of a software system Patterns canbeusedto constructsoftware architectures with 35 Becoming a Chess Master First learn rules and physical requirements , names of pieces, legal movements, chess boardgeometry and orientation, etc.

2 3 Bibliography… « A System of Pattern » Bushmann et All « Design Patterns » Gamma et All « Concurrent Programming in Java » D. Lea. « Distributed Objects » Orfali et All « Applying UML and Patterns » Larman 4 Patterns… « Patterns help you build on the collective experience of skilled software engineers. » « They capture existing, well-proven

Tags:

  Java

Information

Domain:

Source:

Link to this page:

Please notify us if you found a problem with this document:

Other abuse

Transcription of Design Patterns, Architectural Patterns - nyu.edu

1 11 Software 8 Sub-Topic 1 Design Patterns , Architectural PatternsDr. Jean-Claude FranchittiNew York UniversityComputer Science DepartmentCourant Institute of Mathematical SciencesDesign Patterns , Architectural A System of Pattern Bushmann et All Design Patterns Gamma et All Concurrent Programming in java D. Lea. Distributed Objects Orfali et All Applying UML and Patterns Patterns help you build on the collective experience of skilled software engineers. They capture existing, well-provenexperience in software development andhelp to promote good Design practice Every pattern deals with a specific, recurring problem in the Design or implementation of a software system Patterns canbeusedto constructsoftware architectures with 35 Becoming a Chess Master First learn rules and physical requirements , names of pieces, legal movements, chess boardgeometry and orientation, etc.

2 Then learn principles , relative value of certain pieces, strategic value of center squares, power of a threat, etc. However, to become a master of chess, one must study the games of other masters These games contain Patterns that must be understood, memorized, and applied repeatedly There are hundreds of these Patterns 6 Becoming a Software Designer Master First learn the rules , the algorithms, data structures and languages of software Then learn the principles , structured programming, modular programming, object oriented programming, generic programming, etc. However, to truly master software Design , one must study the designs of other masters These designs contain Patterns must be understood, memorized, and applied repeatedly There are hundreds of these Patterns 47 Software Architecture A software architecture is a description of thesubsystems and components of a software system and the relationships between them.

3 Subsystems and components are typicallyspecified in different views to show therelevant functional and non-functionalproperties of a software system. The software system is an artifact. It is theresult of the software Design A component is an encapsulated part of a software system. A component has an interface. Components serve as the building blocks for the structure of a system. At a programming-language level, components may be represented as modules, classes, objects or as a set ofrelated A subsystem is a set of collaboratingcomponents performing a given task. A subsystem is considered a separate entitywithin a software architecture. It performs its designated task by interactingwith other subsystems and Patterns An Architectural Pattern expresses a fundamental structural organization schemafor software systems.

4 It provides a set of predefined subsystems, their responsibilities, and includes rules and guidelines for organizing the relationships between Patterns A Design pattern provides a scheme for refining the subsystems or components of a software system, or the relation shipsbetween them. It describes a commonly-recurring structure of communicatingcomponents that solves a general Design problem within a particular An Idiom is a low-level pattern specific to a programming language. An idiom describeshow to implement particular aspects of components or the relationships betweenthem using the features of the A framework is a partially complete software (sub-) system that is intended to beinstantiated.

5 It defines the architecture for a family of (sub-) systems and provides thebasic building blocks to create them. It alsodefines the places where adaptations for specific functionality should be Example A Dice Game A Player rolls 10x 2 dices If result = 7, score=score + 10 points At the end, score of the player is registred in the highscore ++UpdatehighscoreTurn<10[highscore][start][exit][true][false]Activity Diagram16 Analysis : Stri ngscore : int = 0;play()Player()<<Actor>>DiefaceValue : int = 1roll()Die()1212 RollsDiceGameDiceGame()start()1111 Plays1111In cludesHighScoreH i ghs co re ()add()1111 ScoringEntryname:String : type = initvalscore:int : typ e = initva lEntry(name :String,sco re :int)() * *1917 Design Stage Manage User Interface Manage Persistence of highscore in a file or in relational database Realize a layered architecture : Apply theLayer Architectural Pattern18 Layer Helps structure an application that can bedecomposed into groups of subtasks in which each group of subtasks is at a particular level of : examples20 Layer :Structure1121 Layer: Structure22 Layer and : Variants Relaxed Layered System.

6 A layer j can use service of j-1, A layer can be partially opaque Some service to layer j+1, others to all Layering through inheritance: Lower layers are implemented as base classes Higher level can override lower : Known Uses Virtual machines: JVM and binary code format API : Layer that encapsulates lower layers Information System Presentation, Application logic, Domain Layer, Database Windows NT (relaxed for: kernel and IO and hardware) System services, Resource management (Object manager, security monitor, processmanager, I/O manager, VM manager, LPC), Kernel (exception handling, interrupt, multipro synchro, threads), HAL (Hardware Abstraction Level) Hardware1325 Layers: benefits Reuse of layers Support for standardization (POSIX) Dependencies are kept local Exchangeabilities : Replacement of old implementation with Adapter Pattern Dynamic exchange with Bridge Pattern26 Layers: Liabilities Cascades of changing behavior Lower efficiency Unnecessary work: functions of a layer called many times for one service Difficulty of establishing correct granularity of layers.

7 Too few layers -> less benefits, too many layers -> complexity and Layer ArchitecturePlayViewHigh ScoreFichier ou BDDUICorePersistence28 Package decompositionUI<<layer>>Core<<layer>>Persist<<layer>>Util<<subsystem>>1529 Layer core Contain business logic Adapt analysis classes for implementation Use of singleton (Idiom) Ensure a class only has one instance, andprovide a global point of access to Structure32 Core Layer :First diagramEntryname:String : type = initvalscore:int : type = initva lEntry(name:Str ing,sco re :int)( )HighScore$ hs : HighScore = nullHighscore()add()load()save() * *Playername : Stringscore : int = 0;Player()display()Diefa ceV alue : int = 1roll()Die()display()DiceGame$ dg = nullDiceGame()getInstance()start() : Stri ngscore : int = 0;play()Player()<<Actor>>DiefaceValue : int = 1roll()Die()1212 RollsDiceGameDiceGame()start()1111 Plays1111 IncludesEntryname:String : type = initvalscore:int : type = initvalEntry(name:String,score:int)()Hig hScoreHighscore()add()1111 Scoring0.

8 *10 ..*1 DesignAnalysis1733 Package decompositionUI<<layer>>Core<<layer>>Persist<<layer>>Util<<subsystem>>34 Observer One-to-many dependency betweenobjects: change of one object willautomatically notify observers1835 Observer: Applicability A change to one object requires changing an unknown set of other objects Object should be able to notify other objectsthat may not be known at the beginning36 Observer: Structure1937 Observer: Consequences Abstract coupling between subject andobserver Support for broadcast communication Hard to maintain38 Applying Observer Pattern Observablechanged : boolean = falseOb servable()a dd Observer()d elete Observer()no tifyObservers()no tifyObservers()deleteObservers()se tChanged()cl ea rChanged()ha sChanged()countObservers()(from util)DieViewDieView(die : Die)up da te(o : Ob serva ble, arg : Object) : voidPlayerViewPlayerView(player : Player)update(o : Observable, arg : Object) : voidObserverup da te(o : Ob serva ble, a rg : Object) : void(from util)<<Interface>> * *Playername : Stri ngscore : int = 0.

9 Player()display()(from Co re)DiefaceValue : int = 1roll()Die()display()(from Core)2039 Observer ViewOb ser ve rupdate(o : Observable, arg : Object) : void(from uti l)<<Interface>>DieViewDieView(die : Die)update(o : Observable, arg : Object) : voidPlayerViewPlayerView(player : Player)update(o : Observable, arg : Object) : void40 Views are graphical objectsDieViewDieView(die : Die)up da te(o : Ob serva ble, arg : Object) : voidPlayerViewPlayerView(player : Player)update(o : Observable, arg : Object) : voidObservablechanged : boolean = falseOb servable()addObserver()deleteObserver()n o tifyObservers()no tifyObservers()deleteObservers()se tC hanged()clea rChanged()ha sC hanged()countObservers()(from util)Observerup da te(o : Ob serva ble, a rg : Object) : void(from util)<<Interface>> * *Playername : Stringscore : int = 0.

10 Player()display()(from Co re)DiefaceValue : int = 1roll()Die()display()setValue()(from Core)PanelPanel()Panel()constructCompone ntName()addNotify()(from awt)2141 Setting up Observer : RollForm : Die : DieView : Playe : PlayerView1: display( )2 : Pl ayer Vi e w( Pl ayer )4: return component5: display()6: DieView(Die)8: return component3: addObserver(Observer)7: addObserver(Observer)42 Observer : Change Propagation: Die: Randomizer: DieView1: getValue( )2: setValue(int)3: notifyObservers( )4: update(Observable, Object)5: getState()3: JLabel6: setText(3)2243 Layered : int = 1roll()Die()display()setValue()Playerna me : Str i ngscore : int = 0;Player()display()Observer(from util)<<Interface>>Observable(from util) * *Displayable<<Interface>>PlayerViewPlayerView()update()(from UI)RollFormroll_action()cancel_action()R ollForm()(from UI)1+thePlayerView1 DieViewDieView()update()(from UI)+ theD ie View22 UICoreDecoupling classes and interfaces44 Package decompositionUI<<layer>>Core<<layer>>Persist<<layer>>Util<<subsystem>>2345 Pattern Factory Method Intent Define an interface for creating an object, but let sub-classes decide which class to instantiate let a class defer instantiation to subclasses Also known as Virtual Constructor46 Factory Method Applicability.


Related search queries