[go: up one dir, main page]

0% found this document useful (0 votes)
128 views1 page

Bca-622 Uml

This document discusses object-oriented programming concepts including objects, classes, encapsulation, abstraction, inheritance, and polymorphism. It provides examples of how these concepts apply to representing cars as classes. A class defines common attributes like brand name and behaviors like starting for all instances of cars. Encapsulation groups related data and behaviors together and hides implementation details. Abstraction focuses on essential features without background details. Inheritance allows subclasses to extend and reuse attributes and behaviors of a superclass.

Uploaded by

tbwpoeef
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
128 views1 page

Bca-622 Uml

This document discusses object-oriented programming concepts including objects, classes, encapsulation, abstraction, inheritance, and polymorphism. It provides examples of how these concepts apply to representing cars as classes. A class defines common attributes like brand name and behaviors like starting for all instances of cars. Encapsulation groups related data and behaviors together and hides implementation details. Abstraction focuses on essential features without background details. Inheritance allows subclasses to extend and reuse attributes and behaviors of a superclass.

Uploaded by

tbwpoeef
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Chapter 2 The behavior describes the operations the object carries out like start a car, operations or functions

s out like start a car, operations or functions or methods wrapped in the class can access it. This gives
stop a car, change gear, accelerate, and apply brake. The behavior is described by protection and security to the data. The data is insulated from direct access. This
Review of Object Orientation the operations or the methods. achieves a way to hide information or data.
All the cars have a brand name, a model name, a color and so on. All the cars
can be started, stopped, accelerated. All the features that describe the state and the
2.0 Objectives behavior of cars are similar. So we need not define them separately.
2.1 Introduction
brandName = Tata
2.2 Object modelName = Nano
2.3 Class color = Yellow

2.4 Encapsulation
2.5 Abstraction
For the car class the following diagram shows the encapsulation where the
2.6 Inheritance A dog is an animal. A cat is an animal. A cow is an animal. A lion is an animal.
operations are around the attributes. The attributes are not directly visible or open to
2.7 Polymorphism brandName = the outside. The operations above them form an insulating cover or wrapper around The superclass is animal. The subclasses are dog, cat, cow, and lion.
2.7.1 Function Polymorphism Hyundai them.
2.7.2 Operator Polymorphism modelName = i10
color = Red
2.8 Message Passing …
2.9 Summary
2.10 Check your Progress – Answers
2.11 Questions for Self – Study
2.3 CLASS
2.12 Suggested Readings
There can be a large number of cars. We need not define each of them
separately. Instead we can describe them together by grouping all the cars under a
pattern, template or blueprint. This pattern is known as a class. It creates a group of
2.0 OBJECTIVES structurally identical items. e.g. car. A car can have attributes like a brand name, a
To revise the following object oriented concepts - model name, a color. A car can have operations like to stop, to start, to accelerate, to
change gear. A class consists of both a pattern and a mechanism for creating items 2.5 ABSTRACTION
▫ Objects
based on that pattern. The items created or manufactured using the class are called 2.4-2.6 Check your progress
▫ Classes instances. e.g. myCar, yourCar. Abstraction is the act of representing the essential features without including
the background details or explanations. This is a fundamental principle of modeling. True or False
▫ Encapsulation A system model is created at different levels, starting at the higher level and adding
▫ Abstraction more levels are more and more details become known about the system. A model 1. The data is directly accessible to the outside world due to encapsulation.
Attributes Operations can be viewed at several levels, each giving different details about the system. So
▫ Inheritance brandName stop() abstraction is looking only at the information that is relevant at the time by hiding 2. Abstraction is looking only at the information that is relevant at the time by
modelName start() details so that there is no confusion in understanding the system. hiding details.
▫ Polymorphism
color accelerate()
▫ Message passing numberOfGears changeGear() For example, 3. Encapsulation supports abstraction.
currentGear applyBrake()
A car is an abstraction which represents the features i.e. the attributes like
… … 4. Inheritance supports hierarchical classification and provides reusability.
brandName and modelName and the operations like start and change gear. Also a
car represents all possible models of all possible cars.
2.1 INTRODUCTION 2.6 INHERITANCE 2.7 POLYMORPHISM
The UML can be used in a better way with the object oriented technologies. 2.2-2.3 Check your progress
The process by which objects of one class acquire the properties of objects of Polymorphism means the ability to take more than one form. The
So there is a need to revise the object concepts. All the important concepts will be another class is known as inheritance. This supports hierarchical classification. This
Fill in the blanks polymorphism is of two types:
covered in this chapter. provides reusability. It makes it possible to add additional features to an existing
1. The ………………….. is the property of an object that distinguishes it from other class without modifying it. This helps avoid duplication. 2.7.1 Function polymorphism
2.2 OBJECT
object A class known as the subclass or the child class can inherit attributes and An operation may exhibit different behavior in different instances depending
Every day we come across many things. The things can be a tangible thing like
operations from another class known as the superclass or the parent class. The upon the data used in the operation. Here a single name is used to perform different
a car or a printer, a role like an employee or a boss, an incident like a flight or an 2. The behavior describes the ……………… the object carries out.
subclass provides the specialized behavior whereas the superclass provides the tasks. The same method used in a superclass can be overridden in subclasses to
overflow, interaction like contract or a sale or a specification like a color or a shape. 3. A class creates a group of ………………. items.
generalized behavior. give a different functionality.
Each of these things has some kind of identity, state and behavior. 4. The items created or manufactured using the class are called
For example,
The identity is the property of an object that distinguishes it from other objects …………………………
like myCar, yourCar. For example: All animals make some kind of a sound. But the sounds of different animals
are termed differently. A cat mews. A dog barks. A lion roars.
The state describes the data stored in that object like for a car we can specify 2.4 ENCAPSULATION A car is a vehicle. An auto rickshaw is a vehicle. A truck is a vehicle. The
the brand name as Tata, the model name as Nano, the color as yellow for myCar superclass is vehicle. The subclasses are car, auto rickshaw, truck. All polygons occupy area. A triangle, a rectangle, a square are all polygons. The
The wrapping of data and functions into a single unit called a class is known as
and the brand name Hyundai, the model name as i10, the color as red for yourCar superclass polygon has a method getArea(). For getArea() in subclass triangle the
encapsulation. The data is not directly accessible to the outside world. Only the
and so on. The state or the structure is described by the properties or the attributes.
Unified Modeling System / 8 Unified Modeling System / 10
Review of Object Orientation / 7 Review of Object Orientation / 9

calculation is done by the formula ½ of the product of the base and height. For 2.10 CHECK YOUR PROGRESS - ANSWERS Chapter 3
getArea() in subclass rectangle the calculation is done by the formula product of the
2.2-2.3
length and breadth. Overview of UML
1. Identity
2.7.2 Operator polymorphism
2. Operations
This is the process of making an operator to exhibit different behaviors in different
3.0 Objectives
instances. 3. Structurally identical Interface – interface defines a set of operations which specifies what a class can do.
3.1 Introduction
For example, 4. Instances Collaboration – collaboration defines an interaction between things to achieve some
3.2 Things goal.
‘+’ operator when used with integers, it gives the result as the addition of the two 2.4 - 2.6
3.2.1 Structural Things Use case – use case represents a set of actions performed by a system for a
integers. We might wish ‘+’ to add two matrices or two vectors.
1. False
3.2.2 Behavioral Things specific goal.
2.8 MESSAGE PASSING 2. True 3.2.3 Grouping Things
A message is a request for execution of a procedure that invokes a function in the
3. True 3.2.4 Annotational Things
receiving object that generates the desired result.
4. True 3.3 Relationships
Message passing achieves communication between a set of objects with each other. Component – component describes a physical part of the system.
This communication is established by sending and receiving information. This can 3.3.1 Dependency
be achieved by specifying the name of the object, the name of the function 2.7-2.8 3.3.2 Association
(message) and the information to be sent.
1. Polymorphism 3.3.3 Generalization
For example, Node – a node can be defined as a physical element that exists at runtime.
2. An operation 3.3.4 Realization
A television may be operated by a remote. When the ON button on the remote is 3.4 Diagrams
pressed; the television should get switched on. Similarly when the OFF button on the 3. different behaviors
remote is pressed; the television should get switched off. The volume 3.4.1 Structure Diagrams
4. message
increase/decrease button on the remote is pressed; similar action should be 3.4.2 Behaviour Diagrams
activated by the television. For this the object ‘remote’ invokes the function of the
3.4.3 Interaction Diagrams
object ‘television’.
2.11 QUESTIONS FOR SELF – STUDY 3.5 Summary 3.2.2 Behavioral things
3.6 Check your Progress – Answers These are also called the verbs of the UML models. These are usually the dynamic
1. What is an object? 3.7 Questions for Self – Study parts of the system. Following behavioral things are available with the UML for use.
2. What are classes? 3.8 Suggested Readings Interaction – some behavior constituted by messages exchanged among objects.
The exchange of messages is with a view to achieving some purpose.
3. What is abstraction?
4. What is inheritance?
3.0 OBJECTIVES
5. What is encapsulation?
To understand the building blocks of UML
6. What is the purpose of message passing? State machine – state machine is useful when the state of an object in its lifecycle is
2.7-2.8 Check your progress ▫ Things and its four types important. It defines the sequence of states an object goes through in response to
events. Events are external factors responsible for state change
Fill in the blanks ▫ Relationships and its four types
▫ Diagrams and its three types.
1. ………………… means the ability to take more than one form.
2.12 SUGGESTED READINGS
2. ………………. may exhibit different behavior in different instances
3.1 INTRODUCTION
depending upon the data used in the operation. This is function UML is constructed from three main building blocks: things, relationships and .
polymorphism. 1. Unified Modeling Language User Guide by Grady Booch,James Rumbaugh, diagrams. When these building blocks are understood correctly it is easy to use the 3.2.3 Grouping things
Ivar Jacobson UML.
3. Operator polymorphism is the process of making an operator to exhibit This is the organizational part of the UML. It provides a higher level of abstraction.
………………… in different instances. 2. UML 2 For Dummies by Michael Jesse Chonoles, James A. Schardt 3.2 THINGS Following grouping mechanism is available with the UML for use.
4. A ………………… is a request for execution of a procedure that invokes There are four types of things in the UML. These are structural, behavioral, grouping Package – a general purpose element that comprises UML elements – structural,
a function in the receiving object that generates the desired result. and annotational. behavioral and even grouping things. These are conceptual groupings of the system
 and need not necessarily be implemented as cohesive software modules.

3.2.1 Structural Things


2.9 SUMMARY
These are also called the nouns of the UML models. These are usually the static
In this chapter the object oriented concepts are reviewed. The most important
parts of the system in question. They represent physical and conceptual elements.
elements of the object oriented method i.e. classes and objects are considered. The
Following structural things are available with the UML for use.
other important features viz. encapsulation, polymorphism, inheritance, message
passing are also described. Class – an abstraction of a set of things in the system that have similar properties
and/or functionality.

Unified Modeling System / 12 Unified Modeling System / 16


Review of Object Orientation / 11 Overview of UML / 15

3.2.4 Annotational things diagram. This includes communication, interaction overview, sequence and timing
diagrams.
This is the explanatory part of the UML model. It adds information or meaning to the
model elements. Following annotational mechanism is available with the UML for
use. 3.4 Check your progress
For example,
Note – it is a graphical notation for attaching constraints, rules, comments to
An animal (generalization) and a cat (specialization) are related by the Fill in the blanks
elements of the model.
generalization-specialization relationship.
1. Structure diagrams is a set of diagrams that depicts the elements of a
3.3.4 Realization specification those are ……………….. of time.
Realization is a semantic relationship between two things where one specifies the
2. ………………….. is a set of diagrams that depicts behavioral features of a
behavior to be carried out and the other carries out the behavior. I.e. one element
system or business process.
3.2 Check your progress describes some responsibility which is not implemented and the other one
implements it. This relationship exists in case of interfaces. The notation used is a 3. ………………… is a set of diagrams which emphasize object interactions.
Fill in the blanks dashed line with a empty triangular block arrowhead.

1. …………………. are called the nouns of the UML models.


3.5 SUMMARY
2. The behavioral things are called the …………………… of the UML. In this chapter we learnt the building blocks of the UML. There are three main
For example,
building blocks viz. things, relationships and diagrams. The types of diagrams are
3. ……………………….. are conceptual groupings of the system. The television carries out the behavior specified by the remote. mentioned here but the different diagrams available are described in the next
chapter.
3.3 Check your progress
3.6 CHECK YOUR PROGRESS - ANSWERS
3.3 RELATIONSHIPS True or false 3.2
The objects need to interact with each other. The relationships describe the meaning
1. Dependency is a semantic relationship where a change in one thing causes 1. Structural things
of the links between things and how the links are to be interpreted while
implementing the system. There are four types of relationships viz. dependency, a change in the semantics of the other thing. 2. Verbs
association, generalization, realization. 3. Packages
2. Association describes how many objects are taking part in that relationship.
3.3.1 Dependency 4. Annotational things
3. In the generalization relationship, arrowhead points toward the specialized
Dependency is a semantic relationship where a change in one thing (the 3.3
class 3.7 QUESTIONS FOR SELF - STUDY
independent thing) causes a change in the semantics of the other thing (the
dependent thing). The notation used for dependency is a dashed line with an 1. True 1. Why is it necessary to have a variety of diagrams?
arrowhead. 2. True 2. Which diagrams give the static view of the system?
3.4 DIAGRAMS
The diagrams are graphical representation of the models which uses various 3. False 3. Which diagrams give the behavioral view of the system?
symbols and text. Each different symbol has a special meaning in the context of the 4. True 4. Name major building blocks of UML?
UML. The user can use text to describe the concepts from the system under
3.4 5. What are the different types of UML diagrams?
For example, development. There are thirteen different types of diagrams available in the UML 2.0.
Each diagram has its own set of symbols. Each diagram captures a different 1. Irrespective 6. What is interaction diagram?
When the date of birth (the independent thing) is changed, the age (the dependent dimension, view, perspective of the system.
thing) changes with it. 2. Behavior diagrams
There two major types of the UML diagrams: structure and behavior. The behavior
3.3.2 Association 3. Interaction diagrams
diagrams also include the interaction diagrams. 3.8 SUGGESTED READINGS
Association is a structural relationship that describes the connection between two 3.4.1 Structure diagrams
things. It also describes how many objects are taking part in that relationship. The
notation used for association is a simple line segment or a line segment with This is a set of diagrams that depicts the elements of a specification those are 1. Unified Modeling Language User Guide by Grady Booch,James Rumbaugh,
arrowhead. irrespective of time. This includes class, composite structure, component, Ivar Jacobson
deployment, object and package diagrams. These models represent the framework
for the system. 2. UML 2 For Dummies by Michael Jesse Chonoles, James A. Schardt

3.4.2 Behavior diagrams


For example,
This is a set of diagrams that depicts behavioral features of a system or business
3.3.3 Generalization process. This includes activity, state machine, use case diagrams and the four

interaction diagrams. These models describe the interaction in the system.
Generalization is a relationship between a general thing (a parent or superclass) and
a more specific kind of that thing (a child or subclass). The notation used for 3.4.3 Interaction diagrams
generalization is a line segment with an empty block triangular arrowhead. The
This is a set of diagrams which emphasize object interactions. The interaction is very
arrowhead points toward the generalized class or use case or package.
important to get something done. This diagram type is categorized under behavior

Unified Modeling System / 18 Unified Modeling System / 20


Overview of UML / 17 Overview of UML / 19

NOTES NOTES

Unified Modeling System / 22


Overview of UML / 21

You might also like