ProQuest Business Solutions Copyright 2006 Database Advance Concepts OOP & UML - Part II (Object-Oriented Programming & Unified Modeling Language) Joseph, Johns Date: 08/25/2006
ProQuest Business Solutions Copyright 2006
Database Advance Concepts
OOP & UML - Part II(Object-Oriented Programming & Unified Modeling Language)
Joseph, Johns
Date: 08/25/2006
© 2006 Proquest Business Solution. All Rights Reserved. confidential and proprietary information.
Training Expectations
Object-Oriented Programming and UML Group 1 (TK, AD, AM, AM2, RA)
12– Refresh OOPs terminology
– OOAD tools;
– Practical Application; Usage of correct OOPs technique
– Refresh UML Basics and how is it used in OOAD
Group 2 (PG,Abhi, SM,VR,NS,PraM)
14– 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 Group 3 (PC, VV, NK, KRS, RajeRas,AK)
12– 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
Group 4 (PJ,PG,HH,AS)
10– 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 – Follow up
Assignment Total
Group 1
Tarun K, Ananya D, Ashish M, Anuradha M, Rajesh A
12 7 5 10 34
Group 2
Priyaranjan G, Abhishek S, Shishir M, Vishal R, NS, Prabeer M
14 5.5 5 12 36.5
Group 3
Paras C, Vivek V, Neeraj K, KRanjan S, Rajesh R, Amit K
12 4 3 12 31
Group 4
Paritosh J, Piyush G, Harish H, Amit S
10 7.5 17.5
© 2006 Proquest Business Solution. All Rights Reserved. confidential and proprietary information.
Prize - Group 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 - Group 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 2000
© 2006 Proquest Business Solution. All Rights Reserved. confidential and proprietary information.
Agenda
Contents– Last Session Doubts (20 Min)
– Modeling and UML (15 Min)
– UML Advantages and Usages (10 Min)
– Phillip Krutchen’s View Model (10 Min)
– UML History (10 Min)
– UML 1.x and 2.0 diagrams (120 Min)
– Quiz (30 Min)
– Summary (10 Min)
© 2006 Proquest Business Solution. All Rights Reserved. confidential and proprietary information.
Last Session Doubts
Q. Does Managed C++ (MC++) has same features as that of C++ ?
Yes. 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
Q. Managed C++ in Windows environment, is there a GC at OS level ?
No. Use of .NET framework’s GC
© 2006 Proquest Business Solution. All Rights Reserved. confidential and proprietary information.
Last Session Doubts
Q. 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.
Last Session Doubts
Q. Internal access specifier – is it within assembly or namespace ?
Within a project or an assembly Can be accessed across namespace within a project. Identified by Root
namespace
Q. Pointers in C# ?
Yes. Syntax
– Int *p or int* p
– int x; &x;
– *p;
© 2006 Proquest Business Solution. All Rights Reserved. confidential and proprietary information.
Quiz 1 (Pointer in C#) – 1 minute
What are the values stored in x and p at BP1 and BP2 ?
unsafe void unsafeFunction()
{
int x = 5;
int* p;
p = &x;
*p = 10;
}
C#
Breakpoint 1
Breakpoint 2
BP1x=5
p=address of xBP2 x=10 p=address of x
© 2006 Proquest Business Solution. All Rights Reserved. confidential and proprietary information.
Last Session Doubts
Q. 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 20 more tools
– Costs $ 500 – $ 10,000
© 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 Reduction 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 Requirement – The system needs to be large with four legs and a trunk
© 2006 Proquest Business Solution. All Rights Reserved. confidential and proprietary information.
UML – 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 Leading object oriented modelers
– 15 years of lessons learnt and refinement
© 2006 Proquest Business Solution. All Rights Reserved. confidential and proprietary information.
UML - Usage
Usage As a sketch
– To convey key points
– Throwaway sketches As a blueprint
– Not disposable
– Generated with a UML 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.
UML - 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
– What 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.
UML - History
Identifiable OO modeling languages began between mid 70 and late 80s Chaos and Confusion
– Modeling languages increased from 10 to 50 (’89-’94) Method Wars
– Primary protagonists – Grady Booch, Ivar Jacobson, James Rumbaugh
– Grady Booch – OOAD (Best known for class notation)
– Ivar Jacobson – OOSE (Best known for use case notation)
– James Rumbaugh – OMT (Best known for class and object diagram notation) 1996
– UML 0.9 and 0.91 documents released in June and October 1996 1997
– UML 1.0. Given to OMG as initial RFP 1997 Fall
– UML 1.1
– Later minor version – 1.3, 1.4, 1.5 2004-5
– UML 2.0 More ??
© 2006 Proquest Business Solution. All Rights Reserved. confidential and proprietary information.
UML - Diagrams
Diagram Type Introduced in UML Version
Remarks
Use Case UML 1.x Behavior Diagram
Activity UML 1.x Behavior Diagram
Class UML 1.x Structure Diagram
Object UML 1.x Structure Diagram. Informal introduction
Sequence UML 1.x Interaction Diagram
Communication UML 2.0 Interaction Diagram. 1.x’s Collaboration Diagram
Timing UML 2.0 Interaction Diagram
Package UML 2.0 Structure Diagram
Component UML 1.x Structure Diagram. New meaning in UML 2.0
State Machine UML 1.x Behavior Diagram. 1.x’s State-chart Diagram
Deployment UML 1.x Structure Diagram
© 2006 Proquest Business Solution. All Rights Reserved. confidential and proprietary information.
Use Case
Main View (Use Case View) Specify Functional Requirement
– What the system is supposed to do
Example– Requirement A.1
– 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 Remark
Use case description detail What the detail means and why it is useful
Related Requirements 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 What needs to happen before the use case can be executed.
Successful End Condition What the system's condition should be if the use case executes successfully.
Failed End Condition What 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
Related Requirements 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
– Requirement A.2
– The content management system shall allow an administrator to create a new personal Wiki, provided the personal details of the applying author are verified using the Author Credentials Database.
Include Relationship– Reuse of a Use Case
© 2006 Proquest Business Solution. All Rights Reserved. confidential and proprietary information.
Use Case - Relationship
Inherit Relationship– Reuse of a Use Case with small change
Extend Relationship– 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.
Quiz 2 (Use Case) – 2 minutes
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
UML 2.0
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
– Guard
– Fork Transition
– Join 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 / Receive Signal
© 2006 Proquest Business Solution. All Rights Reserved. confidential and proprietary information.
Quiz 3 (Activity Diagram) – 2 minutes
Which of the following pseudo code implements the activity diagram above?
UML 2.0
Option A, F
B. If (!OK) then
do C else
do A and B do D
A. If (OK) then
do Celse
do A and B do D
C. If (OK) then
do C else do A or B do D
D. If (OK) then do C else do A do B do D
E. If (OK) then do C else do A and B If (OK) do D
F. If (OK) then do C else do A as well as B 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 Relationships
Dependency Relationship– Short duration
– May require a change
Association Relationship– Longer duration
© 2006 Proquest Business Solution. All Rights Reserved. confidential and proprietary information.
Class Diagram - Relationship
Aggregation Relationship– Stronger association
– Class actually owns but may share
Composition Relationship– More Stronger
– “Part Of” relationship
Generalization Relationship– 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.
Quiz 4 (Class Diagram) – 2 minutes
Every student at TS College will be advised by one teacher. Some teachers advise many students, and some advise none. Which of the following class diagrams most clearly represents that student-teacher relationship?
UML 2.0
Option B
A. B.
C. D.
© 2006 Proquest Business Solution. All Rights Reserved. confidential and proprietary information.
Package
Part of Development View Group Related Elements in UML
– Equivalent to Namespaces
Example
Dependency– Import (Public)
– Access (Private Import)
© 2006 Proquest Business Solution. All Rights Reserved. confidential and proprietary information.
Quiz 6 (Package) – 2 minutes
A, B, C and D packages can access packages of what all other packages based on the following package diagram?
UML 2.0
Package AB, C
Package BC, D
Package CNone
Package DNone
© 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.
Quiz 5 (Object Diagram) – 2 minutes
Which 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.
UML 2.0
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.
Quiz 7 (Sequence Diagram) – 2 minutes
Which of the following pieces of sequence diagrams represents this action:
"Object A sends object B several messages named msg."?
UML 2.0
Option D
A. B.
C. 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.
UML – Sequence Vs. Communication
Features Sequence Communication
Show participants effectively Good Better
Showing the links between participants Bad Better
Showing message signatures Good Good
Easy to read message ordering Better Good
Use Sequence if mainly interested in interactions Use Communication if mainly interested in links among the participants
© 2006 Proquest Business Solution. All Rights Reserved. confidential and proprietary information.
Quiz 8 (Communication Diagram) – 2 minutes
Which 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.
UML 2.0
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 Real-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. Loggers, XML Parser, Shopping List
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
entry/Display In Scheduling Administrator's Inbox; Assigned automatically to user if only one user in Roleexit/Display in Account Holder's Sent Box
NewAppointment Request
entry/Review Request
Pending
Take ownership
Review Request
Rejected Schedule
entry/Scheduling Admin Sent Boxexit/Account Holder's Inbox
Approved
/ Escalated to Defined Role
/ Escalated to Defined Role
entry/Scheduling Admin Sent Boxexit/Account Holder's Inbox
Rejected
entry/Scheduling Admin Sent Boxexit/ Account Holder's Inbox
eConsultation
Suggest eConsultation
Cancel Cancel Appointment approved
© 2006 Proquest Business Solution. All Rights Reserved. confidential and proprietary information.
Quiz 9 (State Machine Diagram) – 2 minutes
Which 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).
UML 2.0
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
• J2EE
© 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.
UML – Diagram Summary
Diagram Type Introduced in UML Version
Remarks
Use Case UML 1.x Behavior Diagram
Activity UML 1.x Behavior Diagram
Class UML 1.x Structure Diagram
Object UML 1.x Structure Diagram. Informal introduction
Sequence UML 1.x Interaction Diagram
Communication UML 2.0 Interaction Diagram. 1.x’s Collaboration Diagram
Timing UML 2.0 Interaction Diagram
Package UML 2.0 Structure Diagram
Component UML 1.x Structure Diagram. New meaning in UML 2.0
State Machine UML 1.x Behavior Diagram. 1.x’s State-chart Diagram
Deployment UML 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#Visio2003
UML 2.0 Compliant Tools– http://www.uml.org/#Links-UML2Tools
• Artisan
• IBM Rational Software Architect and Modeler
• Sun Java Studio Enterprise
• I-Logix Rhapsody
• Borland Together ControlCenter
OMG Certified UML Professional– http://www.omg.org/uml-certification/frequently_asked_questions.htm
OMG– http://www.omg.org/
– http://www.uml.org/ UML 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.
Questions and Answers
The marks SYNCATA CORPORATION, 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..