0% found this document useful (0 votes)
16 views18 pages

SDF - Week 16

The document discusses Software Development Fundamentals, focusing on the Object Oriented Paradigm and its importance in managing software complexity. It covers key concepts such as encapsulation, abstraction, and the structure of classes and objects, along with methodologies like the Waterfall and Agile approaches. Additionally, it highlights the significance of a good software model and the challenges of requirement elicitation in software development.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views18 pages

SDF - Week 16

The document discusses Software Development Fundamentals, focusing on the Object Oriented Paradigm and its importance in managing software complexity. It covers key concepts such as encapsulation, abstraction, and the structure of classes and objects, along with methodologies like the Waterfall and Agile approaches. Additionally, it highlights the significance of a good software model and the challenges of requirement elicitation in software development.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 18

11/12/2024

Software Development Fundamentals


Week 16

Dr. Loubna Mekouar

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

The Object Oriented Paradigm


Encapsulation & 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

• The impact of reducing software complexity is paramount in terms of


cost and also reducing the effort of building software.

• Many times, it is even life saving, because these software control real-
world systems.
6

3
11/12/2024

Software Complexity -- Problems


- No clear understanding of how all the functionalities of a software fit
together. The programmer keeps writing code and fixes it on the fly.

- Lack of interoperability between software components, which are


many times built by different people and maybe with different design
models.

- Software is not built to be reused. Every time a functionality is


required the software component has to be created from scratch.

Good Model Reduces Software Complexity


• A major reason for software complexity is the difficulty in
understanding the software model which represents a software
system [1].
• Having a good software model helps to translate ideas
(requirements) into working programs (software)
• It also helps to easily change/update software based on new
requirements
• A model that is easy to understand is also easier to use and
maintain, which reduces the likelihood of introducing errors when
creating or updating it.

[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

The Waterfall Approach

The Agile Approach

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

• How to reduce the impact of


change on software?

• How to connect the requirements


to the actual implementation?

• How to ensure scalability?

12

12

6
11/12/2024

OO Software Design

13

13

Managing Software Complexity


• An unambiguous representation (modelling notation and
programming language) with precise semantics eases software
creation.
• For this course we use,
• UML Class Diagrams as a notation to model ideas and requirements
• Python programming language to create working programs/software

• The approach to building software can be either:


• Top-Down: The “Divide and Rule” or “Algorithmic Decomposition” concept
looks at breaking down requirements into smaller functions.
• Bottom-Up: The approach pieces together smaller units to give rise to the
larger systems. In a bottom-up approach the smaller parts of the system are
first specified in great detail.
14

14

7
11/12/2024

Object Oriented Programming (OOP)


• Complex scenarios are easily modelled and programmed
using Object Oriented (OO) concepts
• Object Oriented Programing (OOP) uses the Bottom-Up
approach.

• In OOP, small independent units of the software known


as Objects are first created.
• Objects are the building blocks of the software

• A program or software is created by the collection of


interacting Objects.

• Examples of OOP Languages: C++, Python, Java,


Smalltalk, C#

15

15

The Object and its Class


• A Class is the template of an object. It is used to model objects for
implementing a software
• Example: Student, Musical instrument, Fruit, Car

• An Object in a software context, is a uniquely identifiable


representation of a real-world entity. It has attributes and behaviors
• Example: Samir, Guitar, Apple, Toyota Camry

• An Object is an instance of a Class


• Samir is an instance of a Student
• A guitar is an instance of a Musical instrument
• An apple is an instance of a Fruit
• A Toyota Camry is an instance of a Car

16

16

8
11/12/2024

Class Diagram

17

17

UpperCamelCase

18

18

9
11/12/2024

Attributes and Behaviors


• Consider a car, a real-world entity that needs to be represented in a
software.
• Let’s say the car is, a 2017 model Toyota Camry
• For our software let’s call the car, myCar
• Therefore, myCar is a software object that identifies my real-world car

• To use it in a software, we define a class that would represent myCar.


• Let’s call the class, Car
• Therefore, myCar is an instance of Car

• 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

An Object – Instance of a Class


• An instance of the class Car is myCar
• myCar is an object that has at-least these attributes
o Manufacturer - Toyota
o Model - Camry
o Year of Manufacture - 2017
o Engine Capacity - 2.4
o Number of Doors -4
o Color - Blue
o Gear - Automatic
o Number of Gears -6
o Drive Position - Right
o Number of Seats -3+2
o Type of Fuel - Petrol
o Fuel Capacity - 60.0
o Fuel Consumption - 10 (Km/L)
o Max Speed - 200 (Km/Hr)
o Engine State (On/Off) - Off
o Current Speed -0
• What would be the data types of the attributes listed above?

21

21

Attributes of Class - Car


• manufacturer :String • Toyota
• model : String • Camry
• yearOfManufacture :Date • 2017
• bodyType : String • Sedan
• engineNumber :String • AX1839930S8920
• engineCapacity :float • 2.4
• numberOfDoors :int • 4
• color : String • White
• gear : String • Automatic
• numberOfGears :int • 6
• drivePosition : String • Right
• numberOfSeats :String • 3+2
• typeOfFuel : String • Petrol
• fuelCapacity :float • 60.0
• fuelConsumption :String • 10 Km/L
• maxSpeed :float • 200
• engineState :Boolean • False (Off)
• currentSpeed :float • 0.0

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

• The state myCar is determined by the changes to the attributes.


• The value of the attributes are modified using the behaviors of the object

24

24

12
11/12/2024

State of an Object
• An object’s state is defined by the value of its attributes.

- Note: State can be of two types.


• Passive state refers to state which does not change.
• Active state refers to the state which changes the behavior of the
object
- For example, attributes like Model and Manufacturer does not change
and hence does not change the behavior of myCar object. These
contribute to passive state.
- While, changes to attributes like Current Speed, and Engine State
changes the behavior of myCar.

25

25

Class Activity
• Students can work in groups.

• Discuss and write the attributes of the class: Student


• Identify at-least 20 attributes
• Include the data types that represent the attributes
• Use proper notations, e.g.
• name: string,
• age: int

• Consider universityStudent to be an object of the above class


• Notations:
• Classes start with capital letters
• Attributes and Behavior start with small letters
• Objects (class instances) start with small letters

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

• setEngineState(Boolean) starts myCar


• setCurrentSpeed(float) sets the speed of myCar to 45 Km/Hr.
• setColor(String) sets the color of myCar to Black

• Setter Methods or Mutator Methods


• Getter Methods or the Accessor Methods
27

27

Behavior, Functions, or Methods


• Other than the setter and getter methods, the object will also have
other functions, to represent real-world actions.
• Example, for myCar, we could have functions like:
• checkRemainDistance(float, float): float
• Calculate remaining distance based on remaining fuel, and current speed. The function
returns the distance which is a float value
• turnLeft(float) : Boolean
• the car turns left at a certain angle, and the function returns True or False
• turnRight(float) : Boolean
• the car turns right at a certain angle, and the function returns True or False
• stopCar() : Boolean
• the car stops and the function returns True or False
• accelerate(float) : Boolean
• the car increases speed at a certain value, and returns True or False

28

28

14
11/12/2024

Example

29

29

Class Activity
• Students can work in groups.

• Discuss and write down the behaviors of the class: Student


• For all the attributes identified earlier, write down the associated setter methods
(mutator) and getter methods (accessor)
• Include the data types that represent the attributes
• Use proper notations

• Consider universityStudent to be an object of the above class


• Notations:
• Classes start with capital letters.
• Attributes and Behavior start with small letters.
• Objects (class instances) start with small letters.

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

• The state of an object represented by 5 Camry

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.

• Abstraction simplifies the understanding and use of complex systems


by hiding information that is not relevant to context of the software.
• It reduces complexity and increases efficiency

• 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

You might also like