You are on page 1of 13

What is OOAD? Explain advantages of OOAD.

ANSWER:Object-oriented analysis and design (OOAD) is a software engineering approach that models a
system as a group of interacting objects. Each object represents some entity of interest in the system
being modeled, and is characterised by its class, its state (data elements), and its behavior. Various
models can be created to show the static structure, dynamic behavior, and run-time deployment of
these collaborating objects. There are a number of different notations for representing these models,
such as the Unified Modeling Language (UML).

Object-oriented analysis (OOA) applies object-modeling techniques to analyze the functional


requirements for a system. Object-oriented design (OOD) elaborates the analysis models to produce
implementation specifications. OOA focuses on what the system does, OOD on how the system does it.

Object-oriented analysis

Object-oriented analysis (OOA) looks at the problem domain, with the aim of producing a conceptual
model of the information that exists in the area being analyzed. Analysis models do not consider any
implementation constraints that might exist, such as concurrency, distribution, persistence, or how the
system is to be built. Implementation constraints are dealt with during object-oriented design (OOD).
Analysis is done before the Design[citation needed].

The sources for the analysis can be a written requirements statement, a formal vision document,
interviews with stakeholders or other interested parties. A system may be divided into multiple
domains, representing different business, technological, or other areas of interest, each of which are
analyzed separately.

The result of object-oriented analysis is a description of what the system is functionally required to do,
in the form of a conceptual model. That will typically be presented as a set of use cases, one or more
UML class diagrams, and a number of interaction diagrams. It may also include some kind of user
interface mock-up.

Object-oriented design

Object-oriented design (OOD) transforms the conceptual model produced in object-oriented analysis to
take account of the constraints imposed by the chosen architecture and any non-functional constraints,
such as transaction throughput, response time, run-time platform, development environment, or
programming language.

The concepts in the analysis model are mapped onto implementation classes and interfaces. The result
is a model of the solution domain, a detailed description of how the system is to be built.
Explain characteristics of an Object Oriented Systems. (10 Marks)

ANSWER:An object-oriented system is composed of objects. The behavior of the system results from the
collaboration of those objects. Collaboration between objects involves them sending messages to each
other. Sending a message differs from calling a function in that when a target object receives a message,
it itself decides what function to carry out to service that message. The same message may be
implemented by many different functions, the one selected depending on the state of the target object.
The implementation of "message sending" varies depending on the architecture of the system being
modeled, and the location of the objects being communicated with.

Characteristics of an Object Oriented Systems are as follows :-

Information hiding:-Information hiding in computer science is the principle of hiding of design decisions
in a computer program that are most likely to change, thus protecting other parts of the program from
change if the design decision is changed. The protection involves providing a stable interface which
shields the remainder of the program from the implementation (the details that are most likely to
change).

Data abstraction:-In object-oriented programming theory, abstraction is the facility to define objects
that represent abstract "actors" that can perform work, report on and change their state, and
"communicate" with other objects in the system. The term encapsulation refers to the hiding of state
details, but extending the concept of data type from earlier programming languages to associate
behavior most strongly with the data, and standardizing the way that different data types interact, is the
beginning of abstraction. When abstraction proceeds into the operations defined, enabling objects of
different types to be substituted, it is called polymorphism. When it proceeds in the opposite direction,
inside the types or classes, structuring them to simplify a complex set of relationships, it is called
delegation or inheritance.
Various object-oriented programming languages offer similar facilities for abstraction, all to support a
general strategy of polymorphism in object-oriented programming, which includes the substitution of
one type for another in the same or similar role.

Encapsulation:-Encapsulation is the hiding of the internal mechanisms and data structures of a software
component behind a defined interface, in such a way that users of the component (other pieces of
software) only need to know what the component does, and cannot make themselves dependent on the
details of how it does it. The purpose is to achieve potential for change: the internal mechanisms of the
component can be improved without impact on other components, or the component can be replaced
with a different one that supports the same public interface.Encapsulation also protects the integrity of
the component, by preventing users from setting the internal data of the component into an invalid or
inconsistent state.Another benefit of encapsulation is that it reduces system complexity and thus
increases robustness, by limiting the interdependencies between software components.
The concept of encapsulation is most commonly associated with object-oriented programming, where
the interface to an object is defined by its public methods, while its internal state is represented by
private data. However, the idea is more general than this: for example, a relational database is
encapsulated in the sense that its only public interface is the SQL language, which hides all the internal
machinery and data structures of the database management system. As such, encapsulation is a core
principle of good software architecture, at every level of granularity.
Encapsulating software behind an interface allows the construction of objects that mimic the behavior
and interactions of objects in the real world. For example, road traffic can be simulated by creating
objects that mimic the behavior of real vehicles and road junctions. This idea is most prominent in
simulation and virtual reality software (for example, games), but it is also important in other fields such
as network modeling and computer-aided design.

Modularity:-Modular programming is a software design technique that increases the extent to which
software is composed from separate parts, called modules. Conceptually, modules represent a
separation of concerns, and improve maintainability by enforcing logical boundaries between
components. Modules are typically incorporated into the program through interfaces. A module
interface expresses the elements that are provided and required by the module. The elements defined
in the interface are visible to other modules. The implementation contains the working code that
corresponds to the elements declared in the interface.

Polymorphism:-The primary usage of polymorphism in industry (object-oriented programming theory) is


the ability of objects belonging to different types to respond to method, field, or property calls of the
same name, each one according to an appropriate type-specific behavior. The programmer (and the
program) does not have to know the exact type of the object in advance, and so the exact behavior is
determined at run time (this is called late binding or dynamic binding). and

Inheritance:-In object-oriented programming, inheritance is a way to form new classes (instances of


which are called objects) using classes that have already been defined. The inheritance concept was
invented in 1967 for Simula.The new classes, known as derived classes, take over (or inherit) attributes
and behavior of the pre-existing classes, which are referred to as base classes (or ancestor classes). It is
intended to help reuse existing code with little or no modification.An advantage of inheritance is that
modules with sufficiently similar interfaces can share a lot of code, reducing the complexity of the
program.

Question 3:

What is Inheritances? Explain with an example, how Inheritance is shown in class diagram. (10 Marks)

ANSWER:In object-oriented programming, inheritance is a way to form new classes (instances of which
are called objects) using classes that have already been defined. The inheritance concept was invented
in 1967 for Simula.
The new classes, known as derived classes, take over (or inherit) attributes and behavior of the pre-
existing classes, which are referred to as base classes (or ancestor classes). It is intended to help reuse
existing code with little or no modification.
Inheritance provides the support for representation by categorization in computer languages.
Categorization is a powerful mechanism number of information processing, crucial to human learning by
means of generalization (what is known about specific entities is applied to a wider group given a
belongs relation can be established) and cognitive economy (less information needs to be stored about
each specific entity, only its particularities).

Inheritance is also sometimes called generalization, because the is-a relationships represent a hierarchy
between classes of objects. For instance, a "fruit" is a generalization of "apple", "orange", "mango" and
many others. One can consider fruit to be an abstraction of apple, orange, etc. Conversely, since apples
are fruit (i.e., an apple is-a fruit), apples may naturally inherit all the properties common to all fruit, such
as being a fleshy container for the seed of a plant.

An advantage of inheritance is that modules with sufficiently similar interfaces can share a lot of code,
reducing the complexity of the program. Inheritance therefore has another view, a dual, called
polymorphism, which describes many pieces of code being controlled by shared control code.

Inheritance is typically accomplished either by overriding (replacing) one or more methods exposed by
ancestor, or by adding new methods to those exposed by an ancestor.
Complex inheritance, or inheritance used within a design that is not sufficiently mature, may lead to the
Yo-yo problem.

What is an object? Critically explain “Object Identification is one of the major challenges in OOAD “.
(10 Marks)

ANSWER:In object-oriented programming (OOP), an instance of a program (i.e. a program running in a


computer) is treated as a dynamic set of interacting objects. Objects in OOP extend the more general
notion of objects described above to include a very specific kind of typing, which among other things
allows for:

1. data members that represent the data associated with the object.

2. methods that access the data members in predefined ways.

In the case of most objects, the data members can only be accessed through the methods, making it
easy to guarantee that the data will always remain in a well-defined state (class invariants will be
enforced). Some languages do not make distinctions between data members and methods.

In almost all object-oriented programming languages, a dot(.) operator is used to call a particular
method/function of an object. For example, consider an arithmetic class named Arith_Class. This class
contains functions like add(), subtract(), multiply() and divide(), that process results for two numbers
sent to them. This class could be used to find the product of 78 and 69 by first of all creating an object of
the class and then invoking its multiply method, as follows:

1 int result = 0; // Initialization

2 arith_Obj1 = new Arith_Class(); // Creating a new instance of Arith_Class

3 result = arith_Obj1.multiply(78,69); // Product of 78 and 69 stored in result variable

In a language where each object is created from a class, an object is called an instance of that class. If
each object has a type, two objects with the same class would have the same datatype. Creating an
instance of a class is sometimes referred to as instantiating the class.

A real-world example of an object would be "my dog", which is an instance of a type (a class) called
"dog", which is a subclass of a class "animal". In the case of a polymorphic object, some details of its
type can be selectively ignored, for example a "dog" object could be used by a function looking for an
"animal". So could a "cat", because it too belongs to the class of "animal". While being accessed as an
"animal", some member attributes of a "dog" or "cat" would remain unavailable, such as the "tail"
attribute, because not all animals have tails.

A ghost is an object that is unreferenced in a program, and can therefore serve no purpose. In a
garbage-collected language, the garbage collector would mark the memory occupied by the object as
free, although it would still contain the object's data until it was overwritten.

Three properties characterize objects:

1. Identity: the property of an object that distinguishes it from other objects

2. State: describes the data stored in the object

3. Behavior: describes the methods in the object's interface by which the object can be used

Some terms for specialized kinds of objects include:

* Singleton object: An object that is the only instance of its class during the lifetime of the program.

* Functor (function object): an object with a single method (in C++, this method would be the function
operator, "operator()") that acts much like a function (like a C/C++ pointer to a function).

* Immutable object: an object set up with a fixed state at creation time and which does not vary
afterward.
* First-class object: an object that can be used without restriction.

* Container: an object that can contain other objects.

* Factory object: an object whose purpose is to create other objects.

* Metaobject: an object from which other objects can be created (Compare with class, which is not
necessarily an object)

* Prototype: a specialized metaobject from which other objects can be created by copying

* God object: an object that knows too much or does too much. The God object is an example of an anti-
pattern.

* Anti objects: a computational metaphor useful to conceptualize and solve hard problems often with
massively parallel approaches by swapping computational foreground and background.....
Filter object

The purpose of object modeling is to describe objects. For example, Joe Smith, Simplex company, and
the top window are objects. An object is simply something that makes sense in an application context.
Objects serves two purposes: they promote understanding of the real world and provide a practical
basis for computer implementation. Decomposition for a problem into objects depends on judgments
and the nature of the problem. There is no one correct representation.

All objects have identity and are distinguishable. Two apples with the same color, shape and texture are
still individual apples; a person can eat one and then eat the other.

An object class describes group with similar properties, common behavior, common relationships to
other objects, and common semantics, company, animal, process, and window are all object classes. Ach
person has an age, IQ, and may work at a job. Ac process has an owner, priority, and list of required
resources. Objects and object classes often appear as nouns in problem description.

The object in class share a common semantic purpose, above and beyond the requirement of common
attributes and behavior. Each object knows its class.

Identifying Objects (and Class)


Identify the nouns( objects) in the problem description.
Identify more objects in your developing problem solution.
From these objects, determine what new types (classes) you need.
Example: Black Jack Program
Cards
A deck
A dealer
Player(s)

What is a state diagram? Explain the characteristics of the system that can be identified by
examination of the state diagram of that System. (10 Marks)

Ans. State diagrams (also called State Chart diagram) are used to help the developer better understand
any complex/unusual functionalities or business flows of specialized areas of the system. In short, State
diagrams depict the dynamic behavior of the entire system, or a sub-system, or even a single object in a
system. This is done with help of Behavioral elements.

The characteristics of the system that identified by examination of the state diagram of that System are
given below:

Initial state: This shows the starting point or first activity of the flow. Denoted by a solid circle. This is
also called as a “pseudo state,” where the state has no variables describing it further and no activities.
State: Represents the state of object at an instant of time. In a state diagram, there will be multiple of
such symbols, one for each state of the Object we are discussing. Denoted by a rectangle with rounded
corners and compartments (such as a class with rounded corners to denote an Object).

Transition: An arrow indicating the Object to transition from one state to the other. The actual trigger
event and action causing the transition are written beside the arrow, separated by a slash. Transition
that occur because the state completed and activity are called “triggerless” transitions. If an event has
to occur after the completion of some event or action, the event or action is called the guard condition.
The transition takes place after the guard condition. The transition takes place after the guard condition
occurs. This guard condition/event/action is depicted by square brackets around the description of the
event/action.

History States: A flow may require that the object go to occur is called as an event or action. Every
transition need not occur due to the occurrence of an event or action directly related to the state that
transitioned from one state to another.

Final State: the end of the state diagram is shown by a bull’s eye symbol also called a final state. A final
state is another example of a pseudo state because it does not have any variable or action described.

Simple Set
A simple state is a state that does not have sub-states, i.e. it has no regions and it has no sub-machine
state machine.
Explain different UML Diagrams used in OOAD. (10 Marks)

ANSWER:UML 2.0 has 13 types of diagrams divided into three categories.Six diagram types represent
the structure application, seven represent general types of behavior, including four represent different
aspects of interactions. These diagrams can be categorized hierarchically as shown in the following class
diagram:
UML does not restrict UML element types to a certain diagram type. In general, every UML element may
appear on almost all types of diagrams. This flexibility has been partially restricted in UML 2.0.
In keeping with the tradition of engineering drawings, a comment or note explaining usage, constraint,
or intent is always allowed in a UML diagram.

Structure diagrams
Structure diagrams emphasize what things must be in the system being modeled:

Class diagram: describes the structure of a system by showing the system's classes, their attributes, and
the relationships among the classes.

Component diagram: depicts how a software system is split up into components and shows the
dependencies among these components.

Composite structure diagram: describes the internal structure of a class and the collaborations that this
structure makes possible.

Deployment diagram serves to model the hardware used in system implementations, and the execution
environments and artifacts deployed on the hardware.

Object diagram: shows a complete or partial view of the structure of a modeled system at a specific
time.

Package diagram: depicts how a system is split up into logical groupings by showing the dependencies
among these groupings.

Class diagram

Component diagram

Composite structure diagrams

Deployment diagram
Object diagram

Package diagram

Since structure diagrams represent the structure of a system, they are used extensively in documenting
the architecture of software systems.
Behavior diagrams

Behavior diagrams emphasize what must happen in the system being modeled:
Activity diagram: represents the business and operational step-by-step work flows of components in a
system. An activity diagram shows the overall flow of control.
State diagram: standardized notation to describe many systems, from computer programs to business
processes.
Use case diagram: shows the functionality provided by a system in terms of actors, their goals
represented as use cases, and any dependencies among those use cases.

UML Activity Diagram

State Machine diagram

Use case diagram


Since behaviour diagrams illustrate the behaviour of system, they are used extensively to describe the
functionality of software systems.
Interaction diagrams
Interaction diagrams, a subset of behavior diagrams, emphasize the flow of control and data among the
things in the system being modeled:

Communication diagram: shows the interactions between objects or parts in terms of sequenced
messages. They represent a combination of information taken from Class, Sequence, and Use Case
Diagrams describing both the static structure and dynamic behavior of a system.

Interaction overview diagram: are a type of activity diagram in which the nodes represent interaction
diagrams.

Sequence diagram: shows how objects communicate with each other in terms of a sequence of
messages. Also indicates the lifespans of objects relative to those messages.

Timing diagrams: are a specific type of interaction diagram, where the focus is on timing constraints.

Communication diagram

Interaction overview diagram


Sequence diagram

Explain object model and dynamic model with example. (10 Marks)

Ans: The object model describes the structure of the objects in the system – their identity, their
relationship to other objects, their attributes, and their operations. The object model depicts the
primary view of how the real world in which the system interacts is divided and the overall
decomposition of the system. The object model provides the framework into which the other models
are placed.

The object model is represented graphically with object class diagrams containing the object classes and
their relationships. Each application-domain concept from the real world that is important to the
application should be modeled as an object class. Classes are arranged into hierarchies sharing common
structure and behavior and are associated with other classes. Classes define the attributes carried by
each object instance and the operations that each object performs or undergoes.

The object class diagram should adhere to OMT’s notation and exploit the capabilities of OMT, such as
links and vasodilatations, inheritance (generalization and specialization), and aggregation. The attributes
and operations need not be included in this diagram, as they will be described below in the object class
specification.

Elements of an Object Model


Object classes with attributes, relations and connections.
Attributes
Relations
Connection
Generalization/specialization
Aggregation
Classes with constraints no their environment
Behavior associated with an object model

Localization
The activity of establishing an object model consists of going through all the elements of an object
model.

Objects
The purpose of object modeling is to describe objects. For example, Joe Smith, Simplex company, and
the top window are objects. An object is simply something that makes sense in an application context.
Objects serves two purposes: they promote understanding of the real world and provide a practical
basis for computer implementation. Decomposition for a problem into objects depends on judgments
and the nature of the problem. There is no one correct representation.

All objects have identity and are distinguishable. Two apples with the same color, shape and texture are
still individual apples; a person can eat one and then eat the other.

Classes
An object class describes group with similar properties, common behavior, common relationships to
other objects, and common semantics, company, animal, process, and window are all object classes. Ach
person has an age, IQ, and may work at a job. Ac process has an owner, priority, and list of required
resources. Objects and object classes often appear as nouns in problem description.

The object in class share a common semantic purpose, above and beyond the requirement of common
attributes and behavior. Each object knows its class.

What is Unidirectional Implementation? Explain how it is different than Bi-directional Implementation


with an example. (10 Marks)

Ans.With a unidirectional association, you can navigate from one class to another (As indicated by the
direction of the arrow) but not vice-versa.It is conveniently implemented using a reference. Associations
represent relationships between instances of types (a person works for a company, a company has a
number of offices…). The interpretation of them varies with the perspective. Conceptually they
represent conceptual relationships between the types involved. In specification these are
responsibilities for knowing, and will be made explicit by access and update operations. This may mean
that a pointer exists between order and customer, but that is hidden by encapsulation. A more
implementation interpretation implies the presence of a pointer. Thus it is essential to know what
perspective is used to build a model in order to interpret it correctly.

Associations may be bi-directional (Can be navigated in either direction) or unidirectional (can be


navigated in one direction only). Conceptually all associations can be thought of a bi-directional, but
unidirectional associations are important for specification and implementation models. For coupling. IN
implementation models a bi-directional association implies coupled sets of pointers, which many
designers find difficult to deal with.

Bi-directional one-to-one associations


The following diagram indicates a bi-directional association no arrows on any end of the association

It indicates that we must be able to navigate from an account to the corresponding customer and vice
versa. There are three approaches to bi-directional implementation:
Implement as an attribute in one direction only and perform a search when a backward traversal is
required.
Implement as attributes in both directions.
Implement as a distinct association object, independent of either class.

Question 3:
What is Inheritances? Explain with an example, how Inheritance is shown in class
diagram.
Ans 3
An important concept in object-oriented programming is inheritance. It provides
a way for objects to define relationships with each other.
As the name inheritance suggests an object is able to inherit characteristics from
another object. In more concrete terms, an object is able to pass on its state and
behaviors to its children. For inheritance to work the objects need to have
characteristics in common with each other.
For example, let's say we make a class called "Human" that represents our
physical characteristics. It's a generic class that could represent you, me or
anyone in the world. Its state keeps track of things like number of legs, number
of arms, and blood type. It has behaviors like eat, sleep, and walk. Human is
good for getting an overall sense of what makes us all the same but it can't for
instance tell me about gender differences. For that we'd need to make two new
class types called "Man" and "Woman". The state and behaviors of these two
classes will differ from each other in a lot of ways except for the ones that their
inherit from Human.
Therefore inheritance allows us to encompass the parent class' state and
behaviors into its child. The child class can then extend the state and behaviors
to reflect the differences it represents. The most important aspect of this concept
to remember is that the child class is a more specialized version of the parent.
Superclass
In the relationship between two objects a superclass is the name given to the
class that is being inherited from. It sounds like it's a super duper class but
remember that it's the more generic version. Better names to use might be base
class or simply parent class.
To take a more real world example this time we could have a superclass called
"Person". Its state holds the person's name, address, height and weight and has
behaviors like go shopping, make the bed, and watch TV. We could make two
new classes that inherit from Person called "Student" and "Worker". They are
more specialized versions because although they have names, addresses, watch
TV and go shopping, they also have characteristics that are different from each
other. Worker could have a state that holds a job title and place of employment
whereas Student might hold data on an area of study and an institution of
learning.
What Is a Subclass?
In the relationship between two objects a subclass is the name given to the class
that is inheriting from the superclass. Although it sounds a little more drab,
remember that it's a more specialized version of the superclass. Subclasses can
also be known as derived classes or simply child classes.
In the previous example, Student and Worker are the subclasses.
Number of Subclasses
You can have as many subclasses as you want. There is no limitation to how
many subclasses a superclass can have. Likewise there's no limitation on the
number of levels of inheritance. A hierarchy of classes can be built upon a certain
area of commonality.
In fact, if you look at the Java API libraries you will see many examples of
inheritance. Every class in the APIs is inherited from a class called
java.lang.Object. For example, any time you use a JFrame object you're at the
end of a long line of inheritance:
java.lang.Object
extended by java.awt.Component
extended by java.awt.Container
extended by java.awt.Window
extended by java.awt.Frame
extended by javax.swing.JFrame
In Java, when a subclass inherits from a superclass its known as "extending" the
superclass.
Use of Inheritance
Inheritance allows programmers to re-use code they've already written. In the
Human class example we don't need to create new fields in the Man and Woman
class to hold the blood type because we can use the one inherited from the
Human class.
Another benefit of using inheritance is it also allows us to treat a subclass as if it
was a superclass. For example, let's say a program has created multiple
instances of the Man and Woman objects. The program might need to call the
sleep behavior for all these objects. As the sleep behavior is a behavior of the
Human superclass we can group all the Man and Woman objects together and
treat them as if they were Human objects.

You might also like