Professional Documents
Culture Documents
L3&4 - 2023
L3&4 - 2023
L3&4 - 2023
• INTERFACES
• OBJECT RELATIONSHIPS
Result:
YES!
Stu Elmer
Prime factorization of 905:
5181 (2 distinct factors)
Prime factorization of 1988:
22771 (4 factors, 3 distinct)
Two integers are said to be coprime or relatively prime if they have no common factor other than 1 or,
equivalently, if their greatest common divisor is 1.
OBJECTS DON’T ACCEPT ARBITRARY CALLS
Object:
method-1: method-2: method-3:
ATM machine
Accept card Read code Take selection
1234
5678
12345
1
4 2
7 5 3
8 6
0 9
OBJECT INTERFACE
Interface defines method “signatures”
Method signature: name, parameters, parameter types, return type
Interface
method-1 Object hides its state
(attributes). The attributes
method-2 are accessible only through
the interface.
method-3
CLIENTS, SERVERS, MESSAGES
Client
Client Object
Object Server
Server
Object
Object
Message
Software Module
Data
(state)
Software Class
«interface»
Inheritance
BaseInterface
relationship:
ClassName BaseInterface
+ operation()
is implemented
# attribute_1 : int by two classes
Three compartments: # attribute_2 : boolean
# attribute_3 : String
1. Classifier name
+ operation_1() : void
+ operation_2() : String Class1Implement Class2Implement
2. Attributes
+ operation_3(arg1 : int)
+ operation() + operation()
3. Operations
OBJECT RELATIONSHIPS (1)
Composition
Derived Class B
B acts as “front-end” for A and uses services of A
+ operation()
(i.e., B may implement the same interface as A)
Inheritance
OBJECT RELATIONSHIPS (2)
...
}
Composition Aggregation
1 1 1..3 1 17
Name Student Address
UML NOTATION FOR INHERITANCE
What are the members of each class in the below class diagram?
SuperClass
Subclass
Subclass
Inheritance
UML
notation
OBJECT-ORIENTED VERSUS
PROCESS-ORIENTED APPROACHES
System
1
2
3
4
5
X
Y
Key
Key unlock() Lock
Lock turnOn() Light
Light
(b) Checker
Checker Ctrl
Ctrl Ctrl
Ctrl
Valid No
key
?
Unlock the
Key
Key Lock
Lock Light
Light
lock (c) Checker
Checker Ctrl
Ctrl Ctrl
Ctrl
Turn the
light on
• OBJECT-ORIENTED IS ORGANIZATION-CENTRIC
• BUT, HARD TO DESIGN WELL ORGANIZATIONS…
HOW TO DESIGN WELL OO SYSTEMS?
CO-3 Code-3
Requirements
Engineering Use Cases OOA/OOD Implementation
(Section 2.2) (Section 2.3) (Sections 2.4 & 2.5) (Section (2.7)