Ques 7: Unit 3
Ques 7: Unit 3
Answer
Design Optimization
The analysis model captures the logical information about the system, while
the design model adds details to support efficient information access. Before a
design is implemented, it should be optimized so as to make the
implementation more efficient. The aim of optimization is to minimize the cost
in terms of time, space, and other metrics.
However, design optimization should not be excess, as ease of
implementation, maintainability, and extensibility are also important concerns.
It is often seen that a perfectly optimized design is more efficient but less
readable and reusable. So the designer must strike a balance between the
two.
The various things that may be done for design optimization are −
With each update of the base attribute value, the derived attribute is
also re-computed.
All the derived attributes are re-computed and updated periodically in a
group rather than after each update.
Answer
Structured Analysis and Structured Design (SA/SD) is diagrammatic
notation which is design to help people understand the system. The basic goal
of SA/SD is to improve quality and reduce the risk of System failure. It
establishes concrete management specification and documentation. It focuses
on solidity, pliability and maintainability of system.
Basically the approach of SA/SD is based on the Data Flow Diagram. It is
easy to understand SA/SD but it focuses on well defined system boundary
whereas JSD approach is too complex and does not have any graphical
representation.
SA/SD is combined known as SAD and it mainly focuses on following 3 points:
1. System
2. Process
3. Technology
Answer
Answer:
Sr.
SA/SD OMT
No.
It manages system
It manages a system around
1 around real world
procedures.
objects.
Dominance order is
Dominance order is functional,
3 object, dynamic and
dynamic and object.
functional.
It is much advanced
4 It is a historical approach.
approach.
Decomposition of process to
Decompsition is based
sub-process is not
on objects so different
6 standardized. Different people
people provide similar
provide different
decomposition.
decomposition.
Reusablity of
Reusability of components
components across
7 across projects is less as
projects is more as
compared to in OMT.
compared to SA/AD.
Answer
Implementing an object-oriented concept in a non-object oriented language
requires the following steps :
1. Translate classes into data structures :
i. Each class is implemented as a single contiguous block of attributes. Each
attribute contains a variable. Now an object has state and identity and is
subject to side effects.
ii. A variable that identifies an object must therefore be implemented as a
sharable reference.
2. Pass arguments to methods :
i. Every method has at least one argument. In a non-object-oriented language,
the argument must be made explicit.
ii. Methods can contain additional objects as arguments. In passing an object
as an argument to a method, a reference to the object must be passed if the
value of the object can be updated within the method.
3. Allocate storage for objects :
i. Objects can be allocated statically, dynamically or on a stack.
ii. Most temporary and intermediate objects are implemented as stack-based
variables.
iii. Dynamically allocated objects are used when there number is not known at
compile time.
iv. A general object can be implemented as a data structure allocated on
request at run time from a heap.
4 Implement inheritance in data structures :Following ways are use to
implement data structure for inheritance in non object oriented programming
language
Avoid it.
Flatten the class hierarchy.
Break out separate objects.
5 Implement method resolution : Method resolution is one. main features of
an object-oriented language that is lacking in a non object-oriented language.
Method resolution can be implemented in a following ways
Avoid it.
Resolve methods at compile time.
Resolve methods at run time.
6. Implement associations : Implementing associations in a non oriented
language can be done by :
Answer
Inheritance is an important pillar of OOP(Object Oriented Programming). It is
the mechanism in java by which one class is allow to inherit the features(fields
and methods) of another class.
Important terminology:
Super Class: The class whose features are inherited is known as super
class(or a base class or a parent class).
Sub Class: The class that inherits the other class is known as sub
class(or a derived class, extended class, or child class). The subclass
can add its own fields and methods in addition to the superclass fields
and methods.
Reusability: Inheritance supports the concept of “reusability”, i.e. when
we want to create a new class and there is already a class that includes
some of the code that we want, we can derive our new class from the
existing class. By doing this, we are reusing the fields and methods of
the existing class.
Types of Inheritance
In above diagram, Class B extends only Class A. Class A is a super class and
Class B is a Sub-class.
Multiple Inheritance:
In Multiple Inheritance, one class extending more than one class. Java does
not support multiple inheritance.
As per above diagram, Class C extends Class A and Class B both.
Multilevel Inheritance:
In Multilevel Inheritance, one class can inherit from a derived class. Hence,
the derived class becomes the base class for the new class.
As per above example, all the public and protected members of Class A are
inherited into Class D, first via Class B and secondly via Class C.
Note: Java doesn't support hybrid/Multiple inheritence
Ques 22 Describe the various features object-oriented languages.
Compare any two object-oriented languages.
AKTU 2010-11, Marks 05
Answer
1. Classes
2. Objects
3. Data Abstraction
4. Encapsulation
5. Inheritance
6. Polymorphism
Class
Class represents a real world entity which acts as a blueprint for all the
objects.
We can create as many objects as we need using Class.
Example:
We create a class for “ Student ” entity as below
Student.java
Class Student{
String id;
int age;
String course;
void enroll(){
System.out.println(“Student enrolled”);
}}
Above definition of class contains 3 fields: id,age and course and also it
contains behavior or a method called “ enroll ”.
Object
Abstraction is a process where you show only “relevant” data and “hide”
unnecessary details of an object from the user.
For example, when you login to your bank account online, you enter your
user_id and password and press login, what happens when you press login,
how the input data sent to server, how it gets verified is all abstracted away
from the you.
We can achieve “ abstraction ” in Java using 2 ways
Encapsulation
To inherit a class we use extends keyword. Here class A is child class and
class B is parent class.
class A extends B{
}
Polymorphism
Answer
KEY DIFFERENCE
In abstraction,
While in encapsulation, the data is
implementation complexities
hidden using methods of getters and
are hidden using abstract
setters.
classes and interfaces.
Ques 5 What are the three models in OMT? How is the Object-
Oriented Analysis and design attached with OMT? Explain with an
example.
AKTU 2013-14, Marks 10
Answer
Object Modeling Technique’s Models:
There are three main types of models that has been proposed by OMT:
1. Object Model:
Object Model encompasses the principles of abstraction, encapsulation,
modularity, hierarchy, typing, concurrency and persistence. Object
Model basically emphasizes on the object and class. Main concepts
related with Object Model are classes and their association with
attributes. Predefined relationships in object model are aggregation and
generalization (multiple inheritance).
2. Dynamic Model:
Dynamic Model involves states, events and state diagram (transition
diagram) on the model. Main concepts related with Dynamic Model are
states, transition between states and events to trigger the transitions.
Predefined relationships in object model are aggregation (concurrency)
and generalization.
3. Functional Model:
Functional Model focuses on the how data is flowing, where data is
stored and different processes. Main concepts involved in Functional
Model are data, data flow, data store, process and actors. Functional
Model in OMT describes the whole processes and actions with the help
of data flow diagram (DFD).
Answer:
Object Model
Dynamic Model
Functional Model
Answer
When one class extends more than one classes then this is called multiple
inheritance. For example: Class C extends class A and B then this type of
inheritance is known as multiple inheritance. Java doesn’t allow multiple
inheritance. In this article, we will discuss why java doesn’t allow multiple
inheritance and how we can use interfaces instead of classes to achieve the
same purpose.
Why Java doesn’t support multiple inheritance?
C++ , Common lisp and few other languages supports multiple inheritance
while java doesn’t support it. Java doesn’t allow multiple inheritance to avoid
the ambiguity caused by it. One of the example of such problem is
the diamond problem that occurs in multiple inheritance.
What is diamond problem?
We will discuss this problem with the help of the diagram below: which shows
multiple inheritance as Class D extends both classes B & C. Now lets assume
we have a method in class A and class B & C overrides that method in their
own way. Wait!! here the problem comes – Because D is extending both B
& C so if D wants to use the same method which method would be called (the
overridden method of B or the overridden method of C). Ambiguity. That’s the
main reason why Java doesn’t support multiple inheritance.
Ques 10 Describe physical packaging with example.
AKTU 2010-11, Marks 2.5
Answer
Programs are made of discrete physical units that can be edited, compiled,
imported, or otherwise manipulated. In C and Fortran the units are source
files; In Ada, it is packages. In object oriented languages, there are various
degrees of packaging. In any large project, careful partitioning of an
implementation into packages is important to permit different persons to
cooperatively work on a program.
Packaging include issues:
. Hiding internal information from outside view
. Coherence of entities
. Constructing physical modules.
Notation − Graphically, a package is represented by a tabbed folder. A
package is generally drawn with only its name. However it may have
additional details about the contents of the package. See the following figures.
Answer
In computer hardware and software product development, documentation is
the information that describes the product to its users. It consists of the
product technical manuals and online information (including online versions of
the technical manuals and help facility descriptions). The term is also
sometimes used to mean the source information about the product contained
in design documents, detailed code comments, white papers, and blackboard
session notes.
Documentation is an essential part of any software development process that
records the procedure of making the software. The design decisions need to
be documented for any non–trivial software system for transmitting the design
to others.
Usage Areas
Though a secondary product, a good documentation is indispensable,
particularly in the following areas −
Answer:
Object Oriented Analysis (OOA):
Object Oriented Analysis (OOA) is the first technical activity performed as part
of object oriented software engineering. OOA introduces new concepts to
investigate a problem. It is based in a set of basic principles, which are as
follows-
The above notes principles form the foundation for the OOA approach.
Object Oriented Design (OOD):
An analysis model created using object oriented analysis is transformed by
object oriented design into a design model that works as a plan for software
creation. OOD results in a design having several different levels of modularity
i.e., The major system components are partitioned into subsystems (a system
level “modular”), and data their manipulation operations are encapsulated into
objects (a modular form that is the building block of an OO system.).
In addition, OOD must specify some data organization of attributes and a
procedural description of each operation.
Shows a design pyramid for object oriented systems. It is having the following
four layers.
Ques 2 Write a short note on Object Design.
Answer
In the object-oriented design method, the system is viewed as a collection of
objects (i.e., entities). The state is distributed among the objects, and each
object handles its state data. For example, in a Library Automation Software,
each library representative may be a separate object with its data and
functions to operate on these data. The tasks defined for one purpose cannot
refer or change data of other objects. Objects have their internal data which
represent their state. Similar objects create a class. In other words, each
object is a member of some class. Classes may inherit features from the
superclass.
The different terms related to object design are:
Objects: All entities involved in the solution design are known as objects. For
example, person, banks, company, and users are considered as objects.
Every entity has some attributes associated with it and has some methods to
perform on the attributes.
Classes: A class is a generalized description of an object. An object is an
instance of a class. A class defines all the attributes, which an object can have
and methods, which represents the functionality of the object.
Messages: Objects communicate by message passing. Messages consist of
the integrity of the target object, the name of the requested operation, and any
other action needed to perform the function. Messages are often implemented
as procedure or function calls.
Abstraction: In object-oriented design, complexity is handled using
abstraction. Abstraction is the removal of the irrelevant and the amplification of
the essentials.
Encapsulation: Encapsulation is also called an information hiding concept.
The data and operations are linked to a single unit. Encapsulation not only
bundles essential information of an object together but also restricts access to
the data and methods from the outside world.
Inheritance: OOD allows similar classes to stack up in a hierarchical manner
where the lower or sub-classes can import, implement, and re-use allowed
variables and functions from their immediate superclasses.This property of
OOD is called an inheritance. This makes it easier to define a specific class
and to create generalized classes from specific ones.
Polymorphism: OOD languages provide a mechanism where methods
performing similar tasks but vary in arguments, can be assigned the same
name. This is known as polymorphism, which allows a single interface is
performing functions for different types. Depending upon how the service is
invoked, the respective portion of the code gets executed.
Ques 3 How can we design an algorithm? Explain.
Answer
Algorithm Design
The operations in the objects are defined using algorithms. An algorithm is a
stepwise procedure that solves the problem laid down in an operation.
Algorithms focus on how it is to be done.
There may be more than one algorithm corresponding to a given operation.
Once the alternative algorithms are identified, the optimal algorithm is selected
for the given problem domain. The metrics for choosing the optimal algorithm
are −
Answer
Jackson System Development (JSD) is a method of system development
that covers the software life cycle either directly or by providing a framework
into which more specialized techniques can fit. JSD can start from the stage in
a project when there is only a general statement of requirements.
However many projects that have used JSD actually started slightly later in
the life cycle, doing the first steps largely from existing documents rather than
directly with the users.
Phases of JDS:
JSD has 3 phases:
Modelling Phase:
In the modelling phase of JSD the designer creates a collection of entity
structure diagrams and identifies the entities in the system, the actions they
perform, the attributes of the actions and time ordering of the actions in the life
of the entities.
Specification Phase:
This phase focuses on actually what is to be done? Previous phase provides
the basic for this phase. An sufficient model of a time-ordered world must itself
be time-ordered. Major goal is to map progress in the real world on progress
in the system that models it.
Implementation Phase:
In the implementation phase JSD determines how to obtain the required
functionality. Implementation way of the system is based on transformation of
specification into efficient set of processes. The processes involved in it
should be designed in such a manner that it would be possible to run them on
available software and hardware.
JSD Steps:
Initially there were six steps when it was originally presented by Jackson, they
were as below:
Entity/action step
Initial model step
Interactive function step
Information function step
System timing step
System implementation step
Ques 20 Describe passing arguments to method with example.
AKTU 2012-13, Marks 05
Answer
There are different ways in which parameter data can be passed into
and out of methods and functions. Let us assume that a function B() is
called from another function A(). In this case A is called the “caller
function” and B is called the “called function or callee function”. Also, the
arguments which A sends to B are called actual arguments and the
parameters of B are called formal arguments.
Types of parameters:
Formal Parameter : A variable and its type as they appear in the
prototype of the function or method.
Syntax:
function_name(datatype variable_name)