SDF - Week 16
SDF - Week 16
Note:
• Some of the slides of the course are based on the material provided
by the College of Technological Information, Zayed University, UAE.
• The copyrighted material belongs to their respective owners.
1
11/12/2024
Topics of Discussion
• The Object Oriented Paradigm
• Managing Software Complexity
• The Object and its Class
• Attributes and Behaviors
• Encapsulation & Information Hiding
• Abstraction
2
11/12/2024
Definition of Software
-A software is a collection of interoperable programs
-A program is a logical sequence of instructions to
achieve a certain requirement
-An instruction (command) is a combination of bits
(0s and 1s) which is understood by a device
(computer)
Software Complexity
• Real-World systems are becoming more and more reliant on software.
• Ex: Banking, Transportation, Navigation, Health Care, Education, Security etc.
• For all real-world systems the software has become very complex and
the relative size has increased enormously.
• The need to manage software has become very critical to all areas of life
• Many times, it is even life saving, because these software control real-
world systems.
6
3
11/12/2024
[1] Evaluating and Mitigating the Impact of Complexity in Software Models, TECHNICAL REPORT, CMU/SEI-2015-TR-013, Carnegie Mellon University
https://resources.sei.cmu.edu/asset_files/TechnicalReport/2015_005_001_448093.pdf
4
11/12/2024
10
10
5
11/12/2024
Collecting Requirements
11
11
Understanding Requirements
• The challenge of Requirement
Elicitation.
o conflicting requirements
o unspoken requirements
o difficulty in meeting with relevant
stakeholders
o stakeholder resistance to change
12
12
6
11/12/2024
OO Software Design
13
13
14
7
11/12/2024
15
15
16
16
8
11/12/2024
Class Diagram
17
17
UpperCamelCase
18
18
9
11/12/2024
• The class Car will provide the template to define any car by defining:
• Attributes and Behaviors common to any Car
• So, we need to identify
• Attributes or data that define a car.
• Behaviors or functions that define a car
• Note: The first alphabet of Class names are written in Upper case. This is a common
convention used by all programmers
19
19
Class - Attributes
• We use generic physical attributes of a car
• Discuss: What are the attributes or data that define a car?
o Manufacturer
o Model
o Year of Manufacture
o Engine Capacity
o Number of Doors
o Color
o Gear (Automatic or Manual)
o Number of Gears
o Drive Position (Left or Right Hand Drive)
o Number of Seats
o Type of Fuel (Petrol, Diesel, Electric, Hybrid)
o Fuel Capacity
o Fuel Consumption
o Max Speed
o Engine State (On/Off)
o Current Speed
20
20
10
11/12/2024
21
21
22
22
11
11/12/2024
Note that:
- The attributes of an object are closely related to the application of the
software that the object is part of.
- For example, the attributes of a car is different in “Car Rental Software”
when compared to a “Car Sales Software” or a “Car Gaming Software”.
- The attributes are named as variables are named in a program
- The attributes are also mapped to data structures supported by a
programming language
- The first alphabet of Class names are written in Upper case. This is a
common convention used by all programmers.
- The first alphabet of Objects and Class members (attributes and behavior)
are written in Lower case. This is a common convention used by all
programmers.
23
23
State of an Object
• An object’s state is defined by the value of its attributes.
• For Example:
• The state of myCar changes depending on the following attributes:
• engineState :Boolean
• currentSpeed :float
• myCar could be in a state that the engine is On and speed is 0
• myCar could be in a state that the engine is On and speed is 40
• myCar could be in a state that the engine is Off and speed is 0
• myCar CANNOT be in a state that the engine is Off and speed is 40
24
24
12
11/12/2024
State of an Object
• An object’s state is defined by the value of its attributes.
25
25
Class Activity
• Students can work in groups.
26
26
13
11/12/2024
Class Behaviors
• A behavior is an action that retrieves or changes the state of an object.
• A behavior provides the means for interaction with the object
• A behavior is also called a function or method.
• Example: Some behaviors of myCar
• getManufacturer() returns a String
• getNumberOfDoors() returns an int
• getEngineState() returns a Boolean
• getCurrentSpeed() returns a float
27
28
28
14
11/12/2024
Example
29
29
Class Activity
• Students can work in groups.
30
30
15
11/12/2024
Encapsulation
• “enclosing something in” or “as if in a
capsule”. get
or() Eng
C ol ine
set Sta
te()
• An object encapsulates the attributes,
setC
)
behaviors, and the state of a real- Manufacturer
or (
world entity. Toyota
C ol
urre
get
ntSp
Number of Gears Model
ee
…
the attributes or data are hidden
d()
inside the object and is accessible via Doors
Current Speed
the behaviors or functions.
get
45.5
rs()
4
Ma
oo
Type of Fuel
nu
D
Color
• This concept is also understood as
No
Petrol
fac White
Information Hiding.
get
tu
rer
()
- In other words, the data is accessible get
Ge a pC ar()
only through the functions. r() sto
31
31
Data Hiding
32
32
16
11/12/2024
Abstraction
• It is the concept of removing certain attributes from something in
order to reduce it to only essential characteristics.
• For example:
• The myCar object does not describe all the details of a real-world car.
• Functions like the engine’s working or the shifting of gears are not included.
• The object abstracts only those functions and attributes that are required for the context
of the software being built.
33
33
Abstraction
34
34
17
11/12/2024
In Summary
• The Object Oriented (OO) Paradigm
• Managing Software Complexity
• The Object and its Class
• Attributes and Behaviors
• Encapsulation & Information Hiding
• Abstraction
35
35
18