Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
and
UML
( C to C++ Context)
Principles
of
Object
Orientation
Data 1
Data 2 Simple data
Compound
Data
Intialization Complex Data
and
other Function 1
functions Function 2
Maintenance
Lack of Flexibility in future releases
Accomodating Changes
during Project time
Re-Use of what is designed & coded
Make for one client. Adapt for others
Clear Demarcation of Responsibilities
between Members of Project
Team
File object f2 : ?
Report object r :
Knows report contents
File Object f1 File Object f2
Two month data
duly consolidated
Application Also formated for
W indow
Object w1
display
Report Object
r But no display code
Window object w1
Display characteristics
Font, color, size
User functions on
window
Minimize, close, move
Section : Objects
File Object f1
Data :
File Name
File Length
File Object f1
File Object f2
Window Object w
Which means,
Object instance occupies Memory ( RAM)
by providing slots for the fields
File length
Small or large file
File path
Where is it located ?
Object Orientation:
Care about Object States too.
Point to Ponder :
A file Object.
Empty,
5 records,
100 records,
200,000 records.
: Like close
FileName
FilePath
Length
File Object f1
Open
Close
Seek
Flush
Each Method
exhibits
One behaviour Collectively Methods provide the
Behaviour of the Object
Behavior is exhibited
when Method is executed
Code : How
How exactly does it happen
Algorithm
Business Logic body
Operation :
METHODS
OPERATIONS
BEHAVIOUR
CONTROLLER :
FIELDS ??
METHODS ????
Controller - Controlled
Controller - Controlled
: Boundary
object
( Presentation Role)
SOFTWARE OBJECT
OO SOFTWARE PROJECT
Section : Define
int age;
Unique ?
Has Field(s) ?
Hold State?
Exhibits Behaviour ?
Operations ?
Primitive types :
Primitive types :
Range
Type Bytes Range (signed) Literals
(unsigned)
false,
bool 1 0..1
true
char 1 -128..+127 0..255 'a'
short 2 -32,768..+32,767 0..65,535 none
Characters
Characters are stored in one byte (char) or two bytes wchar_t.
char is an integer type
Fields as required
Operations as needed
Objects are to be
CLASS
class X {
…..
…..
};
Seek(P1,P2):int{……………}
Creating Instance
Instance Creation
Instantiation
OO : Create
OOPS : Language specific creation
Student* p;
p = new Student(1002);
p->displayResult();
InLine Creation
Situation 1:
int main () {
Student s1;
Situation 2 :
Student s1;
// Created WHEREVER University Object is
created
// Embedded Object
….
};
Student Object
Student ;
Student ( 1021) ;
String name;
…..
public :
Student() …..
Student( int RollNo) { …}
Student ( string n ) : name(n) { … }
// Use Member initialization List , for
efficiency
….
};
Destructor ( or Finalizer )
class Student {
String* sp ;
…..
public :
Student() { sp = new String(….) ; }
Student( int RollNo) { …}
~Student ( ) { // Destructor
delete sp ;
}
};
{
Student s1;
// constructed, fairly
efficient
// Pass on messages to s1
} // s1 goes out of scope
// Very efficient stack
deallocation
{
Student* p;
p = new Student();
// Not the best of
performance
// Pass on messages to p
delete p ;
// Not so efficient
compared to stack de-alloc
// Block continues;
// do not pass messages to p
}
Service
open
close
seek
read
write
class SomeClient {
….
void someFunc () {
File f1 (….. ) ;
f1.open(…);
f1…..
f1.close( );
};
SomeClient s;
s.someFunc() ;
….
Accept Marks
Validating Behavior
Name
ID Design Fields only based on
Institution Method and its service
Course
Year First discover the Services
Subject 1 Mark
Subject 2 Mark
Exam Result
PrintedFlag
So in OO Software :
Objects are instantiated
data
data
creates
operations
Communication between
two entities
s1.displayResult();
or
r1.displayResult ();
or
p->displayResult () ;
Software Messaging is :
Communication between two entities
Window
File Object f1
Object w1 Message Passing
f1.open (..... )
f1.open(….)
Receiver Object :
1. Already knows its attribute and state values
Receiver Object
2. May use the parameter
3. Returns control,
plus result - if any.
If Student is a CLASS
II Using Attributes :
Can read them.
Can Change values.
r1.name=”XYZ"
r1.displayResult()
Alternate Design :
• The objects are not copied prior to the function call; their
addresses are passed. This can reduce the overhead of the
function call.
Better Design
So in OO Software :
Objects are instantiated
Object pass on Message to other Object(s)
Message is mapped to invoking Methods
Message Variations:
Interrupt, Signal, Event
Messaging Variations:
One-Way Message,
Time Out Message
INFORMATION HIDING
On / Off : Yes
Volume Control : YES
Potentiometer which control volume ?
Another Developer
};
ID Check
if ( ….. ID = p )
else …….
Why ?
FileName
FilePath
HIDE : Length
File Object f1
W hich M ethods Open Write
are to be Close Read
HIDDEN ? Seek
Flush
ChangeLength
You can declare another class as friend, which means all its
methods get access to private members of your class
Call these as
Access Specifiers
Or
Visibility Specifiers
DO not mistake
Visibility
with
Availability
Available ?
Visible ?
Usually private members are visible only to the code inside the
Class
READ and
WRITE
operations on them.
Hidden Attributes
Hidden Operations
= private methods
FileName
File Path
HIDE:LENGTH
File Object f1
Open
Close
Seek Write
Flush Read
ChangeLength
At suitable stage
in the DESIGN Phase
Hints to Design :
Encapsulation
Services : Methods
All methods :
Appropriate parameters
Appropriate return type
I. Unit Testing :
II. Maintenance :
#include<iostream.h>
class Player {
private:
public:
void setStrength( )
// this modifies the private member
// cannot be declared as const function
{ strength=12; }
{ return strength; }
};
void main()
{
Player p;
Player *ptr=&p;
Ptr->setStrength( );
Ptr->printStrength( );
}
ABSTRACTION means
a simplified representation
of real world objects and concepts.
Abstraction in Teaching :
Abstraction in Conceptualization :
Abstraction in Visualization :
Public Members :
Parameters :
Suggestive Names
Proper Coupling
A S/W Engineering Principle
enum COLORS {
BLACK,
Abstracted
Make it Simple
For the Client User
To Understand
Encapsulated
Encapsulation is
achieved when the
client of that Unit is not
able to know more
than what is required
to work with that Unit
Every Class
All these are
The Sub to be
System Each Abstracted
Thru
Encapsulation
d
Project
Properties
Properties are accessor methods whose job it is to retrieve and
set the values of fields. It provides a way to protect a field in a
class by reading and writing and also support object-oriented
concept of encapsulation.
C# specific
1. Overloading
2. Inheritance
POLYMORPHISM
POLY = Many MORPH = SHAPE
POLY = Polymorphism
Many Dynamic Static
Polymorphism Polymorphism
MORPH Overriding Overloading
= dispatch
SHAPE
Type polymorphism
Templates in C++
Generics – Java 1.5 , Dot Net 2.0
class Payslip {
};
Play is overloaded
Play ( Cricket )
Play ( Tennis )
Play ( Child )
A variable ( Attribute)
Cannot be overloaded
In function Examples :
overloading class X {
class Y {
The return type does
not matter, as long as int add ( int, int ) {...}
the above two rules float add ( float, float) {….}
are satisfied. X add ( X, X ) { … }
…
};
Student Object
Class : Payslip
Printslip ( Screen s )
Printslip ( Printer s )
Inheritance
A a1; B b1;
a1 = new A () b1 = new B ()
W orkAllow ance
Payslip
When is it destroyed ?
We do need a methodology
which can guide us through
the process of arriving
at a complete design.
DFD OOPS,
SSAD Non-UML
Methodologies
Non OOAD
Methodologies
OMT
Object Modeling
Technique
OOPS
James Rambaugh
OOAD
Methodologies
BOOCH
Grady Booch
Unification
By
Rational Corp
Objectory
OOSE
Iver Jacobson
• class diagram
• behavior diagrams :
• statechart diagram
• activity diagram
• interaction diagrams :
• sequence diagram
• collaboration diagram
• implementation diagrams :
• component diagram
StructureDiagram
BehaviourDiagram
ComponentDiagram
ClassDiagram PackageDiagram
InteractionDiagram
ComponentStructureDiagram
SequenceDiagram
InteractionOverviewDiagram
DeploymentDiagram
CollabrationDiagram
TimingDiagram
Architecture centric,
and iterative and incremental
USECASE
Speaker: Animesh S Client: Juniper
DRIVEN
APPROACH
An Use Case is
a broad area of functionality
of a system
Rank 0
Here we define the overall Goals
System
Level
UseCase
IDENTIFY ACTORS
( AS MANY AS POSSIBLE)
BE CLEAR ABOUT
THE OVERALL SCOPE
PROVIDE A
SUMMARY DESCRIPTION
OF THE SYSTEM
What is it based on ?
What is it based on ?
2. Many Actors :
Say :
In Use Case,
the line connects
Intiator
To the
Initiated
Primary Actor :
Directly interacts with the System
: Commuter
Secondary Actor :
Act on behalf of another Actor
: Operators
Software as Actor:
Another ( Client) Software
Comes in mostly for distributed Systems and in
simple client Server systems.
At System Level,
We are showing all these
scenarios
through a single line
( Uni-Directional Association)
between the
Actor and the
System.
SYSTEM XXX
ACTOR_B
Why does the Arrow go from Actor to the System ( Use Case ) ?
Significant Scenarios
Significant Scenarios
Scenarios are
instances of Use Cases.
A scenario is
a specific,
step-by-step sequence of
messages sent between
the actors and the system
A Scenario as conceived
from Actor View point
C om m u te r S ta rtin g J o u rn e y
E n d in g J o u rn e y
Note :
DESCRIPTION :
Ending Journe y
Describe it properly
Must be a multi-line Description
Complete Flow inside the System
is to be described as a Flow
Summarizing so far :
Scope
Limitation
Problem Domain
System
Level Rank 1
USeCase MOST IMPORTANT
BASELINE
of GENERIC
PROJECT MOST IMPORTANT
SCENARIOS
ESTABLISHED CAPTURED
One Scenario :
Into many connected Sub-Scenarios
Actor1
UseCase4 UseCase5
Please try to figure out the logic needed behind each of these
start-up scenarios before adopting them in your study and
providing the Description.
Recommended book :
UML 2 Toolkit
by Hans-Erik Eriksson, Magnus Penker, Brian Lyons, David Fado
Other books :
The major strength of "UML Distilled" is its short, concise presentation of the essentials of UML and where it fits within
today's software development process. The book describes all the major UML diagram types, what they're for, and the basic
notation involved in creating and deciphering them.
ISBN 0321193687
www.omg.org
www.rational.com
http://www.cetus-links.org/software.html
More Books
Efficiently code statecharts directly in C/C++. You get a lightweight alternative to CASE tools that permits you to model
reactive systems with UML statecharts. Includes complete code for your own applications, several design patterns, and
numerous executable examples that illustrate the inner workings of the statechart-based framework.
ISBN1578201101
The Unified Modeling Language (UML) is a third generation method for specifying,
an object-oriented system under development. It unifies the three leading object-orie
serve as the basis for a common, stable, and expressive object-oriented development
software applications increases, so does the developer's need to design and analyze a
them. This practical introduction to UML provides software developers with an over
design notation, and teaches Java programmers to analyse and design object-oriented
notation.
* Apply the basics of UML to your applications immediately, without having to wad
documentation
* Use the simple Internet example as a prototype for developing object-oriented appl
* Follow a real example of an Intranet sales reporting system written in Java that is u
throughout the book
* Learn from an example application modeled both by hand and with the use of Popk
Architect O-O visual modeling tool.
ISBN1558604650
This comprehensive, practical tutorial helps programmers understand both C++ and object-oriented design methodologies, so
they can write C++ that truly meets its potential. This text incorporates the newer language features, including templates and
exception handling, and explains how to apply C++ language constructs, design guidelines, and object-oriented methodology
to solve real world problems.
his comprehensive tutorial reflects the authors' extensive experience teaching C++ to professional
developers. Start with the clearest introduction to object modeling you'll ever read. Then learn all the
Next, discover C++ classes, the basic building block of object-oriented design. Through proven analogies
and examples, the authors introduce containment and inheritance, overloading, templates, RTTI, and
exception handling. And, the authors' unique presentation on multiple inheritance will give you
invaluable insights into this complex topic.
Learn to apply C++ and object-oriented techniques to real-world development. Discover how to design
classes effectively using the authors' class design boilerplate. Understand how to design container
classes. Walk through class designs using the powerful OMT methodology. Along the way, try out the
book's extensive exercises and take advantage of the exercise solutions and library of sample code on the
accompanying CD-ROM.
Navigating C++ and Object-Oriented Design is one of the first C++ tutorials that covers in detail
powerhouse ANSI C++ features like:
Why learnC++ simply as a "better C" when you can write C++ code that really meets its potential? One
book shows you how: "Navigating C++ and Object-Oriented Design!"
ISBN0135327482
The Unified Process Construction Phase: Best Practices in Completing the Unified Process
by Scott W Ambler, Larry L Constantine - Computers - 2000 - 295 pages
ISBN 1-57820-073-3,
OOAD
UML
Component Engineering
J2EE
App Servers : WebSphere, WebLogic
Higher & Modern Technologies :
Web Services
And so on.