Mit-2020-Sam - 271-364
Mit-2020-Sam - 271-364
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
1
9/16/2020
277 278
279 280
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
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.
289 290
System concepts for object modeling System concepts for object modeling
291 292
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 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
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
System concepts for object modeling System concepts for object modeling
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
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
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
323 324
9
9/16/2020
325 326
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
335 336
11
9/16/2020
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
<<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
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
process
checkOverdue( ) getOverdueDetails ( )
Activity Diagram :
• A diagram that shows the flow from
checkOverlimit( )
informBorrowedCopy( )
345 346
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
<<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
StudentOptions.exe StudentOptions.exe
353 354
14
9/16/2020
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
363 364
16