0% found this document useful (0 votes)
11 views16 pages

Mit-2020-Sam - 271-364

software engineering

Uploaded by

nawamini85
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)
11 views16 pages

Mit-2020-Sam - 271-364

software engineering

Uploaded by

nawamini85
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/ 16

9/16/2020

MASTER OF INFORMATION TECHNOLOGY


MASTER OF INFORMATION TECHNOLOGY
MIT 1204 Exploring OOAD and Development
• To write any piece of software you need to do
three things.
• OO Analysis - Understand – (What)
• OO Design - Plan – (How)
• OO Programming - Build

Systems Analysis and Modelling


Lecture 5
Prof. Kapila. Dias 2020
UNIVERSITY OF COLOMBO SCHOOL OF COMPUTING

272

System concepts for object modeling System concepts for object modeling
• A problem can be divided into subjects.
• We understand the real world through ideas
• Subjects are used as logical divisions for development of large that are organized in to recognizable patterns
systems
• Each subject is generally considered as a problem domain
and concepts.
• Concepts can be divided into following types :
Tangible - book
Subjects eg. Airport Management System Roles - doctor
Relational - marriage
Radar control Baggage Handling Passenger Intangible - time, quality
Processing
Judgmental - good pay
Event - Purchase, loan

273 274

System concepts for object modeling System concepts for object modeling

• In the real world interaction of these concepts allow complex • Classes


operations to be performed. • Represent the concepts that are to be modeled.
Library System
Core Concepts - Borrowing, Returning of books, Book registration, • Initial Step in OOA is the identification of Actors, Use
cases, classes (Problem Domain).
Member registration (Use Cases)
Category • Library System: identify Use Cases-Borrowing books,
Concepts - Member, Copy, Book (Classes) returning of books , registration of Books in a library
system
* He knows certain facts - eg. Name
address etc. • Classify type of expected users (Actors) of the system
* Also perform certain activities ( Librarian, Member etc.)
• Classes in a library system - Book, Copy,
Member etc. (problem Domain Classes)
Instance of a
Member Concept
276
275

1
9/16/2020

System concepts for


System concepts for object modeling
object modeling
• Objects (Instances of Classes) • Attributes and Services
• Something that is or is capable of being seen, touched, or • By examine the descriptions/documents given
otherwise sensed and about which users store data and by the users, event type concepts (Scenarios)
associate behavior can be identified
• Types of objects • Attributes : The data that represents
• Person – e.g. employee, customer, instructor, student characteristics of interest about an object.
• Place – e.g. warehouse, building, room, office • Services : The set of things that an object can
• Thing – e.g. product, vehicle, computer, videotape do and that correspond to functions that act
• Event – e.g. an order, payment, invoice, application on the object’s data or attributes.
• Sensual – e.g. phone call, meeting

277 278

System concepts for System concepts for object modeling


object modeling Objects

• Attributes and Services


eg. Library System Borrowing of Books
e.g. Class WashingMachine
Main Actions Return of Books
Reservation of Books Attributes brandName
modelName
Each Action Involves with Pool of Objects serialNumber
Each Class offer (Instance of a Class) capacity
* Various Services
addClothes()
* Contains information reflected as Attributes Services addDetergent()
removeClothes()

279 280

System concepts for object modeling


System concepts for object modeling

• A principle used to derive attributes and services


* What the specific concept knows ?
- attributes
* What are the responsibilities of a class ?
- services
Services operate when they are involved through message
connections.
Student knows how to draw a rectangle
but he will not draw unless somebody ask
him to draw
Another example : TV and Remote

281 282

2
9/16/2020

System concepts for object modeling System concepts for object modeling

• Abstraction • Inheritance
• A mechanism to reduce and filter out details so • The concept wherein methods and/or attributes
that one can focus on a few concepts at a time. defined in a class can be inherited or reused by
Focus on Essentials another class.
• Filter out an object’s properties and operations e.g. some individuals in the room might be classified
until just the ones you need are left. as STUDENTS and TEACHERS. Thus, STUDENT and
Ignore the irrelevant. Ignore the unimportant. TEACHER classes are members of the class PERSON
eg. Book – Bookshop you bought

283 284

System concepts for object modeling System concepts for object modeling

• Inheritance
e.g. Cont…
• Generalization / Specialization
• A technique wherein the attributes and behaviors that
are common to several types of classes are grouped /
abstracted into their own class called a supertype.
• The attributes and methods of the supertype class are
then inherited by those classes (subtype)
• Sometimes abbreviated as gen/spec.

285 286

System concepts for object modeling UML Representation of Generalization/Specialization

Generalization Specialization
Student
GPA firstName
Classification lastName
Person
birthdate
firstName enroll gender
lastName displayGPA walk
birthdate Inheritable
Attributes
+ jump
gender Teacher talk
And
walk sleep
behavior rank
jump
talk
sleep lecture

287 288

3
9/16/2020

System concepts for object modeling System concepts for object modeling

Polymorphism
• the concept that different objects can respond to
• Generalization / Specialization the same message in different ways.
• It allows different forms of the same service to be
Vehicle defined.
Person
• Sometimes an operation has the same name in different
classes.
eg. You can open a door, you can open a window, or a
Bus Car Truck bank account. In each case, you are performing a different
Student Teacher operation.

* Specialized classes inherits from the parent class

289 290

System concepts for object modeling System concepts for object modeling

• Polymorphism • Polymorphism - Function(Method) Overloading


• In object-orientation, each class “knows” how that
operation is supposed to take place. In some programming languages,
• This is polymorphism. function overloading or method
• Related terms used in OO programming language overloading is the ability to create
multiple functions of the same name
Function Overloading, with different implementations.
Operator Overloading,
Method Overriding

291 292

System concepts for object modeling


System concepts for object modeling
Polymorphism – Operator Overloading
Polymorphism
• In languages like C++, we can change the way operators work for
Overriding – a technique
user-defined types like objects and structures. This is known as
whereby a subclass
operator overloading.
(subtype) uses an
attribute or behavior of • Suppose we have created three objects c1, c2 and result from a
its own instead of an class named Complex that represents complex numbers.
attribute or behavior • we can redefine how the + operator works and use it to add the
inherited from the class complex numbers of c1 and c2 by writing the following code:
(supertype). result = c1 + c2;
instead of something like
result = c1.addNumbers(c2);

293 294

4
9/16/2020

complex operator+(complex&);
Operator Overloading in C++
•Definition of the operator is like a member
class complex function, except the operator symbol is prefixed
{ by the keyword operator.
float real,imag;
public : complex operator+(complex&); complex complex::operator+(complex &a)
complex() { } //default constructor {
complex(float r, float s) // constructor complex z; int main()
{ real=r; imag=s;} z.real=real+a.real; {
void printcomplex( ) z.imag=imag+a.imag; complex var1(1.2,3.4), var2(4.5,6.5), outc;
{ return z; outc=var1+var2;
std::cout<<”Real component=”<<real<<’\n’; } outc.printcomplex();
std::cout<<”Imaginary component=”<<imag; }
} Sample Output :
}; Real component = 5.7
gkad 295 gkad 296
Imaginary component = 9.9

System concepts for object System concepts for object modeling


modeling
• Encapsulation
• Encapsulation When an object carries out its operations, those operations are hidden.
• Packaging of several items together into one unit (both attributes and
behavior of the object), Also protects the contents.
E.g. When most people watch a television show,
• The only way to access or change an object’s attribute is through that - they usually don’t know or care about the complex
object’s specific behavior. electronics that sit in back of the TV screen
• Objects encapsulates what they do. - or the operations that are happening.
The TV hides
• That is, they hide the inner workings of their operations
its operations
• from the outside world Eg. Class BankAcount from the
• and from other objects { person
Private: Balance watching it.
………
Withdraw(int)
Deposit(int)
297 298
}

System concepts for object modeling System concepts for object modeling
Encapsulation

• Encapsulation
Why is this important?
• In the software world, encapsulation helps cut down on
the potential for bad things to happen.
• In a system that consists of objects, the object depends
on each other in various ways.
• If one of them happen to malfunction, software
engineers have to change it in some way.
• Hiding its operations from other objects means it
probably won’t be necessary to change those other
objects.

299 300

5
9/16/2020

System concepts for object modeling System concepts for object modeling

• Encapsulation
• Encapsulation • An object hides what it does from other objects
• Turning from software to reality, you see the and from outside world
importance of encapsulation.
• But an object does have to present a “face“ to
the outside world, so you can initiate those
eg. Your computer monitor, hides its
operations from your computers CPU. operations.
When something goes wrong with your monitor, eg. A TV, has a set of buttons either on
you either fix or replace it.
You probably won’t have to fix or replace the the TV or on a remote.
CPU along with it. The TV’s buttons are called interfaces.

301 302

System concepts for object modeling System concepts for object modeling
Encapsulation

• Encapsulation
• Encapsulation is done through the definition of region of
access.
• Region of access defines the accessibility of the services or
attributes in a class.
•In C++ (OO programming Language)
• 3 types of access regions: private, public, protected
•In Java
• Access modifiers: default, public, private, protected,
• Static modifier, final modifier, synchronized modifier,
native modifier

303 304

Access to the Base Class


System concepts for object modeling
Class shape
public private protected Message – communication that occurs when one object
invokes another object’s method (behavior) to request
information or some action
Class rectangle_shape : public shape

public private protected

Class rounded_rectangle_shape
: public rectangle_shape
public private protected
305 306

6
9/16/2020

System concepts for object modeling System concepts for object modeling

• Message Passing • Message Passing


• In a system, objects work together. • When you want to watch a TV show,
• You hunt round for a remote,
• They do this by sending messages to one
• Settle into your favorite chair and
another. • Push the On Button.
• One object sends another a message to • What happens?
perform an operation. • The remote object sends a message (literally!) to the
TV object to turn itself on.
• The receiving object performs that operation. • The TV object receives the message.
eg. A TV and a Remote • It knows how to perform the turn-on operation, and
turns itself on.
307 308

System concepts for object modeling System concepts for object modeling

• Message Passing • Message Passing


• When you want to watch a different channel, • Let’s go back to interfaces for a moment.
• You click the appropriate button on the remote, • Most of the things you do from the remote, you
• Remote object sends a different message change can also do by getting out of the chair, going to the
channel to the TV object. TV, and clicking buttons on the TV.
• The remote can also communicate with the TV via • The interface the TV presents to you is obviously
other messages for changing the volume, muting not the same interface it presents to the remote.
the volume etc..

309 310

System concepts for object modeling System concepts for object modeling
• Each object offers services within the realm of its
responsibility.
Object B • Relationships
Object A
MI MI MI MI • A natural business association that exists
Service B1 between one or more objects and classes
Service A1 Service B2
Service A2 e.g. You interact with a text book by reading it,
with a telephone by using it, People interact with
* Objects use other objects services through message each other by communicating with them.
passing
* An object may even call its own services

311 312

7
9/16/2020

System concepts for object modeling System concepts for object


modeling
• Association • Association
• When you turn on your TV, in object oriented terms, e.g.
you are in an association with your TV.
• An association is unidirectional (one way) or bi- A CUSTOMER PLACES zero or more ORDERS
directional (two way). An ORDER IS PLACED BY one and only one CUSTOMER
eg. is married to
• Some times an object might be associated with
another in more than one way.
Gihan is a co-worker of Damith 1 Places 0..*
Customer Order
Gihan is a friend of Damith
Represent the
relationship
between the objects

313 314

UML Multiplicity
System concepts for object modeling Notations
Multiplicity – the
• Multiplicity minimum and
• The minimum and maximum number of occurrences of maximum number
one object class for a single occurrence of the related
object class. of occurrences of
e.g. Exactly one -> 1 one object/class
Zero or 1 -> 0..1 for a single
Zero or more -> 0..* or * occurrence of the
1 or more -> 1..* related
Specific range -> 7..9 object/class.

315 316

System concepts for object modeling System concepts for object modeling

• Aggregation • Aggregation (Removed in UML 2.x)


• A relationship in which one larger “whole” class
some more examples…
contains one or more smaller “parts” classes.
Conversely, a smaller “part” class is part of a
“whole” larger class. Aircraft 0..* 0..*
Engine
e.g. A club – a club is made up of several club UML notation
members
0..* 12..18
A computer – a computer contains a case, Team Player
CPU, motherboard, power supply …etc. Whole object Part Objects

317 318

8
9/16/2020

System concepts for object modeling System concepts for object modeling

• Composition
• Composition • Drawn with a filled diamond.
• An aggregation relationship in which the “whole” 1 1..*
is responsible for the creation and destruction of School Department
its “parts”.
• If the “whole” were to die, the “part” would die Each “part” can belong to only one “whole”,
with it. therefore, multiplicity needs to be specified
• A stronger form of aggregation. only one for the “whole”
• The relationship between club and club
member would not be composition, because Components will live and die with the whole
members have a life out-side the club and can, object
belong to multiple clubs.
319 320

Composition
Another Example of Composition

321 322

Introduction to Object Modelling Introduction to Object Modelling

Object-oriented analysis (OOA) – an approach used


• Object oriented languages (Java & C++,C#) are to
growing in popularity. 1. study existing objects to see if they can be reused or
• Because object oriented programming adapted for new uses
• can promote better code reuse to hold down program costs 2. define new or modified objects that will be combined
• More appropriate for projects where with existing objects into a useful business computing
• geographically separated groups of programmers have application
to collaborate to produce an integrated system and
• each team can develop pieces of programming code Object modeling – a technique for identifying
independently objects within the systems environment and the
relationships between those objects.

323 324

9
9/16/2020

Introduction to Object Modelling Introduction to Unified Modeling


Language (UML)
• Some of the object oriented diagrams, such
as class and sequence diagrams would be • One of the most exciting and useful tools in the
inappropriate except when the system will be world of system development
implemented in an OO environment • A visual modeling language
• Other diagrams developed for OOAD can be • Enables system builders to create blueprints that
used in any kind of environment capture their visions in a standard, easy-to-
understand way
• e.g. Use cases
• Provides a mechanism to effectively share and
communicate these visions with others (Technical or
Non technical)

325 326

Introduction to Unified Modeling UML Inputs


Language (UML)

Booch Rumbaugh Jacobson


• It most directly unifies the methods of
• Booch, Odell
Mayer
Pre and post
classification
• Rumbaugh (OMT) and UML conditions
Shlaer-Mellor Harel
• Jacobson Object life cycles State charts

as well as the best ideas from a number of Gamma et al Wirfs-Brook


Frameworks, Responsibilities
other methodologies. Patterns,
Embly
Fusion
Singleton
notes Operation descriptions
classes
Message numbering

327 328

UML History
Introduction to the UML
• The first public draft version – (version 0.8) – Oct 1995
• Feedback from public and Ivor Jacobson’s inputs included –
(ver. 0.9 Jul 1996, ver. 0.91 Oct 1996)
Unified Modeling Language (UML) – a • Ver 1.0/1.1 was presented to OMG group for
set of modeling conventions that is used standardization in July/Sep 1997.
to specify or describe a software system in • Nov 1997 – UML adopted as the standard modelling
language by OMG
terms of objects. • Ver 1.2 - June 1998
• Ver 1.3 – Dec 1998
• The UML does not prescribe a method
• Ver 1.4 – 2000
for developing systems—only a notation • Ver 2.0 – 2003
that is now widely accepted as a standard • Ver 2.1 – 2007
for object modeling. • Ver 2.2 - 2009
• Ver 2.3 – 2010,
• Ver 2.4 –Jan 2011
• Ver 2.5 June 2015
329 330

10
9/16/2020

UML
Components and Capabilities UML Diagrams
• The UML consists of a number of graphical • UML has 14 types of diagrams divided into two
elements that combine to form diagrams.
categories.
• Because it is a language, the UML has rules for
combining these elements. - Structure Diagrams :
• Lets look at the diagrams before looking at the Seven diagram types represent structural
elements and rules. You will be using these
diagrams to do systems analysis and design.
information,
• The purpose of the diagrams is to present -Behaviour Diagrams :
multiple views (model) of a system. other seven represent general types of behavior..
• UML 2.* include many different diagrams.

331 332

UML Diagrams
Context Models

• Context models are used to illustrate the


operational context of a system
• they show what lies outside the system
boundaries.
• Use Case Diagram can be used to represent a
Context model for a system.
• There is no single diagram in UML that would
map to the definition
333 334

Context Models UML Diagrams

• UML include many different diagrams.


Class Diagrams :
• Shows set of classes, interfaces, and
collaborations and their relationships.
• Most common diagram found in modelling
object-oriented system.
• Address the static view of a system.
class: a category or group of things that have
the same attributes and the same behaviours.

335 336

11
9/16/2020

UML Diagrams UML Diagrams

Object Diagrams :
• Models actual object instances with current
attribute values.
• Shows a set of objects and their
relationships.
• Provides a snap shot of the system’s
objects at one point in time.
Class Diagram (UML 1.*)
e.g. School =Faculty
337 338

UML Diagrams
UML Diagrams
Object Diagram Use Case Diagrams :
e.g.
Is being attacked by • Shows a set of use cases and actors and their relationships.
thisWhiteQueen:Queen thisBlackKnight:Knight • A tried-and-true technique for gathering information.
• Graphically describes who will use the system and in what
ways the user expects to interact with the system.
Is strategically positioned against

thisWhitePawn:Pawn

339 340

UML Diagrams UML Diagrams

<<extend>>
Use Case Diagram
Request Catalogue
State Diagrams :
Order Processing
Place Order
<<Communicate>> <<Include>> • Shows a state machine consisting of states,
Arrange Payment
transitions, events and activities.
Order Generalization • Models how events can change the state
Clerk
Generalization of an object over its lifetime,
Arrange Credit
Pay Cash • show both the various states of an object
and the transactions between those states.

342
341

12
9/16/2020

UML Diagrams
UML Diagrams

State Diagrams
e.g. Course Registration Sequence Diagrams:
Add student[ count < 10] ]] • An Interaction diagram that emphasizes the
Add Student / time-ordering of messages.
Initialization Set count =0 00
do: Initialize course Openn

entry: Register student


• Graphically depicts how objects interact with
exit: Increment count
each other via messages in the execution of a
Cancel
use case or operation.
Cancel
Cancel [ count = 10] ]
• Illustrates how messages are sent and received
do: Notify registered students Closed between objects and in what sequence.
Cancel do: Finalize course

343 344

UML Diagrams
Sequence Diagrams UML Diagrams
e.g. book borrowing
a borrowing A borrower : A borrowed copy A copy : copy A book : book
: librarian form borrower : borrowedCopy

Enter Borrower IdcheckBorrowerExis t( )

process
checkOverdue( ) getOverdueDetails ( )
Activity Diagram :
• A diagram that shows the flow from
checkOverlimit( )

Enter copy id checkBorrowable( )


activity to activity within a system.
getBookDetails( )

• Address the dynamic view of a system.


confirm borrowing informBorrower( )

informBorrowedCopy( )

345 346

UML Diagrams UML Diagrams


Activity Diagram
Communication Diagrams :
• An interaction diagram that emphasizes the
structural organization of the objects that send
and receive messages.
• Depicts the interaction of objects via messages.
• Also known as collaboration diagram in UML
1.X.

347 348

13
9/16/2020

UML Diagrams
Communication Diagrams : e.g. UML Diagrams
1: Enter borrower id
2: checkBorrowerExist( )
3: process
4: checkOverdue( )
7: Enter copy i d
6: checkOverli m it( )
11: confirm borrowi ng borrowing 12: i nform Borrower( )
form

a borrower :
borrower
Component Diagram :
: l ibrari an
5: getOverdueDetails( )
• Shows the organizations and dependencies
13: i nform BorrowedCopy( )
among a set of components.
8: checkCopyExist( )
10: checkBorrowabl e( ) • Address the static implementation view of a
a borrowed copy : a book :
borrowedCopy book system.

9: getBookDetai ls( )

a copy :
copy

349 350

UML Diagrams Component Diagrams in UML 1.* and 2.*


<<EXE>>
Lecturer
Options
Component Diagrams
e.g. (UML 1.4 Notation)

<<DLL>> CoursesAPI
Courses

351 352

UML Diagrams
UML Diagrams

Deployment Diagram
Deployment Diagram
Registration
• Shows the configuration of run time processing Database
Server
nodes and the components live on them.
• Shows the physical architecture of a computer
based system. LecturerOptions.exe

• It can show computers, their connections with


one another, and show the software that sits
on each machine. Main
Building
Library

StudentOptions.exe StudentOptions.exe

353 354

14
9/16/2020

UML Diagrams UML Diagrams

Composite Structure Diagrams : Interaction Overview Diagrams :


• New in UML 2.0.
• Decomposes the internal structure of a class.
• New in UML 2.0.
• Replace some of the activities in the activity
• A diagram which shows something about the class’s
internal structure. diagram with sequence / communication
e.g. diagrams (or a combination of the two)
• Shows how objects interact within each
PERSON
activity of a use case.

Mind Body

355 356

Interaction
Overview Diagram UML Diagrams
UML Diagrams
e.g.
:User :LibraryDatabase Timing Diagrams :
Find book find()
goToLocation() • New in UML 2.0.
• A diagram which shows how long an
Borrow book :User :Librarian object is in a particular state.
processCheckOutRequest()
takeBook() • Specially useful when designing
embedded software for devices.
Leave library
:User :Guard
verifyCheckOut()

exitLibrary()

357 358

UML Diagrams
UML Diagrams
Timing Diagram : e.g.
:WashingMachine
Spinning
Package Diagrams:
Rinsing
• A diagram which combines a number of classes or
Washing components into a subsystem
Soaking

0 5 10 15 20 25 30 35

359 360

15
9/16/2020

Package Diagram
UML Diagrams e.g. Package in a Package Diagram

UML Diagrams

361 362

UML Diagrams UML Diagrams

Profile Diagram • Profile Diagram eg.


Describes lightweight extension mechanism to the UML
Profiles allow adaptation of the UML metamodel for
different:
• platforms (such as J2EE or .NET), or
• domains (such as real-time or business process
modeling).

363 364

16

You might also like