Sie sind auf Seite 1von 60

Database Advance Concepts

OOP & UML - Part II


(Object-Oriented Programming & Unified Modeling Language)

Goseph, Gohns

| 
   

Date: 08/25/2006  
Training Expectations
Object-Oriented Programming and UML
‰  roup 1 (TK, AD, AM, AM2, RA)
·
å efresh OOPs terminology
å OOAD tools;
å Practical Application; Usage of correct OOPs technique
å efresh UML Basics and how is it used in OOAD

‰  roup 2 (P ,Abhi, SM,VR,NS,PraM)


·
å Practical Application
å Practitioner¶s experience in OOPs usage
å UML
Use Case realization
How to identify classes from UC
Discuss Case Study

Ñ 2006 Proquest Business Solution. All Rights Reserved. confidential and proprietary information.
Training Expectations
Object-Oriented Programming and UML
‰  roup 3 (PC, VV, NK, KRS, RajeRas,AK)
·
å Practitioner¶s experience in OOPs usage; How OOPs helps in design
å Advanced OOPs (Abstraction, shadowing, sealed, static, message passing, delegates,
virtual functions, events)
å Disadvantage of OOPs
å History of OOPs; How is it changing
å UML
How to use in a new project
Prerequisites to use UML

‰  roup 4 (PG,P ,HH,AS)
·
å Practical usage; When to use and when not to use OOPs
å Estimation based on OOPs
å Adv and Disadv of OOPs
å Interface vs. abstract class
å UML
Would it simply application design
Tool that keep Model and Code synchronized

Ñ 2006 Proquest Business Solution. All Rights Reserved. confidential and proprietary information.
Team Scores

Team Part I Part II Part II ± Assignment Total


Follow up
Group · 12 7 5 10 34
Tarun K, Ananya D, Ashish
M, Anuradha M, Rajesh A
Group 14 5.5 5 12 36.5
Priyaranjan  , Abhishek
S, Shishir M, Vishal R,
NS, Prabeer M
Group 3 12 4 3 12 31
Paras C, Vivek V, Neeraj
K, KRanjan S, Rajesh R,
Amit K
Group  10 7.5 17.5
Paritosh G, Piyush  ,
Harish H, Amit S

Ñ 2006 Proquest Business Solution. All Rights Reserved. confidential and proprietary information.
Prize -  roup I

‰ Practical usage of OOPs with


UML. Establishes a good link
between design and code.
‰ Use of Case Studies
‰ Published by TMH

Ñ 2006 Proquest Business Solution. All Rights Reserved. confidential and proprietary information.
Prize -  roup II

‰ Elaborates on how to move from


Code-Driven process to Model-
Driven process
‰ Published by Pearson Education
‰ Based on whitepaper published
by OMG in 

Ñ 2006 Proquest Business Solution. All Rights Reserved. confidential and proprietary information.
Agenda

‰ Contents
å ast Session Doubts (  Min)
å Modeling and UM (· Min)
å UM Advantages and Usages (· Min)
å Phillip Krutchen¶s View Model (· Min)
å UM History (· Min)
å UM 1.x and 2.0 diagrams (·  Min)
å uiz (3 Min)
å Summary (· Min)

Ñ 2006 Proquest Business Solution. All Rights Reserved. confidential and proprietary information.
ast Session Doubts
?. Does Managed C++ (MC++) has same features as that of C++ ?

‰ les.
‰ And more ..
å Both managed and unmanaged code can be written in the same file
å Best performance among all generated IL code
å Access to GC pointers
å Good language to use if one has to work on existing C++ code

?. Managed C++ in Windows environment, is there a GC at OS level ?

‰ No.
‰ Use of .NET framework¶s  C

Ñ 2006 Proquest Business Solution. All Rights Reserved. confidential and proprietary information.
ast Session Doubts

?. C++ stack/heap details ?

‰ All objects go to stack


å My_class my_object(arglist);
‰ All pointers go to heap
å My_class* my_objptr = new My_class(arglist);
‰ Stack are short-lived
å Destroyed when control goes out of inner most compound statement
‰ Heaps are long lived
å Destroyed using delete keyword
å Memory leak due to loss of pointer or forgetting to clear the heap

Ñ 2006 Proquest Business Solution. All Rights Reserved. confidential and proprietary information.
ast Session Doubts
?. Internal access specifier ± is it within assembly or namespace ?

‰ âithin a project or an assembly


‰ Can be accessed across namespace within a project. Identified by Root
namespace

?. Pointers in C# ?

‰ les.
‰ Syntax
å Int *p or int* p
å int x; &x;
å *p;

Ñ 2006 Proquest Business Solution. All Rights Reserved. confidential and proprietary information.
uiz 1 (Pointer in C#) å 1 minute
u
‰ âhat are the values stored in x and p at BP1 and BP2 ?

unsafe void unsafeFunction()


{
int x = ;
int* p;
p = &x;

 
 BP1
*p = ·; x=5
 
 p=address of x
} BP2
x=10
p=address of x

Ñ 2006 Proquest Business Solution. All Rights Reserved. confidential and proprietary information.
ast Session Doubts
?. Are there good tools to keep the model and code integrated ?

‰ Referred as Round-trip engineering


‰ http://www.objectsbydesign.com/tools/umltools_byProduct.html
‰ Tools
å Component Architect by SBS for C++, Java
å Enterprise Architect Professional for VB.NET, C#, C++
å Around  more tools
å Costs $  ± $ ·,

Ñ 2006 Proquest Business Solution. All Rights Reserved. confidential and proprietary information.
Modeling

What is Modeling?
‰ Simplification of the real system which allows both the design and
viability of a system to be understood, evaluated and criticized.

Advantages
‰ Abstract the essential details and manages complexity
‰ Document and communicate better
‰ Helps in visualization of the problem and its solution
‰ eduction of cost in rework

What is Modeling Language ?


‰ Made up of pseudo-code, actual code, pictures, diagrams, or long
passages of description
‰ Contains notation ± the way to express the model
‰ Contains meta model ± what the notation means

Ñ 2006 Proquest Business Solution. All Rights Reserved. confidential and proprietary information.
Modeling

Verbosity and Ambiguity in Informal Modeling Language


‰ Natural Language Description ± The system needs to be large with four
legs and a trunk

Ñ 2006 Proquest Business Solution. All Rights Reserved. confidential and proprietary information.
Modeling

Formal Modeling Language Clarity


‰ equirement ± The system needs to be large with four legs and a trunk

Ñ 2006 Proquest Business Solution. All Rights Reserved. confidential and proprietary information.
UM å Advantages

UML ± Unified Modeling Language

Advantages
‰ Formal Language
å Each element is strongly defined. No ambiguity
‰ Concise and comprehensive
å Simple and straightforward notations
å Covers all aspect of a system
‰ Scaleable
å Can handle projects of massive complexity to less complexity
‰ Built on Lessons learnt
å Culmination of best practices in object oriented community
å Contributed by eading object oriented modelers
å 15 years of lessons learnt and refinement

Ñ 2006 Proquest Business Solution. All Rights Reserved. confidential and proprietary information.
UM - Usage
Usage
‰ As a sketch
å To convey key points
å Throwaway sketches
‰ As a blueprint
å Not disposable
å  enerated with a UM Tool
‰ As a programming language
å Every aspect of the system is modeled
å Model kept indefinitely for code generation and transformation

UML Applicability in different Lifecycles


‰ Waterfall
å Rarely used
‰ Iterative
å Ranges from sketch to blueprint
‰ Agile (Iteration in very short bursts)
å As a sketch
Ñ 2006 Proquest Business Solution. All Rights Reserved. confidential and proprietary information.
UM - Philippe Kruchten's 4+1 view model
UML Diagrams can be viewed in different views
‰ Use Case View
å Describes what the system supposed to do
å All other view depended on this. Hence 4+1
å E.g. Use Case Diagram, UC Description etc.
‰ Process View
å Describes processes in the system
å E.g. Activity Diagram
‰ Logical View
å Abstract system description
å âhat a system is made of and how they interact
å E.g. Class, Object, State Machine and Interaction Diagram
‰ Development View
å Describes how system parts are organized å modules, components
å E.g. Package and Component Diagram
‰ Physical View
å Describes how system design comes into life as set of real world entities
å E.g. Deployment Diagram
Ñ 2006 Proquest Business Solution. All Rights Reserved. confidential and proprietary information.
UM - History
‰ Identifiable OO modeling languages began between mid 7 and late 8s
‰ Chaos and Confusion
å Modeling languages increased from 10 to 50 (¶89-¶94)
‰ Method Wars
å Primary protagonists å  rady Booch, Ivar Gacobson, Games Rumbaugh
å  rady Booch å OOAD (Best known for class notation)
å Ivar Gacobson å OOSE (Best known for use case notation)
å Games Rumbaugh å OMT (Best known for class and object diagram notation)
‰ ·
å UM 0.9 and 0.91 documents released in Gune and October 1996
‰ ·7
å UM 1.0.  iven to OM  as initial RFP
‰ ·7 Fall
å UM 1.1
å ater minor version å 1.3, 1.4, 1.5
‰ -
å UM 2.0
‰ More ??
Ñ 2006 Proquest Business Solution. All Rights Reserved. confidential and proprietary information.
UM - Diagrams

Diagram Type Introduced in emarks


UML Version
Use Case UM 1.x Behavior Diagram

Activity UM 1.x Behavior Diagram


Class UM 1.x Structure Diagram
Object UM 1.x Structure Diagram. Informal introduction
Sequence UM 1.x Interaction Diagram
Communication UM 2.0 Interaction Diagram. 1.x¶s Collaboration Diagram
Timing UM 2.0 Interaction Diagram

Package UM 2.0 Structure Diagram


Component UM 1.x Structure Diagram. New meaning in UM 2.0
State Machine UM 1.x Behavior Diagram. 1.x¶s State-chart Diagram
Deployment UM 1.x Structure Diagram

Ñ 2006 Proquest Business Solution. All Rights Reserved. confidential and proprietary information.
Use Case
‰ Main View (Use Case View)
‰ Specify Functional equirement
å âhat the system is supposed to do
‰ Example
å equirement A.·
å The content management system shall allow an administrator to create a new blog
account, provided the personal details of the new blogger are verified using the author
credentials database
‰ A good use case should
å Provide measurable result to the user or external system
å Should help construct test cases
‰ Use Case Diagram Elements
å Actor
å System Boundary
å Use Case

Ñ 2006 Proquest Business Solution. All Rights Reserved. confidential and proprietary information.
Use Case Description

Section emark

Use case description detail What the detail means and why it is useful

elated equirements Some indication as to which requirements this use case partially or completely fulfills.

Goal In Context The use case's place within the system and why this use case is important.

Preconditions âhat needs to happen before the use case can be executed.

Successful End Condition âhat the system's condition should be if the use case executes successfully.

Failed End Condition âhat the system's condition should be if the use case fails to execute successfully.

Primary Actors The main actors that participate in the use case.

Secondary Actors Actors that participate but are not the main players in a use case's execution.

Trigger The event triggered by an actor that causes the use case to execute.

Main Flow The place to describe each of the important steps in a use case's normal execution.

Extensions A description of any alternative steps from the ones described in the Main Flow.

Ñ 2006 Proquest Business Solution. All Rights Reserved. confidential and proprietary information.
Use Case Description å Example
Section Details
Use case name Create a new Blog Account

elated equirements Requirement A.1.

Goal In Context A new or existing author requests a new blog account from the Administrator.

Preconditions The system is limited to recognized authors and so the author needs to have appropriate
proof of identity.
Successful End Condition A new blog account is created for the author.

Failed End Condition The application for a new blog account is rejected.

Primary Actors Administrator.

Secondary Actors Author Credentials Database.

Trigger The Administrator asks the CMS to create a new blog account.

Main Flow Step Action

1 The Administrator asks the system to create a new blog account.

2 The Administrator selects an account type.

3 The Administrator enters the author's details.

4 The author's details are verified using the Author Credentials Database.

Extensions 4.1 The Author Credentials Database does not verify the author's details.

Ñ 2006 Proquest Business Solution. All Rights Reserved. confidential and proprietary information.
Use Case - Relationship
‰ May find repetition of behavior in some use cases
‰ Example
å equirement A.
å The content management system shall allow an administrator to create a new
personal âiki, provided the personal details of the applying author are verified using
the Author Credentials Database.
‰ Include elationship
å Reuse of a Use Case

Ñ 2006 Proquest Business Solution. All Rights Reserved. confidential and proprietary information.
Use Case - Relationship
‰ Inherit elationship
å Reuse of a Use Case with small change

‰ Extend elationship
å Reuse of a Use Case
å Optional reuse

Ñ 2006 Proquest Business Solution. All Rights Reserved. confidential and proprietary information.
Use Case å Another Example
‰ Healthcare Domain

Ñ 2006 Proquest Business Solution. All Rights Reserved. confidential and proprietary information.
uiz 2 (Use Case) å 2 minutes
a 
‰ Three items of interest in use case diagrams are:
å A. Objects, activities, and communications
å B. Actors, messages, and activities
å C. Use Cases, actors and system boundaries
å D. Objects, use cases and activities
å E. Actors, use cases and communications

Option C,E

Ñ 2006 Proquest Business Solution. All Rights Reserved. confidential and proprietary information.
Activity Diagram
‰ Part of Process View
‰ How system accomplish its goals

‰ Activity Diagram Elements


å Initial State
å Action State
å Transition
å  uard
å Fork Transition
å Goin Transition
å Final State
å Swim lanes

Ñ 2006 Proquest Business Solution. All Rights Reserved. confidential and proprietary information.
Activity Diagram å Example

Ñ 2006 Proquest Business Solution. All Rights Reserved. confidential and proprietary information.
Activity Diagram åEvents
‰ Time Event

‰ Send Signal / eceive Signal

Ñ 2006 Proquest Business Solution. All Rights Reserved. confidential and proprietary information.
uiz 3 (Activity Diagram) å 2 minutes
a 

‰ âhich of the following pseudo code implements the activity diagram above?
A. B. C. D.
If (OK) then If (!OK) then If (OK) then If (OK) then
do C do C do C do C
else else else else
do A and B do A and B do A or B do A
do D do D do D do B
do D
E. F.
If (OK) then If (OK) then
do C do C
else else
do A and B do A as well as B Option A, F
If (OK) do D
do D
Ñ 2006 Proquest Business Solution. All Rights Reserved. confidential and proprietary information.
Class Diagram
‰ Part of Logical View
‰ Identifies classes and its relationships
‰ Elements of Class Notation

‰ Class Element Visibility

‰ Multiplicity

Ñ 2006 Proquest Business Solution. All Rights Reserved. confidential and proprietary information.
Class Diagram
‰ Public Visibility

‰ Private Visibility

Ñ 2006 Proquest Business Solution. All Rights Reserved. confidential and proprietary information.
Class Diagram
‰ Package Visibility

‰ Protected Visibility

Ñ 2006 Proquest Business Solution. All Rights Reserved. confidential and proprietary information.
Class Diagram - Relationship
‰ Class elationships

‰ Dependency elationship
å Short duration
å May require a change

‰ Association elationship
å onger duration

Ñ 2006 Proquest Business Solution. All Rights Reserved. confidential and proprietary information.
Class Diagram - Relationship

‰ Aggregation elationship
å Stronger association
å Class actually owns but may share

‰ Composition elationship
å More Stronger
å Part Of´ relationship

‰ Generalization elationship
å Reuse of another class and its extension
å Type Of´ relationship

Ñ 2006 Proquest Business Solution. All Rights Reserved. confidential and proprietary information.
Class Diagram å Aggregation Vs. Composition

‰ Aggregation Vs. Composition


å Movie can exist without Theatre, but usually theatre owns it
å Box Office can¶t exist without Theatre

Ñ 2006 Proquest Business Solution. All Rights Reserved. confidential and proprietary information.
Class Diagram å Example

Ñ 2006 Proquest Business Solution. All Rights Reserved. confidential and proprietary information.
uiz 4 (Class Diagram) å 2 minutes
a 
‰ Every student at TS College will be advised by one teacher. Some teachers
advise many students, and some advise none. âhich of the following class
diagrams most clearly represents that student-teacher relationship?

A. B.

C. D.

Option B

Ñ 2006 Proquest Business Solution. All Rights Reserved. confidential and proprietary information.
Package
‰ Part of Development View
‰ Group elated Elements in UML
å Equivalent to Namespaces
‰ Example

‰ Dependency
å Import (Public)
å Access (Private Import)

Ñ 2006 Proquest Business Solution. All Rights Reserved. confidential and proprietary information.
uiz 6 (Package) å 2 minutes
a 
‰ A, B, C and D packages can access packages of what all other packages based
on the following package diagram?

Package A
B, C
Package B
C, D
Package C
None
Package D
None
Ñ 2006 Proquest Business Solution. All Rights Reserved. confidential and proprietary information.
Object Diagram

‰ Part of Logical View


‰ Brings life to the class diagram
‰ Class Diagram Vs. Object Diagram
å Class Diagram å identifies all classes and its relation
å Object Diagram å represents system of object at some particular time

Ñ 2006 Proquest Business Solution. All Rights Reserved. confidential and proprietary information.
uiz 5 (Object Diagram) å 2 minutes
a 
‰ âhich of the following statements is/are correct?

å A. In object diagrams, names of instances are in italics or all-caps.


å B. In object diagrams, names of instances are in italics and underline is a must.
å C. Classes in class diagrams may be grouped into packages in order to
illustrate the overall organization of a model.
å D. If package B depends on package A, then any change in A will require a
change in B.
å E. If package B depends on package A, then any change in B might require a
change in A.
å F. Object diagrams and class diagrams are completely interchangeable.

Option C

Ñ 2006 Proquest Business Solution. All Rights Reserved. confidential and proprietary information.
Sequence Diagram
‰ Part of Logical View
‰ Part of Interaction Diagram Group
‰ Models important interactions between parts

‰ Messaging

Ñ 2006 Proquest Business Solution. All Rights Reserved. confidential and proprietary information.
Sequence Diagram - Example
‰ Example

Ñ 2006 Proquest Business Solution. All Rights Reserved. confidential and proprietary information.
uiz 7 (Sequence Diagram) å 2 minutes
a 
‰ âhich of the following pieces of sequence diagrams represents this action:
"Object A sends object B several messages named msg."?

A. B.

C. D.

Option D

Ñ 2006 Proquest Business Solution. All Rights Reserved. confidential and proprietary information.
Communication Diagram
‰ Part of Logical View
‰ Another perspective of Sequence Diagram
‰ Models important interactions between objects

‰ Messaging

Ñ 2006 Proquest Business Solution. All Rights Reserved. confidential and proprietary information.
UM å Sequence Vs. Communication

‰ Use Sequence if mainly interested in interactions


‰ Use Communication if mainly interested in links among the
participants

Features Sequence Communication

Show participants effectively  ood Better

Showing the links between participants Bad Better


Showing message signatures  ood  ood
Easy to read message ordering Better  ood

Ñ 2006 Proquest Business Solution. All Rights Reserved. confidential and proprietary information.
uiz 8 (Communication Diagram) å 2 minutes

a 
‰ âhich of the following statements is/are correct?

å A. Communication diagrams are dynamic models.


å B. Sequence numbers in communication diagrams are optional.
å C. Sequence numbers in communication diagrams are mandatory.
å D. Communication diagrams do not show iteration since that is a low-level
implementation detail.
å E. Communication diagrams cannot show when an object sends itself a
message.
å F. Communication diagrams can show when an object sends itself a message.

Option A, C, F

Ñ 2006 Proquest Business Solution. All Rights Reserved. confidential and proprietary information.
Timing Diagram
‰ Part of Logical View
‰ Describes the state of objects in different time
‰ Used for eal-time applications
å That support all the functionality with time constraints
å Responds timely predictable way in unpredictable situations
å E.g. Fly-by-wire application, anti-lock braking system

Ñ 2006 Proquest Business Solution. All Rights Reserved. confidential and proprietary information.
Component Diagram
‰ Part of Logical View
‰ Describes the reusable components and their links
‰ Components
å Reusable
å Manageable
å Replaceable
å E.g. oggers, XM Parser, Shopping ist
‰ Example

‰ Component Ports

Ñ 2006 Proquest Business Solution. All Rights Reserved. confidential and proprietary information.
Component Diagram - Example
‰ Example

Ñ 2006 Proquest Business Solution. All Rights Reserved. confidential and proprietary information.
State Machine Diagram
‰ Part of Logical View
‰ Shows possible states and their transition
‰ Called as State chart diagram in earlier versions
‰ State Machine Diagram Elements
å State
å Trigger
å Transition
‰ State Conditions
å Active
å Passive
‰ Trigger Guard
å Active
å Passive
‰ State Internal Behavior

Ñ 2006 Proquest Business Solution. All Rights Reserved. confidential and proprietary information.
State Machine Diagram - Example

MN Om PQmRSmP

Ñ 2006 Proquest Business Solution. All Rights Reserved. confidential and proprietary information. m 

m9

uiz 9 (State Machine Diagram) å 2 minutes

a 
‰ âhich of the following statements about state machine diagram is/are correct?
å A. All actions in a statechart diagram are attached to transitions.
å B. An event may cause an object to remain in the same state it was prior to the
event.
å C. Once an object leaves a state, it cannot return to that state.
å D. Two different transitions out of the same state may overlap (they can be
triggered by the same event).

Option B

Ñ 2006 Proquest Business Solution. All Rights Reserved. confidential and proprietary information.
Deployment Diagram
‰ Part of Physical View
‰ Describes physical elements such as
å Software Files
å Hardware
å Firmware
å OS

‰ Node
å Hardware or software resource that can host software or related files
å Hardware Node
Server
Disk Drive
å Environment Node
OS
G2EE

Ñ 2006 Proquest Business Solution. All Rights Reserved. confidential and proprietary information.
Deployment Diagram - Example
‰ Example

Ñ 2006 Proquest Business Solution. All Rights Reserved. confidential and proprietary information.
UM å Diagram Summary

Diagram Type Introduced in emarks


UML Version
Use Case UM 1.x Behavior Diagram

Activity UM 1.x Behavior Diagram


Class UM 1.x Structure Diagram
Object UM 1.x Structure Diagram. Informal introduction
Sequence UM 1.x Interaction Diagram
Communication UM 2.0 Interaction Diagram. 1.x¶s Collaboration Diagram
Timing UM 2.0 Interaction Diagram

Package UM 2.0 Structure Diagram


Component UM 1.x Structure Diagram. New meaning in UM 2.0
State Machine UM 1.x Behavior Diagram. 1.x¶s State-chart Diagram
Deployment UM 1.x Structure Diagram

Ñ 2006 Proquest Business Solution. All Rights Reserved. confidential and proprietary information.
Reference

‰ Visio Stencil Download


å http://www.phruby.com/stencildownload.html#Visio 3
‰ UM 2.0 Compliant Tools
å http://www.uml.org/#Links-UML Tools
Artisan
IBM ational Software Architect and Modeler
Sun Java Studio Enterprise
I-Logix hapsody
Borland Together ControlCenter
‰ OM  Certified UM Professional
å http://www.omg.org/uml-certification/frequently_asked_questions.htm
‰ OM 
å http://www.omg.org/
å http://www.uml.org/
‰ UM 2.0 by O¶Rielly
‰ http://www.objectsbydesign.com/tools/umltools_byProduct.html (round-trip
engineering)

Ñ 2006 Proquest Business Solution. All Rights Reserved. confidential and proprietary information.
uestions and Answers

The marks SYNCATA COPOATION, SYNCATA and all related product or services names design marks and slogans are the trademarks and
service marks of Syncata Corporation and may not be used in any manner without the prior written consent of Syncata Corporation. Any
unauthorized use of these marks in any context may constitute a violation of Federal trademark, trade dress and unfair competition laws.
With respect to all or any portion of this publication, you may not reproduce, distribute, modify, display or prepare derivative works based on
this publication or cut, copy, past or forward this publication to anyone, without the express prior written consent of Syncata Corporation..
Ñ 2006 Proquest Business Solution. All Rights Reserved. confidential and proprietary information.

Das könnte Ihnen auch gefallen