You are on page 1of 78

•UNIT-1

•Object Oriented System Design-Introduction


•UNIT-1
•Introduction

•Object orientation

•Object Identity

•Encapsulation, Information Hiding, Polymorphism

•Generosity

•Importance of Modelling-Principles

•Object oriented modelling

•Introduction to UML-Conceptual model of UML

•Architecture
Percentage of Projects That Fail
•The statistics for software project delivery show that only one
in three software projects are truly successful.

•According to Standish Group’s Annual CHAOS report, 66% of


technology projects (based on the analysis of 50,000 projects
globally) end in partial or total failure.
•Just one in three software projects are considered truly
successful with large projects most at risk of failure
•Object Orientation
•Object-oriented analysis and design (OOAD) is a technical approach for analyzing and designing
an application, system, or business by applying object-oriented programming, as well as using visual
modelling throughout the software development process to guide stakeholder communication and
product quality.
•What does Object-oriented mean?
•Object-oriented refers to a programming language, system or software methodology that is built on the
concepts of logical objects.
•It works through the Creation, Utilization and Manipulation of reusable objects to perform a specific task,
process or objective.
•The essence of object-oriented is that each of the created objects can be reused in the same and other
programs and applications.

•The object-oriented approach focuses on objects that represent abstract or concrete things in the real
world.
•Objects are first defined by their character and their properties, which are represented by their internal
structure and their attributes (data). The behavior of these objects is described by methods (functions).
•Objects form a capsule, which combines the characteristics with behavior.

•Objects are intended to enable programmers to map a real problem and its proposed software solution on a
one-to-one basis.
•Object Oriented Programming
•Object Oriented programming (OOP) is a programming paradigm that relies on the
concept of classes and objects.

•It is used to structure a software program into

Simple

Reusable pieces of code blueprints (usually called classes),

which are used to create individual instances of objects.

•There are many object-oriented programming languages including JavaScript, C++,


Java, and Python.

•A class is an abstract blueprint used to create more specific, concrete objects.


A CLASS CAR

•Contains all the properties a car must have, color, brand and model.

We then create an instance of a car type object, abc to represent my


specific car.

We could then set the value of the properties defined in the class to
describe my car, without affecting other objects or the class template.

•We can then reuse this class to represent any number of cars.

•Our car class may have a method repaint that changes the colour attribute of our car.
This function is only helpful to objects of type car, so we declare it within the car class
thus making it a method.

•Class templates are used as a blueprint to create individual objects.

•Each object can have unique values to the properties defined in the class.
Class car{
String model, color, brand;
String repaint(colorchange)
{
color=colorchange;
Return color;
}
Func {}
}
main()
{
Car obj()
obj.model=xyz;
obj.color=blue;
obj.brand=hyundai;

Car obj1;
obj1.model=xyz;
obj1.color=blue;
obj1.brand=hyundai;
Obj.repaint(red);
}
Uses of Object Orientation

•Below are some of the advantages of object-orientation:


• Complex software systems become easier to understand, since object-oriented
structuring provides a closer representation of reality than other programming
techniques.
• In a well-designed object-oriented system, it should be possible to implement
changes at class level, without having to make alterations at other points in the
system. This reduces the overall amount of maintenance required.
• Using polymorphism and inheritance, object-oriented programming allows you to
reuse individual components.
• In an object-oriented system, the amount of work involved in revising and
maintaining the system is reduced, since many problems can be detected and
corrected in the design phase.
Achieving these goals requires:

• Object-oriented tools Object-oriented tools allow you to create object-


oriented programs in object-oriented languages. They allow you to model and
store development objects and the relationships between them. For example:
class diagram, object diagrams, object state diagrams etc.

• Object-oriented modeling The object-orientation modeling of a software


system is the most important, most time-consuming, and most difficult
requirement for attaining the above goals. Object-oriented design involves
more than just object-oriented programming, and provides logical advantages
that are independent of the actual implementation.

• Object-oriented programming languages Object-oriented programming


techniques do not necessarily depend on object-oriented programming
languages. However, the efficiency of object-oriented programming depends
directly on how object-oriented language techniques are implemented in the
system kernel.
Building blocks of Object Oriented Programming

➢ Classes

➢ Methods

➢ Attributes

➢ Objects
Classes

Classes are essentially user defined data types. Classes are where we create a
blueprint for the structure of methods and attributes. Individual objects are
instantiated, or created from this blueprint.

•Classes contain fields for attributes, and methods for behaviours and represent broad
categories, like car or dog that share attributes.

•These classes define what attributes an instance of this type will have, like color, but
not the value of those attributes for a specific object.

•Classes can also contain functions, called methods available only to objects of that
type. These functions are defined within the class and perform some action helpful to
that specific type of object.
Objects

Objects are instances of classes created with specific data.

The state of an object is defined by the data in the object’s attributes fields.

For example, a puppy and a dog might be treated differently at pet camp. The
birthday could define the state of an object, and allow the software to handle
dogs of different ages differently.
•Methods: Methods represent behaviors. Methods perform actions; methods might
return information about an object, or update an object’s data. The method’s code
is defined in the class definition.

When individual objects are instantiated, these objects can call the methods
defined in the class.

Methods often modify, update or delete data.

Methods are how programmers promote reusability, and keep functionality


encapsulated inside an object. This reusability is a great benefit when debugging. If
there’s an error, there’s only one place to find it and fix it instead of many.
•Attributes: Attributes are the information that is stored. Attributes are defined in the
class template. When objects are instantiated individual objects contain data
stored in the Attributes field.

The state of an object is defined by the data in the object’s attributes fields.
Object Oriented Development
IT IS ALL ABOUT MODELING THE CONCEPTS

AND

IT IS NOT PURELY IMPLEMENTATION


OBJECT ORIENTED METHODOLOGY
Different Stages

▪ System Conception

▪ Analysis

Domain Model : Description of Real World Objects Reflected within the


system. Eg. Stock, bond,trade and commission

Application Model : Description of the parts of the application system itself


visible to the user. Eg. Execution of trades and calculation of results.

▪ System Design : Design high level system architecture for the overall application

▪ Class Design: Designer adds details to analysis model as per system design strategy

▪ Implementation: Translates classes and relationships into a particular programming model.


• class Parrot:

• # class attribute

• String species = “bird"

• # instance attribute

• def __init__(self, name, age):

• self.name = name

• self.age = age# instantiate the Parrot class

•blu = Parrot("Blu", 10)

•woo = Parrot("Woo", 15)

•# access the class attributes

•print("Blu is a {}".format(blu.__class__.species))

•print("Woo is also a {}".format(woo.__class__.species))

•# access the instance attributes

•print("{} is {} years old".format( blu.name, blu.age))

•print("{} is {} years old".format( woo.name, woo.age))


•Four Principles of OOP
•The four pillars of object oriented programming are:

• Encapsulation: containing information in an object, exposing only selected


information.

• Inheritance: child classes inherit data and behaviors from parent class.

• Abstraction: only exposing high level public methods for accessing an object.

• Polymorphism: many methods can do the same task.


•Encapsulation
•Encapsulation in OOP Meaning: In object-oriented computer programming
languages, the notion of encapsulation (or OOP Encapsulation) refers to the
bundling of data, along with the methods that operate on that data, into a single
unit.

•Many programming languages use encapsulation frequently in the form of


classes.

•A class is a program-code-template that allows developers to create an object


that has both variables (data) and behaviors (functions or methods).

•A class is an example of encapsulation in computer science in that it consists of


data and methods that have been bundled into a single unit.
•Many programming languages use encapsulation frequently in the form of
classes.

•A class is a program-code-template that allows developers to create an object


that has both variables (data) and behaviors (functions or methods).

•A class is an example of encapsulation in computer science in that it consists of


data and methods that have been bundled into a single unit.
Information Hiding
•Information hiding is an important aspect of modularity, and reduces the information
content to only what is important.

•Information hiding is an important aspect to the abstraction of software.

•Specifically, consider that the final software system is the lowest level of abstraction.
All of the software's design details are present at this level. Information hiding allows
us to hide information unnecessary to a particular level of abstraction within the final
software system, allowing for software engineers to better understand, develop and
maintain the software.

•We use software modules to implement information hiding: the information


contained in the modules should be hidden from those the rest of the software
system outside of the module, and access to this hidden information should be
carefully controlled. This allows us to maintain a higher level of abstraction in our
software, making our software more comprehensible.
•If information hiding is done well, changes made to the hidden portions of a
module should not affect anything outside of the module. This allows the
software engineers to more readily manage change (including changes in the
requirements).

•For example, a calculation producing a given result may be hidden. It follows a


model of functionality that can be described as a type of information hiding.
•One advantage of information hiding is yielding flexibility, such as allowing a
programmer to more readily modify a program. This also may be done by placing
source code within modules for easy access in the future, as the program develops
and evolves.
•"Abstraction and encapsulation are complementary concepts: abstraction
focuses on the observable behavior of an object...encapsulation focuses on the
implementation that gives rise to this behavior”

•an abstraction relates to how an object and its behaviors are presented to the
user and encapsulation is a methodology that helps create that experience.

•Think about the interface of your mobile phone. Whether you use an Android
operating system or iOS, you don't interact directly with the code that allows
your phone to connect to the internet, send a text message or play a video
game. Instead, you interact with the code through a user interface that is
designed to streamline your experience and make it easy to access the
functions and methods you need to complete a task. In this case, the interface
is abstracted away from the actual implementation of the code.
•Inheritance
•Inheritance allows classes to inherit features of other classes.

•Inheritance supports reusability.

•If basic attributes and behaviors are defined in a parent class, child classes can be
created extending the functionality of the parent class, and adding additional
attributes and behaviors.

•The benefits of inheritance are programs can create a generic parent class, and
then create more specific child classes as needed. This simplifies overall
programming, because instead of recreating the structure of the class multiple
times, child classes automatically gain access to functionalities within their
parent class.
•Types of Inheritance
✦Single Inheritance − A subclass derives from a single super-class.

✦Multiple Inheritance − A subclass derives from more than one super-classes.

✦Multilevel Inheritance − A subclass derives from a super-class which in turn is derived from another class
and so on.

✦Hierarchical Inheritance − A class has a number of subclasses each of which may have subsequent
subclasses, continuing for a number of levels, so as to form a tree structure.

✦Hybrid Inheritance − A combination of multiple and multilevel inheritance so as to form a lattice structure.
•Polymorphism
•Polymorphism means designing objects to share behaviors. Using inheritance,
objects can override shared parent behaviors, with specific child behaviors.

•Polymorphism allows the same method to execute different behaviors in two


ways: method overriding and method overloading.

•Method Overriding: Runtime polymorphism uses method overriding. In


method overriding, a child class can provide a different implementation than
its parent class.

•Method Overloading: Compile Time polymorphism uses method overloading.


Methods or functions may have the same name, but a different number of
parameters passed into the method call. Different results may occur depending on
the number of parameters passed in.
Example: Let us consider two classes, Circle and Square, each with a method
findArea(). Though the name and purpose of the methods in the classes are
same, the internal implementation, i.e., the procedure of calculating area is
different for each class. When an object of class Circle invokes its findArea()
method, the operation finds the area of the circle without any conflict with the
findArea() method of the Square class.
•Benefits of OOP
• OOP models complex things as reproducible, simple structures

• Reusable, OOP objects can be used across programs

• Allows for class-specific behavior through polymorphism

• Easier to debug, classes often contain all applicable information to them

• Secure, protects information through encapsulation


•Object Identity
•Object identity is a fundamental object orientation concept.

•With object identity, objects can contain or refer to other objects. Identity is a
property of an object that distinguishes the object from all other objects in the
application.

•There are many techniques for identifying objects in programming languages,


databases and operating systems. According to the authors the most commonly
used technique for identifying objects is user-defined names for objects.

•An object retains its identity even if some or all of the values of variables or
definitions of methods change over time.
•Several forms of identity:

◦ value: A data value is used for identity (e.g., the primary key of a tuple in a
relational database).

◦ name: A user-supplied name is used for identity (e.g., file name in a file
system).

◦ built-in: A notion of identity is built-into the data model or programming


languages, and no user-supplied identifier is required (e.g., in OO systems).

•Object identity is typically implemented via a unique, system-generated OID.


The value of the OID is not visible to the external user, but is used internally by
the system to identify each object uniquely and to create and manage inter-
object references.

•The object identity of two objects of the same type is the same, if every change
to either object is also a change to the other object.
Modelling
•Model is a simplification of reality.

• Blueprint of the actual system.

• Specify the structure and behavior of the system.

• Templates for designing the system.

• Helps document the system.


•Advantages of modelling

•Provides standard for software development.

• Reducing of costs to develop diagrams of UML using supporting tools.

• Development time is reduced.

• The past faced issues by the developers are no longer exists.

• Has large visual elements to construct and easy to follow.


The three types of modeling in UML as follows:
1. Structural modeling:
• It captures the static features of a system.
• It consists of the following diagrams:
1. Classes diagrams
2. Objects diagrams
3. Deployment diagrams
4. Package diagrams
5. Composite structure diagram
6. Component diagram
• This model represents the framework for the system and all the components exist here.
• It represents the elements and the mechanism to assemble them.
• It never describes the dynamic behavior of the system.
2. Behavioral modeling

• It describes the interaction within the system.

• The interaction among the structural diagrams is represented here.

• It shows the dynamic nature of the system.

• It consists of the following diagrams:

1. Activity diagrams

2. Interaction diagrams

3. Use case diagrams

• These diagrams show the dynamic sequence of flow in the system.


3. Architectural modeling:

• It represents the overall framework of the system.

• The structural and the behaviour elements of the system are there in this system.

• It is defined as the blue print for the entire system.

• Package diagram is used


Importance of Modelling
•Modeling is a central part of all activities that lead up to the deployment of good software. It is required to build
quality software.
•Importance of Modeling:
• Modeling gives graphical representation of system to be built.
• Modeling contributes to a successful software organization.
• Modeling is a proven and well accepted engineering technique.
• Modeling is not just a part of the building industry. It would be inconceivable to deploy a new aircraft or an
automobile without first building models-from computer models to physical wind tunnels models to full scale
prototypes.
• A model is a simplification of reality. A model provides the blueprint of a system.
• A model may be structural, emphasizing the organization of the system, or it may be behavioral,
emphasizing the dynamics of the system.
• Models are build for better understanding of the system that we are developing:
•Models help us to visualize a system as it is or as we want it to be.

•Models permit us to specify the structure or behavior of a system.

•Models give us a template that guides us in constructing a system.

•Models support the decisions we have made.


Principles of Modelling
• Principle 1: The model we choose have a profound influence on the solution
we provide.

✓Choose your models wisely.

✓The right models will simplify even the most wicked problem, offering insights
that couldn’t have been gained otherwise.
The wrong models will mislead us, causing to focus on irrelevant issues.
• Principle 2: Every model maybe expressed at different levels of abstraction.

• Help the stakeholders visualise the look and feel of system.

• Example: An analyst or an end user will want to focus on issues of what while
a developer would like to address the issues of how.


• Principle 3: The best models are connected to reality.

In object oriented systems, it is possible to connect all the nearly independent


views of the system into one semantic whole.


• Principle 4: No single model is sufficient, a set of models is needed to solve any non-trivial system

• To understand the architecture of such a system, we need several complementary and interlocking
views:

A use case view (exposing the requirements of system).

A design view (capturing the vocabulary of the problem space and solution space).

An interaction view (showing interaction among parts of the system and between the system
and environment).

An implementation (addressing the physical realization of the system).

A deployment view (focusing on system engineering issues).


Object Oriented Modelling
•In the object-oriented approach, the focus is on capturing the structure and
behavior of information systems into small modules that combines both data and
process. The main aim of Object Oriented Design (OOD) is to improve the quality
and productivity of system analysis and design by making it more usable.

•In analysis phase, OO models are used to fill the gap between problem and
solution. It performs well in situation where systems are undergoing continuous
design, adaption, and maintenance. It identifies the objects in problem domain,
classifying them in terms of data and behavior.
•The OO model is beneficial in the following ways −

It facilitates changes in the system at low cost.

It promotes the reuse of components.

It simplifies the problem of integrating components to configure large system.

It simplifies the design of distributed systems.

Features of Object-Oriented System:

•Encapsulation

•Abstraction

•Relationships

•Inheritance

•Polymorphism
Elements of Object-Oriented System

Objects − An object is something that is exists within problem domain and can be
identified by data (attribute) or behavior. All tangible entities (student, patient) and some
intangible entities (bank account) are modeled as object.

Attributes − They describe information about the object.

Behavior − It specifies what the object can do. It defines the operation performed on
objects.

Class − A class encapsulates the data and its behavior. Objects with similar meaning
and purpose grouped together as class.

Methods − Methods determine the behavior of a class. They are nothing more than an
action that an object can perform.

Message − A message is a function or procedure call from one object to another. They
are information sent to objects to trigger methods. Essentially, a message is a function
or procedure call from one object to another.
Introduction to UML
•UML: Unified Modeling Language

•The Unified Modeling Language is a standard language for writing software


blueprints.

•An industry-standard graphical language for specifying, visualizing, constructing


and documenting the software systems, as well as for business modeling.

• The UML uses mostly graphical notations to express the OO modeling and
design of software projects.

•Simplifies the complex process of software design


UML provides
Specifying: building models that are precise, unambiguous, and complete.

Visualizing: more than graphical symbols, each symbol in the UML notation is a
well-defined semantics.
In this manner, one developer can write a model in the UML, and another developer, or even another
tool, can interpret that model unambiguously

Constructing: UML is not a visual programming language, its models can be


directly connected to a variety of programming languages
Documenting : a healthy software organization produces all sorts of artifacts in
addition to raw executable code.
These artifacts include 1. Requirements 2.Architecture 3.Design 4.Source code 5.Project plans 6.Tests
7.Prototypes 8.Releases
Why we use UML?

•Use graphical notation: more clearly than natural language and code.

•Help acquire an overall view of a system.

•UML is not dependent on any one language or technology.


How to use UML diagrams to design software
system?

Types of UML Diagrams:

▪ Use Case Diagram

▪ Class Diagram

▪ Sequence Diagram

▪ Collaboration Diagram

▪ State Diagram
Different VIEWS..
UML : Standard language for….
UML Conceptual Model
To understand the UML, you need to form a conceptual model of the language,
and this requires learning three major elements:

1. The UML's basic building blocks

2. The rules that dictate how those building blocks may be put together

3. Some common mechanisms that apply throughout the UML.


•Basic Building Block of UML
➢Things

➢Relationships

➢Diagrams

Things in the UML : There are four kinds of things in the UML:

1. Structural things

2. Behavioral things

3. Grouping things

4. Annotational things
Structural Things
Structural things are the nouns of UML models.
These are the mostly static parts of a model, representing elements that are either
conceptual or physical.
In all, there are seven kinds of structural things:
1. Classes
2. Interfaces
3. Collaborations
4. Use cases
5. Active classes
6. Components
7. Nodes
CLASS

•Class is a description of a set of objects that share the same attributes,


operations, relationships, and semantics.

•A class implements one or more interfaces.

•Graphically, a class is rendered as a rectangle, usually including its name,


attributes, and operations.
INTERFACE
•Interface is a collection of operations that specify a service of a class or
component.

• Describes the externally visible behavior of that element.

•An interface might represent the complete behavior of a class or component or


only a part of that behavior.

•An interface is rendered as a circle together with its name.

•An interface rarely stands alone. Rather, it is typically attached to the class or
component that realizes the interface.
Collaboration
• It is an Interaction

•It is a society of roles and other elements that work together to provide some
cooperative behavior that's bigger than the sum of all the elements.

•Therefore, collaborations have structural, as well as behavioral, dimensions.

•A given class might participate in several collaborations.

•Graphically, a collaboration is rendered as an ellipse with dashed lines, usually


including only its name
USE CASE
• Use case is a description of set of sequence of actions that a system performs
that yields an observable result of value to a particular actor

• Use case is used to structure the behavioral things in a model.

• A use case is realized by a collaboration.

• Graphically, a use case is rendered as an ellipse with solid lines, usually


including only its name
ACTIVE CLASS
•Active class is just like a class

•Its objects represent elements whose behavior is concurrent with other


elements.

•Graphically, an active class is rendered just like a class, but with heavy lines,
usually including its name, attributes, and operations
COMPONENT

•Component is a physical and replaceable part of a system that conforms to and


provides the realization of a set of interfaces.

•Graphically, a component is rendered as a rectangle with tabs


NODE
Node is a physical element that exists at run time and represents a
computational resource, generally having at least some memory and, often,
processing capability.

Graphically, a node is rendered as a cube, usually including only its name


Behavioral Things
•Dynamic parts of UML models.

•These are the verbs of a model.

• Representing behavior over time and space.

•In all, there are two primary kinds of behavioral things

1. Interaction

2. State machine Interaction


Interaction
Interaction is a behavior that comprises a set of messages exchanged among a
set of objects within a particular context to accomplish a specific purpose.

An interaction involves a number of other elements, including messages, action


sequences and links.

Graphically a message is rendered as a directed line, almost always including


the name of its operation
STATE MACHINE
•State machine is a behavior that specifies the sequences of states an object or
an interaction goes through during its lifetime in response to events, together
with its responses to those events.

• State machine involves a number of other elements, including states,


transitions, events and activities.

•Graphically, a state is rendered as a rounded rectangle, usually including its


name and its substates
Grouping Things
Organizational parts of UML models.

These are the boxes into which a model can be decomposed

There is one primary kind of grouping thing, namely, PACKAGES.

Package:-

• A package is a general-purpose mechanism for organizing elements into groups.

• Structural things, behavioral things, and even other grouping things may be
placed in a package

• Graphically, a package is rendered as a tabbed folder, usually including only its


name and, sometimes, its contents
Annotational things

•Explanatory parts of UML models.

•These are the comments you may apply to describe about any element in a
model.
Relationships in UML
There are four kinds of relationships in the UML:

Dependency

Association

Generalization

Realization
DEPENDENCY

• Dependency is a semantic relationship between two things in which a change


to one thing may affect the semantics of the other thing.

•Graphically a dependency is rendered as a dashed line, possibly directed, and


occasionally including a label

-------------------------------------→
ASSOCIATION

•Association is a structural relationship that describes a set of links, a link being


a connection among objects.

•Graphically an association is rendered as a solid line, possibly directed,


occasionally including a label.
Aggregation

•Aggregation is a special kind of association, representing a structural


relationship between a whole and its parts.

•Graphically, a generalization relationship is rendered as a solid line with a


hollow arrowhead pointing to the parent
Realization

•Realization is a semantic relationship between classifiers, wherein one classifier


specifies a contract that another classifier guarantees to carry out.

•Graphically a realization relationship is rendered as a cross between a


generalization and a dependency relationship

You might also like