![Page 1: Copyright W. Howden1 Lecture 7: Functional and OO Design Descriptions](https://reader035.vdocuments.site/reader035/viewer/2022062714/56649d355503460f94a0d1b4/html5/thumbnails/1.jpg)
Copyright W. Howden 1
Lecture 7: Functional and OO Design Descriptions
![Page 2: Copyright W. Howden1 Lecture 7: Functional and OO Design Descriptions](https://reader035.vdocuments.site/reader035/viewer/2022062714/56649d355503460f94a0d1b4/html5/thumbnails/2.jpg)
Copyright W. Howden 2
Executable Units
• Functional– Procedures
– Functions
– Subroutines
• Modules– Collections of
procedures
– Interface procedures
• Object Oriented– Classes
– Interfaces
– Class methods
• Components– Collections of classes
– Interface classes
![Page 3: Copyright W. Howden1 Lecture 7: Functional and OO Design Descriptions](https://reader035.vdocuments.site/reader035/viewer/2022062714/56649d355503460f94a0d1b4/html5/thumbnails/3.jpg)
Copyright W. Howden 3
Functional Design
• Module connection/relationship models• Design development
– Top down design– Program refinement
• Module/Procedure call/use diagrams• Algorithm design descriptions
– Pseudo-Code– Nassi-Schneiderman diagrams– Decision Tables
![Page 4: Copyright W. Howden1 Lecture 7: Functional and OO Design Descriptions](https://reader035.vdocuments.site/reader035/viewer/2022062714/56649d355503460f94a0d1b4/html5/thumbnails/4.jpg)
Copyright W. Howden 4
Object Oriented Design
• Component connection/relationship models
• Design development – interaction sequence, collaboration diagrams– visibility analysis
• Design Diagrams – Class Structure
• Method design descriptions– algorithm design descriptions
![Page 5: Copyright W. Howden1 Lecture 7: Functional and OO Design Descriptions](https://reader035.vdocuments.site/reader035/viewer/2022062714/56649d355503460f94a0d1b4/html5/thumbnails/5.jpg)
Copyright W. Howden 5
Functional Design Diagrams – Function Interactions
• Tree structure
• Nodes are procedures or modules
• Arcs are calls or uses
• Arc notation: shows flow of data from one node to another: data couples
• Computational and control flow couples
![Page 6: Copyright W. Howden1 Lecture 7: Functional and OO Design Descriptions](https://reader035.vdocuments.site/reader035/viewer/2022062714/56649d355503460f94a0d1b4/html5/thumbnails/6.jpg)
Copyright W. Howden 6
![Page 7: Copyright W. Howden1 Lecture 7: Functional and OO Design Descriptions](https://reader035.vdocuments.site/reader035/viewer/2022062714/56649d355503460f94a0d1b4/html5/thumbnails/7.jpg)
Copyright W. Howden 7
DS Top Down Design
DS process
Dater or Admin process
Dater process
GetADate or SetMember Data process
Filemanager process
Admin processAdd or Delete process
FileManager process
![Page 8: Copyright W. Howden1 Lecture 7: Functional and OO Design Descriptions](https://reader035.vdocuments.site/reader035/viewer/2022062714/56649d355503460f94a0d1b4/html5/thumbnails/8.jpg)
Copyright W. Howden 8
DS PseudoCode and Program Refinement
Member Data getADate(DaterPreferences daterPrefs){ Record record; Boolean match = false;
record = filemanager(“getFirst”);see if record matches daterPrefs and set match
while ((record =/ null) and (match == false)){ record = filemanager(“getNext);
see if record matches daterPrefs and set match}if (match = = false) return null else return record;
}
![Page 9: Copyright W. Howden1 Lecture 7: Functional and OO Design Descriptions](https://reader035.vdocuments.site/reader035/viewer/2022062714/56649d355503460f94a0d1b4/html5/thumbnails/9.jpg)
Copyright W. Howden 9
Data VisibilityFor Functional Programs
• Data item: a function f uses or accesses a data item. How do we enable it to access and manipulate this data.– Local variable: declare one and assign data to it– Parameter: accessed passed data using formal
parameter, or assign it to a local variable– Assign and reference data via a global variable
![Page 10: Copyright W. Howden1 Lecture 7: Functional and OO Design Descriptions](https://reader035.vdocuments.site/reader035/viewer/2022062714/56649d355503460f94a0d1b4/html5/thumbnails/10.jpg)
Copyright W. Howden 10
Type Visibility of Functional Programs
• Variable declarations involve a type
• Type definition visibility– Global generic types– Global struct definitions (C )– Local struct definitions– Includes files
![Page 11: Copyright W. Howden1 Lecture 7: Functional and OO Design Descriptions](https://reader035.vdocuments.site/reader035/viewer/2022062714/56649d355503460f94a0d1b4/html5/thumbnails/11.jpg)
Copyright W. Howden 11
Object Oriented Design Diagrams – Class Models
• Graph structure• Nodes correspond to classes• Arcs are relationships between classes• Visibility analysis in class diagrams
– Solid arc from A to B indicates A has a class variable whose values are instances of B
– Dotted arcs indicate other kinds of visibility implementations
![Page 12: Copyright W. Howden1 Lecture 7: Functional and OO Design Descriptions](https://reader035.vdocuments.site/reader035/viewer/2022062714/56649d355503460f94a0d1b4/html5/thumbnails/12.jpg)
Copyright W. Howden 12
Diagram Details
• Nodes/Classes– Attributes: associated simple variables– Names and signatures of methods– Similar to Domain model classes, + methods
• Arcs– type of relationship, roles, multiplicity
• Separate details: for readability
![Page 13: Copyright W. Howden1 Lecture 7: Functional and OO Design Descriptions](https://reader035.vdocuments.site/reader035/viewer/2022062714/56649d355503460f94a0d1b4/html5/thumbnails/13.jpg)
Copyright W. Howden 13
GUIFrame LogOnDialog
DaterOptionSelectionDialog
SelectDaterPrefsDialog EntermemberDataDialog SelectedDateeDialog
MessageDialog
DomainLogic
<<parameter>> <<attribute>>
<<Local Variable>>
<<attribute>>
<<attribute>>
<<Attribute>>
<<parameter>>
<<parameter>>
<<parameter>><<parameter>>
![Page 14: Copyright W. Howden1 Lecture 7: Functional and OO Design Descriptions](https://reader035.vdocuments.site/reader035/viewer/2022062714/56649d355503460f94a0d1b4/html5/thumbnails/14.jpg)
Copyright W. Howden 14
Object Visibility for Object Oriented Designs
• An object X of class A has the ability to see or reference an object Y of class B
• E.g. in a collaboration diagram, X sends a message to Y
• Will require some way of achieving this visibility in the design
• Design Class Diagram can be used to document visibility implementation decisions
![Page 15: Copyright W. Howden1 Lecture 7: Functional and OO Design Descriptions](https://reader035.vdocuments.site/reader035/viewer/2022062714/56649d355503460f94a0d1b4/html5/thumbnails/15.jpg)
Copyright W. Howden 15
Ways to Achieve Object Visibility
• Attribute
• Parameter
• Local Variable
• Global
![Page 16: Copyright W. Howden1 Lecture 7: Functional and OO Design Descriptions](https://reader035.vdocuments.site/reader035/viewer/2022062714/56649d355503460f94a0d1b4/html5/thumbnails/16.jpg)
Copyright W. Howden 16
Attribute Visibility
• Class A can be defined with an attribute variable y whose values are of class B, which can be assigned the value Y
• E.g. :GUIFrame object in DS sends a getUserType() message to object dL:DomainLogic
![Page 17: Copyright W. Howden1 Lecture 7: Functional and OO Design Descriptions](https://reader035.vdocuments.site/reader035/viewer/2022062714/56649d355503460f94a0d1b4/html5/thumbnails/17.jpg)
Copyright W. Howden 17
1b: [Button = Start] show()
dL : DomainLogic
: LogOnDialog : GUIFrame
System
GUI Frame Presentation Logic
3a: [1b & userType == MEMBER] show()
2: [1b] userType = getUserType()
3b: [1b & userType = UNAUTH] create(gUI, "Unauthorized")4: [1b & userType = UNAUTH] show()
1a: [Button == End] Exit
Start/End Button
: DaterOptionSelectionDialog
: MessageDialog
![Page 18: Copyright W. Howden1 Lecture 7: Functional and OO Design Descriptions](https://reader035.vdocuments.site/reader035/viewer/2022062714/56649d355503460f94a0d1b4/html5/thumbnails/18.jpg)
Copyright W. Howden 18
Attribute Visibility Solution
• Class GUIFrame, the class for the object :GUIFrame, will have an attribute/class variable dL of type DomainLogic whose value is the object dL.
• Permanent association needed. Attribute visibility is a good solution.
![Page 19: Copyright W. Howden1 Lecture 7: Functional and OO Design Descriptions](https://reader035.vdocuments.site/reader035/viewer/2022062714/56649d355503460f94a0d1b4/html5/thumbnails/19.jpg)
Copyright W. Howden 19
Parameter Visibility
• Y is referenced inside a method m() for X’s class A. Y can be passed as a parameter y of m() which can be referenced in m()
• Eg. GUIFrame is going to set dL attribute variable to the dL Object, i.e. establish the attribute visibility in the earlier example.
![Page 20: Copyright W. Howden1 Lecture 7: Functional and OO Design Descriptions](https://reader035.vdocuments.site/reader035/viewer/2022062714/56649d355503460f94a0d1b4/html5/thumbnails/20.jpg)
Copyright W. Howden 20
1b: [Button = Start] show()
dL : DomainLogic
: LogOnDialog : GUIFrame
System
GUI Frame Presentation Logic
3a: [1b & userType == MEMBER] show()
2: [1b] userType = getUserType()
3b: [1b & userType = UNAUTH] create(gUI, "Unauthorized")4: [1b & userType = UNAUTH] show()
1a: [Button == End] Exit
Start/End Button
: DaterOptionSelectionDialog
: MessageDialog
![Page 21: Copyright W. Howden1 Lecture 7: Functional and OO Design Descriptions](https://reader035.vdocuments.site/reader035/viewer/2022062714/56649d355503460f94a0d1b4/html5/thumbnails/21.jpg)
Copyright W. Howden 21
Parameter Visibility Solution
• Parameter dL:DomainLogic will be passed as a parameter in the constructor for GUIFrame.
• Temporary parameter visibility is then changed to a more permanent attribute visibility
![Page 22: Copyright W. Howden1 Lecture 7: Functional and OO Design Descriptions](https://reader035.vdocuments.site/reader035/viewer/2022062714/56649d355503460f94a0d1b4/html5/thumbnails/22.jpg)
Copyright W. Howden 22
Local Variable Visibility
• A method m() in the class A for X can be defined with a local variable y of class B, that can be assigned to Y.
• E.g. In the GUI example, when a user selects the option of getting a date, the system will create and display an SelectDataPrefsDialog.
![Page 23: Copyright W. Howden1 Lecture 7: Functional and OO Design Descriptions](https://reader035.vdocuments.site/reader035/viewer/2022062714/56649d355503460f94a0d1b4/html5/thumbnails/23.jpg)
Copyright W. Howden 23
6b: [mD == null] create(gUI, "No Date")7b: [mD == null] show()
6a: [mD /= null] create (gUI, mD.name, mD.dateeData)7a: [ mD /= null] show()
: DaterOptionSelectionDialog : SelectDateePropsDialog
daterPrefs : DaterPreferences
: SelectDaterPrefsDialog
dL : DomainLogic
: MessageDialog
GetADateButton
4: userName = getUserName()5: mD = getDate(userName, daterPrefs)2: create()
3: show()
1: create()
8: setVisible(false)
![Page 24: Copyright W. Howden1 Lecture 7: Functional and OO Design Descriptions](https://reader035.vdocuments.site/reader035/viewer/2022062714/56649d355503460f94a0d1b4/html5/thumbnails/24.jpg)
Copyright W. Howden 24
Local Variable Visibility Solution
• Solution: the method in DaterOptionsSelectionDialog that is invoked when the getDate() button is pressed will have a local variable of type SelectDaterPrefsDialog that can be assigned to the object :SelectDaterPrefsDialog that is created at this point.
![Page 25: Copyright W. Howden1 Lecture 7: Functional and OO Design Descriptions](https://reader035.vdocuments.site/reader035/viewer/2022062714/56649d355503460f94a0d1b4/html5/thumbnails/25.jpg)
Copyright W. Howden 25
Global Visibility
• The object Y is made global to all classes so that all can reference it.
• E.g. The Message Dialog is used over and over in DS.
• Global visibility solution. Create a top level class that is global to all that use it. Assume it has a static object x whose value is dialog instance that can be re-used with different messages
![Page 26: Copyright W. Howden1 Lecture 7: Functional and OO Design Descriptions](https://reader035.vdocuments.site/reader035/viewer/2022062714/56649d355503460f94a0d1b4/html5/thumbnails/26.jpg)
Copyright W. Howden 26
GUI Example
• Simple diagram with relationships
• Sample detailed class descriptions given separately– Each has setVisible(), show(), a constructor
and a method for responding to a button event that will be called by the OS
![Page 27: Copyright W. Howden1 Lecture 7: Functional and OO Design Descriptions](https://reader035.vdocuments.site/reader035/viewer/2022062714/56649d355503460f94a0d1b4/html5/thumbnails/27.jpg)
Copyright W. Howden 27
GUIFrame LogOnDialog
DaterOptionSelectionDialog
SelectDaterPrefsDialog EntermemberDataDialog SelectedDateeDialog
MessageDialog
DomainLogic
<<parameter>> <<attribute>>
<<Local Variable>>
<<attribute>>
<<attribute>>
<<Attribute>>
<<parameter>>
<<parameter>>
<<parameter>><<parameter>>
![Page 28: Copyright W. Howden1 Lecture 7: Functional and OO Design Descriptions](https://reader035.vdocuments.site/reader035/viewer/2022062714/56649d355503460f94a0d1b4/html5/thumbnails/28.jpg)
Copyright W. Howden 28
+setVisible()+show()+buttonAction(in id : int)+DaterOptionSelectionDialog(in gUIGuiFrame)
+getADate: Button+setMemberData: Button-parentFrame: Frame
DaterOptionSelectionDialog
+show()+setVisible()+LogOnDialog(): LogOnDialog()+buttonAction(in id:buttonID)
+OKButton: Button+nameField: TextField-parentFrame: Frame
LogOnDialog
![Page 29: Copyright W. Howden1 Lecture 7: Functional and OO Design Descriptions](https://reader035.vdocuments.site/reader035/viewer/2022062714/56649d355503460f94a0d1b4/html5/thumbnails/29.jpg)
Copyright W. Howden 29
O/O Programming and Class Visibility
• Declaration of an object of some class– E.g. Attribute/class variable, local variable
(method), parameter (method), global– How is the class definition known in that
context?– Determines structuring of class definitions
• Java: Inner class definition, file visibility, package visibility, import visibility
![Page 30: Copyright W. Howden1 Lecture 7: Functional and OO Design Descriptions](https://reader035.vdocuments.site/reader035/viewer/2022062714/56649d355503460f94a0d1b4/html5/thumbnails/30.jpg)
Copyright W. Howden 30
Class Visibility – Inner Classes
• Class A has an attribute variable y of class B
• Include the definition for class B inside class A
• E.g. in DS, all of the GUI class definitions are inner classes in GUI, which makes it possible to define instances of them
![Page 31: Copyright W. Howden1 Lecture 7: Functional and OO Design Descriptions](https://reader035.vdocuments.site/reader035/viewer/2022062714/56649d355503460f94a0d1b4/html5/thumbnails/31.jpg)
Copyright W. Howden 31
File Visibility
• A class in a file can access other class definitions in that file
• E.g. DS The class definition for the message class file is included in the GUI class file. GUI is the public object in this file (Java)
![Page 32: Copyright W. Howden1 Lecture 7: Functional and OO Design Descriptions](https://reader035.vdocuments.site/reader035/viewer/2022062714/56649d355503460f94a0d1b4/html5/thumbnails/32.jpg)
Copyright W. Howden 32
Package Visibility
• The classes in one file in a package can see the public and non-private classes in other files. Private classes in a file are not visible outside the file.
![Page 33: Copyright W. Howden1 Lecture 7: Functional and OO Design Descriptions](https://reader035.vdocuments.site/reader035/viewer/2022062714/56649d355503460f94a0d1b4/html5/thumbnails/33.jpg)
Copyright W. Howden 33
Import Visibility
• One file can declare itself to be part of a named package
• A file can import files in specified packages
• E.g. In DS GUI has parameter visibility to a Domain Logic object that is passed to its constructor. GUI has visibility to the DomainLogic class via an import statement
![Page 34: Copyright W. Howden1 Lecture 7: Functional and OO Design Descriptions](https://reader035.vdocuments.site/reader035/viewer/2022062714/56649d355503460f94a0d1b4/html5/thumbnails/34.jpg)
Copyright W. Howden 34
Domain Logic Examples
• Object visibility problem– An object X of class A has the ability to see or
reference an object Y of class B– E.g. in a collaboration diagram, X sends a
message to Y– Will require some way of achieving this
visibility in the design
![Page 35: Copyright W. Howden1 Lecture 7: Functional and OO Design Descriptions](https://reader035.vdocuments.site/reader035/viewer/2022062714/56649d355503460f94a0d1b4/html5/thumbnails/35.jpg)
Copyright W. Howden 35
Object Visibility Solutions
• Attribute
• Parameter
• Local Variable
• Global
![Page 36: Copyright W. Howden1 Lecture 7: Functional and OO Design Descriptions](https://reader035.vdocuments.site/reader035/viewer/2022062714/56649d355503460f94a0d1b4/html5/thumbnails/36.jpg)
Copyright W. Howden 36
Attribute Visibility
• Class A can be defined with an attribute variable y whose values are of class B, which can be assigned the value Y
• E.g. dL:DomainLogic object in DS sends a getMemberData() message to object :DataBase
![Page 37: Copyright W. Howden1 Lecture 7: Functional and OO Design Descriptions](https://reader035.vdocuments.site/reader035/viewer/2022062714/56649d355503460f94a0d1b4/html5/thumbnails/37.jpg)
Copyright W. Howden 37
![Page 38: Copyright W. Howden1 Lecture 7: Functional and OO Design Descriptions](https://reader035.vdocuments.site/reader035/viewer/2022062714/56649d355503460f94a0d1b4/html5/thumbnails/38.jpg)
Copyright W. Howden 38
Attribute Visibility Solution
• Class DomainLogic, the class for the object dL:DomainLogic, will have an attribute/class variable dB of type DataBase whose value is the object dB.
• Permanent association needed. Attribute visibility is a good solution.
![Page 39: Copyright W. Howden1 Lecture 7: Functional and OO Design Descriptions](https://reader035.vdocuments.site/reader035/viewer/2022062714/56649d355503460f94a0d1b4/html5/thumbnails/39.jpg)
Copyright W. Howden 39
Parameter Visibility
• Y is referenced inside a method m() for X’s class A. Y can be passed as a parameter y of M() which can be referenced in m()
• E.g. In the DS, DomainLogic is going to set dB attribute variable to the dB Object, i.e. establish the attribute visibility in the earlier example
![Page 40: Copyright W. Howden1 Lecture 7: Functional and OO Design Descriptions](https://reader035.vdocuments.site/reader035/viewer/2022062714/56649d355503460f94a0d1b4/html5/thumbnails/40.jpg)
Copyright W. Howden 40
![Page 41: Copyright W. Howden1 Lecture 7: Functional and OO Design Descriptions](https://reader035.vdocuments.site/reader035/viewer/2022062714/56649d355503460f94a0d1b4/html5/thumbnails/41.jpg)
Copyright W. Howden 41
Parameter Visibility Solution
• Parameter dB:DataBase will be passed as a parameter in the constructor for DomainLogic.
• Temporary parameter visibility is then changed to a more permanent attribute visibility
![Page 42: Copyright W. Howden1 Lecture 7: Functional and OO Design Descriptions](https://reader035.vdocuments.site/reader035/viewer/2022062714/56649d355503460f94a0d1b4/html5/thumbnails/42.jpg)
Copyright W. Howden 42
Local Variable Visibility
• A method m() in the class A for X can be defined with a local variable y of class B, that can be assigned to Y.
• E.g. DS class DomainLogic has a method setMemberData that is called from GUI. It calls getMemberData(userName) in the data base to get back a member record which it then processes.
![Page 43: Copyright W. Howden1 Lecture 7: Functional and OO Design Descriptions](https://reader035.vdocuments.site/reader035/viewer/2022062714/56649d355503460f94a0d1b4/html5/thumbnails/43.jpg)
Copyright W. Howden 43
![Page 44: Copyright W. Howden1 Lecture 7: Functional and OO Design Descriptions](https://reader035.vdocuments.site/reader035/viewer/2022062714/56649d355503460f94a0d1b4/html5/thumbnails/44.jpg)
Copyright W. Howden 44
Local Variable Visibility Solution
• Solution: the setMemberData(), method will have a local variable mD which it can assign to the MemberData record returned from getMemberData(). This will enable it to maintain temporary visibility during the life of setMemberData.
![Page 45: Copyright W. Howden1 Lecture 7: Functional and OO Design Descriptions](https://reader035.vdocuments.site/reader035/viewer/2022062714/56649d355503460f94a0d1b4/html5/thumbnails/45.jpg)
Copyright W. Howden 45
Domain Logic Class Diagram
• Shows association relationships (attributes and other kinds of dependencies)
• Derived from above and other Collaboration Models
• Class details (attributes and methods) omitted
• Associations show class visibility also
![Page 46: Copyright W. Howden1 Lecture 7: Functional and OO Design Descriptions](https://reader035.vdocuments.site/reader035/viewer/2022062714/56649d355503460f94a0d1b4/html5/thumbnails/46.jpg)
Copyright W. Howden 46
DomainLogic
DateRequest LogOn
Data Base
MemberData
<<Import Class>> << Formal Parameter, Attribute>>
<<Inner Class>> <<Attribute>>
<<Inner Class>> <<Local Variable>>
<<Import Class>> <<Local Variable>>