You are on page 1of 58

Software Engineering

Fundamentals
CSC-2073
Lecture No. 33
Dr. Muhammad Adeel
Department of Computer Science
National Textile University

dr.muhammad.adeel.ntu@gmail.com
Last Lecture Review

 Design Principles
– Information Hiding
– Incremental Development
o Fan-in
o Fan-out
– Abstraction
o Functional Abstraction
o Data Abstraction
– Generality

2 Software Engineering - CSC2073


Agenda – What will you Learn Today?

Object Oriented Design

3 Software Engineering - CSC2073


Function Oriented vs. OO Design

4 Software Engineering - CSC2073


Function Oriented Design

 Data is decomposed according to functionality


requirements
 Decomposition revolves around function

F1 F2 F3 F4

DS1 DS2 DS3 DS4

5 Software Engineering - CSC2073


Object-Oriented Design

 OO paradigm focuses both on the


functionality and the data at the same time

6 Software Engineering - CSC2073


Why Object Oriented Design?

 Object-Oriented technology helps in software


modeling of real life objects in a direct and
explicit fashion

 Encapsulate data and processes related to a


real life object or process in a single software
entity

7 Software Engineering - CSC2073


Why Object Oriented Design?

 It also provides a mechanism so that the


object can inherit properties from their
ancestors, just like real-life objects

 An Object-Oriented software system consists


of objects which are:
‒ Hierarchical
‒ Highly Cohesive
‒ Loosely Coupled

8 Software Engineering - CSC2073


OO Design Components

9 Software Engineering - CSC2073


What is Object?

 An object can be defined as a tangible entity


that exhibits some well defined behavior
 An object has:
Identity
State All of the properties of the object and their
current values
Behavior How an object acts and reacts in terms of
its state changes and message passing

10 Software Engineering - CSC2073


What is Class?

 A representation of a type of object

 A class is the blueprint from which the


individual objects are created

 Class is composed of three things:


- Name
- Attributes
- Operations

11 Software Engineering - CSC2073


What is Class?

 A class specifies an interface and defines an


implementation

 The interface consists of the declaration of all


the operations applicable to instances of this
class

 The implementation of a class consists of the


implementation of all the operations

12 Software Engineering - CSC2073


Class vs. Object

Class

Objects

13 Software Engineering - CSC2073


What is Class - UML Notation
Attributes Class Name

Student
Visibly - Name:string
+ public Return Type
- Discipline:string
- private - CGPA:float
# protected + takeClasses():Integer
~ package + getCourseRegister():String
+ prepareNotes():String

14 Software Engineering - CSC2073


Abstract Classes

 An abstract class Abstract Class


Name
implements an abstract
concept
 Main purpose is to be Attributes Vehicle
inherited by other classes - Color
+ Accelerate()
 An abstract class cannot be
instantiated
 If any class contains any Methods

abstract functions, then that


class is also abstract
15 Software Engineering - CSC2073
Abstract Classes

Vehicle
- Color
- Model
+ Accelerate()
+ ApplyBrakes()

Car Bus Truck

16 Software Engineering - CSC2073


Abstract Classes

Shape

+ Draw()

Line Circle Triangle

+ Draw() + Draw() + Draw()

17 Software Engineering - CSC2073


Interfaces

 Interfaces are much like abstract


Interface
classes Name
 Interface is a contract - a class
that implements it is required to <<interface>>
implement all of the methods IDoor
and properties + Open()
 No instances of interfaces can
be created Method
 In interfaces the definition of the
method is not allowed
18 Software Engineering - CSC2073
Why We Need Interfaces?

Vehicle

+ Door()
+ FillFuel()

Car

+ Reverse()

19 Software Engineering - CSC2073


Why We Need Interfaces?

?
??
Vehicle
gn
si
de

+ Door()
t

+ FillFuel()
ec
rr
co
it
Is

Car Motorcycle

+ Reverse() + TurnAround()

20 Software Engineering - CSC2073


Why We Need Interfaces?

Vehicle
<<interface>>
IDoor
+ Door()
+ Open() + FillFuel()

Car Motorcycle

+ Reverse() + TurnAround()

21 Software Engineering - CSC2073


Abstract Class vs. Interface

What is the difference between an interface and an


abstract class?

<<interface>> SomeVehicle
Door
+ Open() + drive()
+ open()
Interface
Abstract class

Non of them can be instantiated

Cannot contain implementation Can (but need not to) contain


implementation

22 Software Engineering - CSC2073


Recap

 Function Oriented vs. OO Design


 OO Design Components
‒ Class vs. Object
‒ Abstract Classes
‒ Interfaces

23 Software Engineering - CSC2073


Last Lecture Review

 Function Oriented vs. OO Design


 OO Design Components
‒ Class vs. Object
‒ Abstract Classes
‒ Interfaces

24 Software Engineering - CSC2073


Agenda – What will you Learn Today?

Object Oriented Design

25 Software Engineering - CSC2073


Relationship Among Classes

26 Software Engineering - CSC2073


Relationships Among Classes

 Association
 Aggregation
 Composition
 Inheritance

27 Software Engineering - CSC2073


Association

 It represents a linkage between two classes

 Associations are bi-directional i.e. both


classes are involved in a relationship

 The line is drawn from the containing to the


contained class

28 Software Engineering - CSC2073


Association - Example

Teacher Course
teaches
+ Salary():int * * + Salary():int
+ Leaves():int + Leaves():int
+ Medical():int + Medical():int

29 Software Engineering - CSC2073


Aggregation

 The relationship between the container and


the contained object is called aggregation

 Aggregation is “has - a” relationship

 A weak Association

 Aggregate object can exist independently

30 Software Engineering - CSC2073


Aggregation - Example

Car Wheel
4

31 Software Engineering - CSC2073


Aggregation - Example
Word
Processing
Document

* * Picture

*
Folder

32 Software Engineering - CSC2073


Aggregation - Example
Tables

1..6 White Board


Chair * Class

1
Multimedia

33 Software Engineering - CSC2073


Composition

 The relationship between the “part” objects


and the “whole” object is known as
Composition

 It’s a strong association

 It contains Objects that live and die together

 It is represented by a filled diamond shape


from child to parent class with association
34 Software Engineering - CSC2073
Composition

 The child class's instance lifecycle is


dependent on the parent class's instance
lifecycle

 The part class can only be related to one


instance of the parent class

35 Software Engineering - CSC2073


Composition - Example

Company Department
1 ..
*

36 Software Engineering - CSC2073


Composition - Example

Building

Room

37 Software Engineering - CSC2073


Composition - Example
Head

2 Person 2 Leg
Arm

1
Body

38 Software Engineering - CSC2073


Inheritance

 It implies the functionality of data sharing


between Base and Derived class

 All the data members and methods of base


class are available for use in derived class but
not vice-versa

 Derive class extends the functionality of super


class to use the base class methods

39 Software Engineering - CSC2073


Inheritance - Example
Person
- Name
- Age
- Gender
+ EatFood()
+ Walk()

Student Teacher
- Program - Designation
- StudyYear - Salary
+ Study() + TakeClasses()
+ HeldExam() + takeExam

40 Software Engineering - CSC2073


Inheritance - Example
Person
- Name
- Age
- Gender
+ EatFood()
+ Walk()

Student Teacher
- Program - Designation
- StudyYear - Salary
+ Study() + TakeClasses()
+ HeldExam() + takeExam

41 Software Engineering - CSC2073


Inheritance - Example
Person Doctor
- Name - Designation
- Age - Salary
- Gender
+ CheckUp()
+ EatFood()
+ Prescribe()
+ Walk()

Student Teacher
- Program - Designation
- StudyYear - Salary
+ Study() + TakeClasses()
+ HeldExam() + takeExam

42 Software Engineering - CSC2073


Inheritance - Example
Person
- Name
- Age
- Gender
+ EatFood()
+ Walk()

Student Doctor Teacher


- Program - Designation - Designation
- StudyYear - Salary - Salary
+ Study() + CheckUp() + TakeClasses()
+ HeldExam() + Prescribe() + takeExam

43 Software Engineering - CSC2073


Recap

 Relationship among Classes


1) Association
2) Aggregation
3) Composition
4) Inheritance

44 Software Engineering - CSC2073


Questions

45 Software Engineering - CSC2073


Last Lecture Review

 Relationship among Classes


1) Association
2) Aggregation
3) Composition
4) Inheritance

46 Software Engineering - CSC2073


Agenda – What will you Learn Today?

Abbot’s Textual Analysis Sequence Diagrams

47 Software Engineering - CSC2073


Announcement

 7th July 2021 (SRS)


 14th July 2021
(Design Document)
 28st July 2021
(Test Document)

Course Project Submission


48 Software Engineering - CSC2073
Abbot’s Textual Analysis

49 Software Engineering - CSC2073


Abbot’s Textual Analysis

 “Textual Analysis” is a working technique used


to extract model element information from
unstructured information systematically.”
 It was initially developed by Abbot and then
extended by Graham and others

 In this technique different parts of speech are


identified within the text of the specification
and these parts are modeled using different
components
50 Software Engineering - CSC2073
Abbot’s Textual Analysis

1) A common noun in the informal strategy


suggests a data type

2) A proper noun suggests an object

3) A verb, attribute, predicate, or descriptive


expression suggests an operator

4) The control structures are implied in a


straightforward way by the English
51 Software Engineering - CSC2073
Abbot’s Textual Analysis
Part of Speech Model Component Example
Proper Noun Instance, Object Ahmad
Common Noun Class, Type, Role Student, Teacher
Doing Verb Operation buy
Being Verb Classification is a horse, is a book
Having Verb Composition Fan has wings
Adjective Phrase Association, The customer with
Operation children.
The customer who
bought the Kite.
Intransitive Verb Exception or Event depend

52 Software Engineering - CSC2073


Abbot’s Textual Analysis - Example

 The customer enters the store to buy a toy. He


has to be a toy that his daughter likes and it
must cost less than 50 Euros. He tries a video
game, which uses a data glove and a head-
mounted display. He likes it. An assistant helps
him. The suitability of the game depends on the
age of the child. His daughter is only 3 years
old. The assistant recommends another type of
toy, namely the board game “Monopoly".

53 Software Engineering - CSC2073


Abbot’s Textual Analysis - Example

Example Part Of Speech UML Model


Component
“Monopoly” proper noun object
toy improper noun class
buy doing verb operation
recommend doing verb operation
is-a being verb inheritance
has-a having verb aggregation
must be modal verb constraint
dangerous adjective attribute
enter transitive verb operation
depends on intransitive verb constraint,
association

54 Software Engineering - CSC2073


Abbot’s Textual Analysis - Example
Customer Store

+ enter()

Daughter
- age

Videogame
suitable

Toy
- price
Boardgame +buy()
+ like()

55 Software Engineering - CSC2073


Interaction Diagrams

56 Software Engineering - CSC2073


Interaction Diagrams

 Interaction Diagrams depict the dynamic


behavior of the system

 A set of messages exchanged among a set of


objects

 Often used to model the way a use case is


realized through a sequence of messages
between objects

57 Software Engineering - CSC2073


Purpose of Interaction Diagrams

 Model interactions between objects

 Assist in understanding how a system (a use


case) actually works

 Verify that a use case description can be


supported by the existing classes

 Identify responsibilities/operations and assign


them to classes
58 Software Engineering - CSC2073

You might also like