You are on page 1of 61

Object Oriented System

MANISH ARYAL
Introduction
Objectives

Visualize concepts of object oriented technology in system design and


development

Conceptualization of significance of UML, AULM and other related tools


Introduction
Course Structure

Unit 1: Introduction
Unit 2: Object Oriented Design
Unit 3: UML
Unit 4: Domain Analysis
Unit 5: Agent UML
Unit 6: Object Oriented Metrics
Unit 7: Object Oriented System Development Life Cycle
Unit 8: Project Design
Introduction
Manish Aryal
Associate Professor
HIST
contact no.: 9841285747
email: manish@sagarmatha.edu.np
Terminologies
Therac-25
Software Crisis
six accidents between 1985 and 1987, in
the difficulty of writing useful and which patients were given massive overdoses
efficient computer programs in of radiation
the required time because of concurrent programming errors, it
due to the rapid increases in sometimes gave its patients radiation doses
computer power and the that were hundreds of times greater than
complexity of the problems that normal, resulting in death or serious injury
could be tackled
highlighted the dangers of software control of
safety-critical systems
Terminologies {contd..}
SDLC (System Development Life Cycle)

a conceptual model used in project


7. Operation,
1.
1. Problem
Operation, Support
Problemand Statement
andStudy
Maintenance
management that describes the stages 6.
5. 2.Support
6. Validation
2. Statement
Feasibility Maintenance
Verification
Verification
Feasibility
Implementation
3. Study
Analysis
5. Implementation
4.3.Design
Analysis

involved in software system


development project
Terminologies {contd..}
SDLC: Problem Statement

Objectives
to identify what needs to be done
Activities
customer communication
Outcome
list of issues to be addressed by using computer program
Terminologies {contd..}
SDLC: Feasibility Study
Operational
feasibility
Objectives:
to identify whether to solve the problem or not Four feasibility
Activities: tests:
Schedule
budgeting, cost-benefit analysis, scheduling feasibility

Outcome: Economic
feasibility
specification of how suitable system (also called Technical
development will be to the company cost/benefit feasibility
feasibility)
Terminologies {contd..}
SDLC: Analysis

Objectives
to identify requirements and develop a logical model
Activities
requirement identification, data modeling, usage modeling,
behavior modeling
Outcome
Software Requirement Specification
Terminologies {contd..}
SDLC: Design

Objectives
to develop physical model
Activities
architecture modeling, algorithm design
Outcome
design specification
Terminologies {contd..}
SDLC: Implementation

Objectives
to translate physical model into working product
Activities
coding
Outcome
a working product
Terminologies {contd..}
SDLC: Validation and Verification

Objectives
to make sure that we are building RIGHT PRODUCT
to make sure that we are building PRODUCT RIGHT
Activities
test case design, test case execution, calibration
Outcome
Errors, issues, Quality Certification
Terminologies {contd..}
SDLC: Support and Maintenance

Objectives
to assist users get comfortable with software
to upgrade the system for meeting the changing needs
Activities
trainings, help desks, feedbacks
Outcome
user guide, list of new problems to be addressed
Traditional Vs OO Software Engineering
Traditional Vs OO Software Engineering
Traditional Vs OO Software Engineering
1. Problem Statement 1. Problem Statement
2. Feasibility Study 2. Feasibility Study
3. Analysis 3. OO Analysis
4. Design 4. OO Design
5. Implementation 5. OO Implementation
6. Validation and Verification 6. Validation and Verification
7. Operation, Support and Maintenance 7. Operation, Support and Maintenance
An object has behaviors
In old style programming, you had:
◦ data, which was completely passive
◦ functions, which could manipulate any data

An object contains both data and methods that manipulate that data
◦ An object is active, not passive; it does things
◦ An object is responsible for its own data
◦ But: it can expose that data to other objects
An object has state
An object contains both data and methods that manipulate that data
◦ The data represent the state/attributes of the object
◦ Data can also describe the relationships between this object and other objects

Example: A CheckAccount() might have


◦ A balance (the internal state of the account)
◦ An owner (some object representing a person)
A “Rabbit” object
You could (in a game, for example) create an object representing a
rabbit
It would have data:
◦ How hungry it is
◦ How frightened it is
◦ Where it is

And methods:
◦ eat, hide, run, dig
Object Oriented Paradigm
Object - Oriented (OO) Programming:
◦ Organizing software as a collection of objects with a certain state and behavior.

Object Oriented Design:


◦ Based on the identification & organization of objects.

OO Methodology
◦ Construction of models
◦ The development of SW is a modeling process

OO Modeling and Design


◦ Modeling objects based on the real world
◦ Using models to design independently of a programming language .
Objects

Object
Complex data type that has an identity, contains other data types
called attributes and modules of code called operations or methods
Attributes and associated values are hidden inside the object.
Any object that wants to obtain or change a value associated with
other object, must do so by sending a message to one of the objects
(invoking a method)
Objects
methods (methods)
Object: employee1
Attributes (values)

method: Age: 35
Set_salary Salary: 10

Set_salary (20) Get_age

employer friend
Classes
Classes are templates that have methods and attribute names and type
information, but no actual values!
Objects are generated by these classes and they actually contain values.
We design an application at the class level.
When the system is running objects are created by classes as they are
needed to contain state information.
When objects are no longer needed by the application, they are
eliminated.
Classes describe objects
Every object belongs to (is an instance of) a class
An object may have fields, or variables
◦ The class describes those fields

An object may have methods


◦ The class describes those methods

A class is like a template, or cookie cutter


Classes are like Abstract Data Types
An Abstract Data Type (ADT) bundles together:
◦ some data, representing an object or "thing"
◦ the operations on that data

Example: a CheckingAccount, with operations deposit, withdraw,


getBalance, etc.
Classes enforce this bundling together
Example of a class
class Employee {
// fields
String name;
double salary;
// a method
void pay () {
System.out.println("Pay to the order of " + name + " $" + salary);
}
}
Classes form a hierarchy
Classes are arranged in a treelike structure called a hierarchy
The class at the root is named Object
Every class, except Object, has a superclass
A class may have several ancestors, up to Object
When you define a class, you specify its superclass
◦ If you don’t specify a superclass, Object is assumed

Every class may have one or more subclasses


Concepts {review…}

SDLC
Objects
Classes
Class & Objects

CLASS: Furniture

Name methods: Example


Number ChangeNumber

Objects:

Desk ChairA ChairB


123445 32143 45687
Objects inherit from their superclasses
A class describes fields and methods
Objects of that class have those fields and methods
But an object also inherits:
◦ the fields described in the class's superclasses
◦ the methods described in the class's superclasses
A class is not a complete description of its objects!
Objects must be created
int n; does two things:
◦ it declares that n is an integer variable
◦ it allocates space to hold a value for n
Employee secretary; does one thing
◦ it declares that secretary is type Employee
secretary = new Employee ( ); allocates the space
How to declare and create objects
Employee secretary; // declares secretary
secretary = new Employee (); // allocates space
Employee secretary = new Employee(); // both But the secretary
is still "blank"
secretary.name = "Adele"; // dot notation
secretary.birthday (); // sends a message
How to reference a field or method
Inside a class, no dots are necessary
class Person { ... age = age + 1; ...}
Outside a class, you need to say which object you are talking to
if (john.age < 75) john.birthday ();
If you don't have an object, you cannot use its fields or methods!
Example: Assignment of subclasses
class Dog { ... }
class Poodle extends Dog { ... }
Dog myDog;
Dog rover = new Dog ();
Poodle yourPoodle;
Poodle fifi = new Poodle ();
myDog = rover; // ok
yourPoodle = fifi; // ok
myDog = fifi; //ok
yourPoodle = rover; // illegal
Methods can be overridden
class Bird extends Animal {
void fly (String destination) {
location = destination;
}
}

class Penguin extends Bird {


void fly (String whatever) { }
}

So birds can fly. Except penguins.


Don't call functions, send messages
Bird someBird = pingu;
someBird.fly ("South America");
Did pingu actually go anywhere?
◦ You sent the message fly(...) to pingu
◦ If pingu is a penguin, he ignored it
◦ otherwise he used the method defined in Bird

You did not directly call any method


Classes themselves can have fields and methods
Usually a class describes fields (variables) and methods for its objects
(instances)
◦ These are called instance variables and instance methods

A class can have its own fields and methods


◦ These are called class variables and class methods

There is exactly one copy of a class variable, not one per object
Use the special keyword static to say that a field or method belongs
to the class instead of objects
Example of a class variable
class Person {
String name;
int age;
static int population;
Person (String name) {
this.name = name;
this.age = 0;
population++;
}
}
Restrict access
Always, always strive for a narrow interface
Follow the principle of information hiding:
◦ the caller should know as little as possible about how the method does its job
◦ the method should know little or nothing about where or why it is being
called
Make as much as possible private
Use setters and getters
class Employee extends Person {
private double salary;
public void setSalary (double newSalary) {
salary = newSalary;
}
public double getSalary () { return salary; }
}

This way the object maintains control


Setters and getters have conventional names
Message Passing & Associations

Methods are associated with classes but classes don’t send messages to
each other.
Objects send messages.
A static diagram (class diagram) shows classes and the logical associations
between classes, it doesn´t show the movement of messages.
An association between two classes means that the objects of the two
classes can send messages to each other.
Aggregation: when an object contains other objects ( a part-whole
relationship)
Class Hierarchies & Inheritance

Classes can be arranged in hierarchies so that more classes inherit


attributes and methods from more abstract classes
Class hierarchy diagrams
Class: Chair

subclasses

Chair Type A Chair Type B


Inheritance
Inheritance
Example of inheritance
class Person { class Employee
String name; extends Person {
String age; double salary;
void birthday () { void pay () { ...}
age = age + 1; }
}
}

Every Employee has a name, age, and birthday method as well as a salary and a pay
method.
Public, Private & Protected

Attributes can be public or private:


◦ Private: it can only be accessed by its own methods
◦ Public: it can be modified by methods associated with any class (violates
encapsulation)
Methods can be public, private or protected:
◦ Public: it’s name is exposed to other objects.
◦ Private: it can’t be accessed by other objects, only internally
◦ Protected: (special case) only subclasses that descend directly from a class that
contains it, know and can use this method.
Polymorphism
Means that the same method will behave differently when it is applied to
the objects of different classes
It also means that different methods associated with different classes can
interpret the same message in different ways.
Example: an object can send a message PRINT to several objects, and
each one will use it’s own PRINT method to execute the message.
Encapsulation
Each objects methods manage it’s own attributes.
This is also known as hiding.
An object A can learn about the values of attributes of another object B,
only by invoking the corresponding method (message) associated to the
object B.
Example:
◦ Class: Lady
◦ Attributes: Age, salary
◦ Methods: get_age, set_salary
Encapsulation
Procedural application OO-application
DATA
Line of code
Data is stored
Line of code independent
of application
Line of code

Each object is independent of


the others
Complex Systems
Complex Systems is a system
◦ whose parts give rise to the collective behaviors of the system,
◦ how the system interacts with its environment.
For our purpose complex systems (Booch):
◦ have many states, i.e. large "phase space",
◦ are hard to comprehend in total
◦ hard to predict
Examples:
◦ Computer, human body, weather
Complex Systems
Attributes of a Complex System
◦ Hierarchical
◦ Components
◦ Primitive Components
◦ Arrangement
◦ Evolution
Complex Systems: Hierarchical
Composed of interrelated subsystems
◦ subsystems consist of subsystems too
◦ until elementary component
Complex Systems: Components
Links (dependencies) within a component are stronger than between
components
◦ inner workings of components separated from interaction between
components
◦ service/repair/replace components
Complex Systems: Primitive Components
There are primitive components
◦ but definition of primitive may vary
◦ Nuts, bolts, individual parts
◦ replaceable components?
Complex Systems: Few kinds of subsystems in many
combinations
There are common patterns
◦ Nuts, bolts, screws interchangeable
◦ cables, bulbs, plugs
◦ belts, chains
◦ clamps
Complex Systems: Evolved from a simpler system
Complex system designed from scratch rarely works
Add new funtionality/improvements in small steps
Software Complexity
The more complex the system, the more open it is to total breakdown

Rarely would a builder think about adding a new sub-basement to an


existing 100-story building
Doing that would be very costly and would undoubtedly invite failure
Amazingly, users of software systems rarely think twice about asking for
equivalent changes
Besides, they argue, it is only a simple matter of programming
Software Complexity
“The complexity of software is an essential property, not an
accidental one.” - Frederick Brooks
Four elements:
◦ the complexity of the problem domain,
◦ the difficulty of managing the development process,
◦ the flexibility possible through software, and
◦ the problems of characterizing the behavior of discrete
systems
Software Complexity
Next …

Unit 3. UML
Thank You.

You might also like