Chapter01
Chapter01
Thought Process
Chapter 1
§ Inheritance ke thua
§ Polymorphism da hinh
2
Object Wrappers
lo ngai he thong cu
Even xuwhen
huong
there are legacy concerns, there is a
trend to wrap the legacy systems in object
wrappers.
– Wrappers are used to wrap:
• Legacy code
khong di dong
• Non-portable code
• etc,.
3
What is an Object?
thuc the
4
Procedural Programming
5
Unpredictable?
6
Nice Packages
ket hop
7
Data and Behaviors
8
O-O Programming
9
Object Data
10
Object Behaviors
11
Object Behaviors
12
What Exactly Is a Class?
ban thiet ke
13
What Exactly Is a Class?
An object cannot be
instantiated without a
class.khoi tao
– Classes can be
thought of as the
templates, or cookie
cutters, for objects as
seen in the next
figure.
14
Higher Level Data Types?
int x;
float y;
15
Modeling a Class in UML
16
Method Signatures
17
Program Spaces
18
Encapsulation
uu diem chinh
19
Encapsulation
lien quan
Details not pertinent to the use of the object should
be hidden from other objects.
– This is called encapsulation.
20
Interfaces
21
Interfaces
22
Implementations
23
Inheritance
24
Mammal Hierarchy
25
Superclasses and Subclasses
26
Mammal Hierarchy
27
Is-a Relationships
28
Polymorphism
29
Polymorphism
30
Polymorphism
31
Polymorphism
32
Polymorphism
33
Shape UML Diagram
34
Composition
35
Composition
36
Composition
37
Has-a Relationships
38
Has-a Relationships
39
Has-a Relationships
40