OOSD Unit-1
OOSD Unit-1
OOSD Unit-1
ii. The only way to reach the data is through these particular methods (see Fig. 1.3.1).
iii. It is the mechanism that binds together code and the data it manipulates.
iv. This concept is also used to hide the internal representation, or state, of an object from the
outside.
2. Polymorphism :
i. Polymorphism means having many forms.
ii. Polymorphism is the ability of a message to be displayed in more than one form.
iii. It plays an important role in allowing objects having different internal structure to share the
same external interface.
3. Inheritance :
i. Inheritance is the ability to create classes that share the attributes and methods of existing
classes, but with more specific features.
ii. Inheritance is mainly used for code reusability.
Describe steps of object-oriented design.
Answer
Steps of object-oriented design :
1. System analysis :
i. In this stage a statement of the problem is formulated and a model is build. This phase show
the important properties associated with the situation.
ii. The analysis model is a concise, precise abstraction and agreement on how the desired
system must be developed.
iii. The objective is to provide a model that can be understood by any application experts in the
area.
2. System design :
i. At this stage, the complete system architecture is designed.
ii. In this stage the whole system is divided into subsystems, based on system analysis model
and the proposed architecture of the system.
3. Object design :
i. At this stage, a design model is developed based on the analysis model.
ii. The object design decides the data structures and algorithms needed to implement each of
the classes in the system.
4. Final implementation :
i. At this stage, the final implementation of classes and relationships developed during object
design takes place.
ii. Actual implementation should be done using software engineering practice. This helps to
develop a flexible and extensible system.
Differentiate between structured approach and object oriented approach.
Answer
Encapsulation of an object.
Using message passing to encapsulate the implementation of an object :
Other parts of a system only see an object’s interface (services it can perform and operation
signatures). Internal details including data are hidden and can only be accessed by a message
that contains a valid signature.
Write short note on information hiding.
Answer
1. Information hiding is the process of hiding the details of an object or function.
2. The hiding of these details results in an abstraction, which reduces the external complexity
and makes the object or function easier to use.
3. In addition, information hiding effectively decouples the calling code from the internal
workings of the object or function being called, which makes it possible to change the hidden
portions without having to also change the calling code.
4. Encapsulation is a common technique programmers use to implement information hiding.
5. Advantage of information hiding is yielding flexibility, such as allowing a programmer to more
readily modify a program.
6. This also may be done by placing source code within modules for easy access in the future, as
the program develops and evolves
What do you mean by polymorphism ? Explain it with an example.
Answer
1. Polymorphism means having many forms.
2. Polymorphism is the ability of a message to be displayed in more than one form.
3. It plays an important role in allowing objects having different internal structure to share the
same external interface.
4. An operation is a function that may be applied to or by objects in a class.
5. Open, close, hide, and redisplay are operations on class Window. All objects in a class share
the same operations.
6. Each operation has a target object as an implicit argument.
7. The behavior of the operation depends on the class of its target.
8. An object “knows” its class, and hence the right implementation of the operation.
9. The same operation may apply to many different classes. Such an operation is polymorphic;
i.e., the same operation takes on different forms in different classes.
10. For example, the class File may have an operation print.
11. Different methods could be implemented to print ASCII files, print binary files, and print
digitized picture files.
12. All these methods logically perform the same task. However, each method may be
implemented by a different piece of code
Applicability of polymorphism :
1. In programming languages there are two types of polymorphism ad-hoc and universal.
2. There are two kinds of universal polymorphism: parametric and subtyping.
3. Ad-hoc polymorphism is a kind of polymorphism in which polymorphic functions can be
applied to arguments of different types.
4. In universal (parametric) polymorphism, the polymorphic functions are written without
mention of any specific type.
5. The ad-hoc polymorphism is applicable in both tradi onal and object oriented programming
environments, whereas universal polymorphism only applies to object-oriented systems.
What do you mean by modeling ? Discuss several purposes served by models with suitable
examples.
Answer
1. A model is an abstraction of something for the purpose of understanding it before building it.
2. Since a model leave out non essential detail, it is easier to manipulate them.
3. To build hardware and software systems, the developer needs to :
i. Abstract different views of the system.
ii. Build models using precise notations.
iii. Make sure that the model satisfy the requirements of the system.
iv. Add details to transform the model into an implementation.
4. Model serves the following purpose
a. Testing a physical entity before building it :
i. Simulating a model is cheaper. Also, it provides information that is too inaccessible to be
measured from physical model.
ii. Computer models are usually cheaper than building a complete system and it enable flaws to
be corrected early. For example : Scale models of airplane and cars are tested in wind tunnels
to improve their aerodynamic.
b. Communication with customers :
i. Software designers build models to show their customers.
For example : Demonstration products like mock-ups that imitate some or all of the external
behavior of a system.
c. Visualization :
i. Storyboards of movies, television shows, and advertisements allow the writers to see how
their idea flows.
ii. Using models unnecessary segments can be modified before the final development begins.
d. Reduction of complexity :
i. Modeling helps in understanding the systems that are too complex to understand directly.
ii. Model reduces complexity by leaving out the non essential details.
What are the different models used in object oriented languages ?
Answer
There are three types of models in object oriented languages are :
1. Object model :
a. The object model identifies the classes in the system and their relationship, as well as their
attributes and operations.
b. It represents the static structure of the system. The object model is represented graphically
by a class diagram.
2. Dynamic model :
a. The dynamic model indicates the dynamics of the objects and their changes in state.
b. The dynamic model captures the functional behavior of the system by exploring the behavior
of the objects over time and the flow of control and events among the objects.
3. Functional model :
a. The functional model is a data flow diagram of the system and describes what the system
does, not how it is done.
b. A DFD is a network representation of the system to show the functional relationships of the
values that are computed by a system.
c. Data flow diagrams consist of processes, data flows, actors and data stores
Write short notes on :
a. Data store
b. Actors
c. Control flow
Answer
a. Data store :
1. A data store is a passive object within a data flow diagram that stores data for later access.
2. Unlike an actor, a data store does not generate any operations on its own but merely
responds to requests to store and access data.
3. A data store allows values to be accessed in a different order than they are generated.
4. A data store is drawn as a pair of parallel lines containing the name of the store.
5. Input arrows indicate information or operations that modify the stored data; this includes
adding elements, modifying values, or deleting elements.
6. Output arrows indicate information retrieved from the store. This includes retrieving the
entire value or some component of it.
b. Actors :
1. An actor is an active object that drives the data flow graph by producing or consuming
values.
2. Actors are attached to the inputs and outputs of a data flow graph.
3. Examples of actors include the user of a program, a thermostat, and a motor under computer
control.
4. An actor is drawn as a rectangle to show that it is an object. Arrows between the actor and
the diagram are inputs and outputs of the diagram.
c. Control flow :
1. A data flow diagram shows all possible computation paths for values; it does not show which
paths are executed and in what order.
2. This is done by including control flows in the data flow diagram.
3. A control flow is a Boolean value that affects whether a process is evaluated.
4. The control flow is not an input value to the process itself.
5. A control flow is shown by a dotted line from a process producing a Boolean value to the
process being controlled.
What are the basic principles of modeling ? Explain in detail.
Answer
Principles of modeling are :
1. The choice of what models to create has a profound influence on how a problem is attacked
and how a solution is shaped : This means choose correct model as per the requirement of
problem statement.
2. Every model may be expressed at different levels of precision : This means all the user and
developers both may visualize a system at different levels of details at different time.
3. The best models are connected to reality : This means that the model must have things that
are practically possible. They must satisfy the real word scenarios.
4. No single model is sufficient, Every non-trivial system is best approached through a small set
of nearly independent models : This means we need to have use case view, design view,
process view, implementation view and development view. Each of these views may have
structural as well as behavioral aspects. Together these views represent a system.
Importance of modeling :
Modeling help the development team better to visualize the plan of their system and allow
them to develop more rapidly by helping them build the right thing.
Define object-oriented modeling (OOM). Describe various steps involved in OOM process.
Explain.
Answer
Object-oriented modeling :
1. Object-oriented modeling (OOM) is the construction of objects using a collection of objects
that contain stored values of the instance variables found within an object.
2. Object-oriented modeling is an approach to modeling an application that is used at the
beginning of the so ware life cycle when using an object oriented approach to so ware
development.
Steps involved in OOM process :
1. System analysis :
i. In this stage a statement of the problem is formulated and a model is build. This phase show
the important properties associated with the situation.
ii. The analysis model is a concise, precise abstraction and agreement on how the desired
system must be developed.
iii. The objective is to provide a model that can be understood by any application experts in the
area.
2. System design :
i. At this stage, the complete system architecture is designed.
ii. In this stage the whole system is divided into subsystems, based on system analysis model
and the proposed architecture of the system.
3. Object design :
i. At this stage, a design model is developed based on the analysis model.
ii. The object design decides the data structures and algorithms needed to implement each of
the classes in the system.
4. Final implementation :
i. At this stage, the final implementation of classes and relationships developed during object
design takes place.
ii. Actual implementation should be done using software engineering practice. This helps to
develop a flexible and extensible system.
Define link and association. Discuss the role of link and association in object modeling with
suitable example
Answer
1. Link and association in object modeling represent the relation between objects and classes.
2. Link : Link defines the relationship between two or more objects and a link is considered as
an instance of an association.
3. Association : It is a group of links that relates objects from the same classes.
4. For example :
i. Let us take the two classes Person and Company. Now there is an association relation
between these two classes.
ii. A person may own stock in zero or more companies.
iii. Also it can be related in reverse that a company may have several persons owing its stock.
iv. The object diagram below shows the links between the objects of person and company class.
v. The class diagram below shows the association between the person and the company class.
Both link and association are represented with a line in UML notation
What do you mean by object modeling technique ? Explain. Discuss the various stages of the
object modeling techniques with some example.
Answer
Object modeling technique :
1. The Object Modeling Technique (OMT) is the methodology that combines the three views of
modeling system, i.e., the object model, the dynamic model and the functioned model.
2. These three models separate a system into orthogonal views that can be represented and
manipulated with a uniform notation.
Stages of object modeling technique :
1. Analysis :
a. Starting from a statement of the problem, the analyst builds a model of the real-world
situation showing its important properties.
b. The analysis model is a concise, precise abstraction of what the desired system must do.
c. The objects in the model should be application-domain concepts.
d. A good model can be understood by application experts who are not programmers.
e. For example, a Window class in a workstation windowing system would be described in
terms of the attributes and operations visible to a user.
2. System design :
a. The system designer makes high-level decisions about the overall architecture.
b. During system design, the target system is organized into subsystems based on both the
analysis structure and the proposed architecture.
c. The system designer must decide what performance characteristics to optimize, developing
strategy for solving the problem, and making tentative resource allocations.
d. For example, the system designer might decide that changes to the workstation screen must
be fast and smooth and choose an appropriate communications protocol and memory buffering
strategy.
3. Object design :
a. The object designer builds a design model based on the analysis model but containing
implementation details.
b. The designer adds details to the design model in accordance with the strategy established
during system design.
c. The focus of object design is the data structures and algorithms needed to implement each
class.
d. The object classes are augmented with computer-domain data structures and algorithms
chosen to optimize important performance measures.
e. For example, the Window class operations are now specified in terms of the underlying
hardware and operating system.
4. Implementation :
a. The object classes and relationships developed during object design are finally implemented.
b. During implementation, it is important to follow good software engineering practice so that
traceability to the design is straight forward and so that the implemented system remains
flexible and extensible.
c. For example, the Window class would be coded in a programming language, using calls to the
underlying graphics system on the workstation.
What do you mean by UML ? Discuss the conceptual model of UML with the help of an
appropriate example.
Answer
UML :
1. UML stands for Unified Modeling Language.
2. UML is a pictorial language used to make software blueprints.
3. UML can be described as a general purpose visual modeling language to visualize, specify,
construct, and document software system.
4. It is also used to model non-software systems as well.
5. UML is not a programming language but tools can be used to generate code in various
languages using UML diagrams.
6. UML has a direct relation with object-oriented analysis and design.
Conceptual model of UML :
1. A conceptual model is defined as a model which is made of concepts and their relationships.
2. A conceptual model is the first step before drawing a UML diagram.
3. It helps to understand the entities in the real world and how they interact with each other.
4. The conceptual model of UML has three major elements :
a. UML building blocks.
b. Rules to connect the building blocks.
c. Common mechanisms of UML.
5. A domain model, often referred to as a conceptual model, might be represented by a
particular kind of UML class diagram.
6. This model explains the structure of the application domain rather than the application
structure itself.
7. It focuses on the domain concepts, rather than on the software entities.
8. Fig. shows the conceptual model for a library system.