3rd Country Training Program
Download
Report
Transcript 3rd Country Training Program
System Engineering and Databases
Lecture 3:
Introduction to Software Analysis and
Design - Object-Oriented Notions
Prof. Kazimierz Subieta
Polish-Japanese Institute of Information Technology
Institute of Computer Science, Warsaw, Poland
[email protected]
http://www.ipipan.waw.pl/~subieta
3rd Country Training, K.Subieta: System Engineering and Databases. Lecture 3, Slide 1
February 20, 2004
Content
Basic Principles of Object Orientation: Abstraction,
Encapsulation, Modularity, Hierarchy
Basic Concepts of Object Orientation: Object, Class, Attribute,
Operation, Component, Generalization, Association,
Polymorphism
Strengths of Object Orientation
What is Class Diagram?
Object-oriented methodologies
Conceptual modelling
Notations in Analysis and Design
Acknowledgment: The material has been compiled from many Internet sources. It has no commercial
purpose. Special thanks to anonymous authors of the Rational Software Corporation, who are the original
authors of many of the presented slides.
3rd Country Training, K.Subieta: System Engineering and Databases. Lecture 3, Slide 2
February 20, 2004
Objectives: Introduction to Object Orientation
Understand the basic principles of object orientation
Define the basic concepts and terms of object orientation
Discuss the strengths of object orientation
Understand some basic UML modeling mechanisms
3rd Country Training, K.Subieta: System Engineering and Databases. Lecture 3, Slide 3
February 20, 2004
Basic Principles of Object Orientation
3rd Country Training, K.Subieta: System Engineering and Databases. Lecture 3, Slide 4
Hierarchy
Modularity
Encapsulation
Abstraction
Object Orientation
February 20, 2004
What is Abstraction?
Salesperson
Customer
Product
3rd Country Training, K.Subieta: System Engineering and Databases. Lecture 3, Slide 5
February 20, 2004
What is Encapsulation?
Hide implementation from clients
– Clients depend on interface
3rd Country Training, K.Subieta: System Engineering and Databases. Lecture 3, Slide 6
February 20, 2004
What is Modularity?
The breaking up of something complex into manageable pieces
Order
Entry
Order Processing System
Order
Fulfillment
Billing
3rd Country Training, K.Subieta: System Engineering and Databases. Lecture 3, Slide 7
February 20, 2004
What is Hierarchy?
Levels of abstraction
Asset
Increasing
abstraction
BankAccount
Savings
Decreasing
abstraction
Checking
Security
Stock
RealEstate
Bond
Classes at the same level of the hierarchy should
be at the same level of abstraction
3rd Country Training, K.Subieta: System Engineering and Databases. Lecture 3, Slide 8
February 20, 2004
Basic Concepts of Object Orientation
Object
Class
Attribute
Operation
Component
Generalization
Association
Polymorphism
3rd Country Training, K.Subieta: System Engineering and Databases. Lecture 3, Slide 9
February 20, 2004
What is an Object?
Behavior
State
English 101
Unique identity
Intro to OO 180
Geology 110
World History 200
Geology 110
Algebra 110
Music History 200
3rd Country Training, K.Subieta: System Engineering and Databases. Lecture 3, Slide 10
February 20, 2004
What is a Class?
An object is defined by a class
English 101
Intro to OO 180
Geology 110
CourseOffering
World History 200
Geology 110
Algebra 110
Music History 200
3rd Country Training, K.Subieta: System Engineering and Databases. Lecture 3, Slide 11
February 20, 2004
What is an Attribute?
Object
Class
Attribute
Attribute Value
CourseOffering
number
startTime
endTime
:CourseOffering
number = 101
startTime = 900
endTime = 1100
:CourseOffering
Name = 104
startTime = 1300
endTime = 1500
3rd Country Training, K.Subieta: System Engineering and Databases. Lecture 3, Slide 12
February 20, 2004
What is an Operation?
CourseOffering
Class
Operation
addStudent
deleteStudent
getStartTime
getEndTime
3rd Country Training, K.Subieta: System Engineering and Databases. Lecture 3, Slide 13
February 20, 2004
What Is A Component?
A non-trivial, nearly independent, and replaceable part of a
system that fulfills a clear function in the context of a welldefined architecture
Design Model
<<subsystem>>
Component Name
Component
Interface
Implementation Model
Component
Name
Component
Interface
3rd Country Training, K.Subieta: System Engineering and Databases. Lecture 3, Slide 14
February 20, 2004
What is Generalization?
One class inherits from another
GroundVehicle
ancestor
weight
licenseNumber
owner
0..*
Person
1
register( )
generalization
decendent
Car
size
Truck
Trailer
tonnage
getTax( )
3rd Country Training, K.Subieta: System Engineering and Databases. Lecture 3, Slide 15
February 20, 2004
What is Association?
Position
Person
Company
Association roles
Person
+employee
Position +employer Company
0..1
*
public class Person {
public class Company {
public Company employer;
}
public Vector employee;
}
3rd Country Training, K.Subieta: System Engineering and Databases. Lecture 3, Slide 16
February 20, 2004
What is Polymorphism?
The ability to hide many different implementations behind a
single interface
Manufactor A
Manufactor A
3rd Country Training, K.Subieta: System Engineering and Databases. Lecture 3, Slide 17
Manufactor C
February 20, 2004
Strengths of Object Orientation
A single paradigm
– Single language used by users, analysts, designers,
implementers
Facilitates architectural and code reuse
Models more closely reflect the real world
– More accurately describe corporate data and processes
– Decomposed based on natural partitioning
– Easier to understand and maintain
Stability
– A small change in requirements does not mean massive
changes in the system under development
3rd Country Training, K.Subieta: System Engineering and Databases. Lecture 3, Slide 18
February 20, 2004
A Simple Sales Order Example
Order
Product
Ship via
3rd Country Training, K.Subieta: System Engineering and Databases. Lecture 3, Slide 19
February 20, 2004
What is Class Diagram?
A representation of the types of objects in the system and the
various kinds of static relationships that exist among them. It
serves as the framework for the system design.
Object - an identified, intelligent component of information system
capability. Domain objects represent "things" in the world (entities).
Capability - behavior that the object can perform, typically
requiring variables (data attributes) and methods (procedural code).
Class - a collection of objects having the same capabilities.
Association - a relationship among objects Subtype
Specialization (Subclasses) - subset of a class that extends its
capabilities
Constraint - a rule defining legal states of objects, classes,
relationships, and subtypes.
3rd Country Training, K.Subieta: System Engineering and Databases. Lecture 3, Slide 20
February 20, 2004
Class Diagram for the Sales Example
Sale
Salesperson
Customer
Corporate
Product
Individual
3rd Country Training, K.Subieta: System Engineering and Databases. Lecture 3, Slide 21
Vehicle
Truck
Train
February 20, 2004
Effect of Requirements Change
Suppose the requirements
for shipping by a truck
change ...
Salesperson
Sale
Customer
Corporate
Product
Individual
Vehicle
Truck
Train
Only the Truck class changes
3rd Country Training, K.Subieta: System Engineering and Databases. Lecture 3, Slide 22
February 20, 2004
Object-oriented methodologies
Object-oriented methodologies employ the concepts of object-orientedness to
conceptual modeling and to analysis and design of information systems.
The main component of O-O methodologies is an object (class) diagram,
which is some notational variant and extension of the popular entityrelationship diagrams.
An object diagram represents: classes of objects, attributes of objects,
methods that can be applied to objects, inheritance hierarchy among classes,
relationships (associations, aggregations) among classes, cardinalities of
these relationships, various constraints, and other information.
Object diagrams are supported by: dynamic diagrams dealing with events,
states and time, method passing diagrams, data flow and functional
diagrams, etc.
Recent O-O methodologies are driven by use case diagrams, which map the
system structure and functionality form the user viewpoint.
3rd Country Training, K.Subieta: System Engineering and Databases. Lecture 3, Slide 23
February 20, 2004
Conceptual modeling
mapping
mapping
...
... ......
... ......
...
Human perception of
the problem (business)
domain
Abstract conceptual
model of the domain
...
...
...
...
...
...
...
...
...
...
Programmer’s view of
data structures and
operations
The tendency in software modeling tools is simplifying the mappings between these
three perspectives.
3rd Country Training, K.Subieta: System Engineering and Databases. Lecture 3, Slide 24
February 20, 2004
Notations in Analysis and Design
A natural language
Graphical notations
Specifications - formalized statements
Graphical notations have special meaning.
Software engineering follows other technological domains, such as
electronics and mechanics.
Advantage of graphical notations are confirmed by psychological
tests.
Kinds of
notations
Functions of notations
Tools for analysis and design, recording ideas and results
Interaction with users of designed systems
Communication with other members of a design team
Basis for implementation of software
Documentation of projects and software
3rd Country Training, K.Subieta: System Engineering and Databases. Lecture 3, Slide 25
February 20, 2004