0% found this document useful (0 votes)
4 views31 pages

Ques 7: Unit 3

The document discusses design optimization, structured analysis and design, and object-oriented programming concepts. It emphasizes the importance of balancing optimization with maintainability, outlines the structured analysis and design approach, and compares methodologies like SA/SD and OMT. Additionally, it covers object-oriented principles such as inheritance, reusability, robustness, extensibility, and the differences between abstraction and encapsulation.

Uploaded by

Yash Agarwal
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)
4 views31 pages

Ques 7: Unit 3

The document discusses design optimization, structured analysis and design, and object-oriented programming concepts. It emphasizes the importance of balancing optimization with maintainability, outlines the structured analysis and design approach, and compares methodologies like SA/SD and OMT. Additionally, it covers object-oriented principles such as inheritance, reusability, robustness, extensibility, and the differences between abstraction and encapsulation.

Uploaded by

Yash Agarwal
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/ 31

Unit 3

Ques 7 What do you mean by the Optimization of design? Discuss the


design optimization with suitable examples using diagrams.
AKTU 2012-13, Marks 05

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 −

 Add redundant associations


 Omit non-usable associations
 Optimization of algorithms
 Save derived attributes to avoid re-computation of complex expressions
Addition of Redundant Associations
During design optimization, it is checked if deriving new associations can
reduce access costs. Though these redundant associations may not add any
information, they may increase the efficiency of the overall model.
Omission of Non-Usable Associations
Presence of too many associations may render a system indecipherable and
hence reduce the overall efficiency of the system. So, during optimization, all
non-usable associations are removed.
Optimization of Algorithms
In object-oriented systems, optimization of data structure and algorithms are
done in a collaborative manner. Once the class design is in place, the
operations and the algorithms need to be optimized.
Optimization of algorithms is obtained by −

 Rearrangement of the order of computational tasks


 Reversal of execution order of loops from that laid down in the
functional model
 Removal of dead paths within the algorithm
Saving and Storing of Derived Attributes
Derived attributes are those attributes whose values are computed as a
function of other attributes (base attributes). Re-computation of the values of
derived attributes every time they are needed is a time–consuming procedure.
To avoid this, the values can be computed and stored in their computed
forms.
However, this may pose update anomalies, i.e., a change in the values of
base attributes with no corresponding change in the values of the derived
attributes. To avoid this, the following steps are taken −

 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.

Ques 15 Describe the structured analysis and structured design


approach with an example.
AKTU 2012-13, marks 10

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

SA/SD involves 2 phases:

1. Analysis Phase: It uses Data Flow Diagram, Data Dictionary, State


Transition diagram and ER diagram.
2. Design Phase: It uses Structure Chart and Pseudo Code.

Ques 16 Compare the OMT methodology with SA/SD methodology.


Explain with suitable example.
AKTU 2014-15, Marks 10

Answer
Answer:

Sr.
SA/SD OMT
No.
It manages system
It manages a system around
1 around real world
procedures.
objects.

More importance is on More importance is on


2 functional model and less on object model and less
object model. on functional model.

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.

It clearly marks the system


System boundries can
boundaries across which
be easily extending by
5 software procedures should
adding new objects,
communicate with real world. It
relationships.
is difficult to extend boundries.

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.

Not easily modifiable and Easily modifiable and


8
extensible. extensible.

Used when data is


Used when functions are more
9 more important than
important than data.
functions.

Difficult to merge programming It better integrates data


code organized about functions with programming code
10
while database is organized as database is
around data. organized around data.

Ques 18 How do you map the object-oriented concepts using non


object-oriented languages? Explain with an example.
AKTU 2010-11, 2011-12, Marks 05

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 :

 Mapping them into pointers.


 Implementing them directly as association container objects.
7. Deal with concurrency :

 Most languages do not explicitly support concurrency.


 Concurrency is usually needed only when more than one external event
occurs, and the behaviour of the program depends on their timing.
8. Encapsulate internal details of classes :

 Object-oriented languages provide constructs to encapsulate


implementation.
 Some of this encapsulation is lost when object-oriented concepts
translated into a non-object-oriented language, but we can still take
advantage of the encapsulation facilities provided by language
Ques 21 Describe implementation of inheritance with example.
AKTU 2012-13, Marks 05

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

There are Various types of inheritance in Java:


Single Inheritance:
In Single Inheritance one class extends another class (one class only).

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 shown in diagram Class C is subclass of B and B is a of subclass


Class A.
Hierarchical Inheritance:
In Hierarchical Inheritance, one class is inherited by many sub classes.
As per above example, Class B, C, and D inherit the same class A.
Hybrid Inheritance:
Hybrid inheritance is a combination of Single and Multiple inheritance.

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

Features of object-oriented languages:

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

Object Oriented Programming system(OOPS) is designed based on the


concept of “Object”. It contains both variables (used for holding the data)
and methods(used for defining the behaviors).
We can create any number of objects using this class and all those objects
will get the same fields and behavior.
Student s1 = new Student();
Now we have created 3 objects s1,s2 and s3 for the same class “ Student
”.We can create as many objects as required in the same way.
We can set the value for each field of an object as below,
s1.id=123;
s2.age=18;
s3.course=”computers”;
Abstraction

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

 Encapsulation is the process of binding object state(fields) and


behaviors(methods) together in a single entity called “Class”.
 Since it wraps both fields and methods in a class, it will be secured from
the outside access.
 We can restrict the access to the members of a class using access
modifiers such as private,protected and public keywords.
 When we create a class in Java, it means we are doing encapsulation.
 Encapsulation helps us to achieve the re-usability of code without
compromising the security.
Inheritance

 One class inherits or acquires the properties of another class.


 Inheritance provides the idea of reusability of code and each sub class
defines only those features that are unique to it, rest of the features can
be inherited from the parent class.

1. Inheritance is a process of defining a new class based on an existing


class by extending its common data members and methods.
2. It allows us to reuse of code, it improves reusability in your java
application.
3. The parent class is called the base class or super class. The child
class that extends the base class is called the derived class or sub
class or child class.

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

 It is the concept where an object behaves differently in different


situations.
 Since the object takes multiple forms, it is called Polymorphism.
 In java, we can achieve it using method overloading and method
overriding.
 There are 2 types of Polymorphism available in Java,
Method overloading
In this case, which method to call will be decided at the compile time itself
based on number or type of the parameters. Static/Compile Time
polymorphism is an example for method overloading.
Method overriding
In this case, which method to call will be decided at the run time time based
on what object is actually pointed by the reference variable.
Ques 23 Explain each of the following term with in reference to
object-oriented programming style with an example
(i) Reusability
(ii) Robustness
(iii) Extensibility
(iv) Abstraction
AKTU 2010- 11,Marks 05 ,2011-12, Marks 10
Answer
(i)Reusability:
Reusable software reduces design, coding, and testing cost by amortizing
effort over several designs. Reducing the amount of code also simplifies
understanding, which increases the likelihood that the code is correct. Reuse
is possible in conventional languages, but object-oriented languages greatly
enhance the possibility of code reuse.
(ii)Robustness
A method is robust if it does not fail even if it receives improper parameters.
Robustness against internal bugs may be traded off against efficiency.
Robustness against user errors should never be sacrificed.
Protect against errors. The software should protect itself against incorrect user
input. Incorrect user input should never cause a crash. Any method that
accepts user input must validate input that could cause trouble.
Optimize after the program runs. Avoid optimizing more of the program than
you have to, as optimization compromises extensibility, reusability, and
understandability. If methods are properly encapsulated, they can be replaced
with optimized versions without affecting the rest of the program.
Validate arguments. External operations, those available to users of the class,
must rigorously check their arguments to prevent failure. But internal methods
may assume their arguments are valid for efficiency reasons. Public methods
must take more care to check the validity of arguments because external
users are more likely to violate restrictions on arguments Internal, or private,
methods can often assume preconditions since the implementor has tighter
control and can rely on the public methods that call them for error checking.
Avoid predefined limits. When possible use dynamic memory allocation to
create data structures that do not have predefined limits.
(iii)Extensibility:
Extensibility is a system design principle where the implementation takes
future growth into consideration. It is a systemic measure of the ability to
extend a system and the level of effort required to implement the extension.
Extensions can be through the addition of new functionality or through
modification of existing functionality. The central theme is to provide for
change typically enhancements while minimizing impact to existing system
functions.
(iv)Abstraction:
The goal of abstraction is to isolate those aspects that are important for some
purpose and suppress those aspects that are unimportant. Abstraction must
always be for some purpose, because the purpose determines what is, and is
not, important. Many different abstractions of the same thing are possible,
depending on the purpose for which they are made.

Ques 24 Compare abstraction and encapsulation.


AKTU 2015-16, Marks 05

Answer

KEY DIFFERENCE

 Abstraction shows only useful data by providing the most necessary


details whereas Encapsulation wraps code and data for necessary
information.
 Abstraction is focused mainly on what should be done while
Encapsulation is focused on how it should be done.
 Abstraction hides complexity by giving you a more abstract picture while
Encapsulation hides internal working so that you can change it later.
 Abstraction helps you to partition the program into many independent
portions whereas Encapsulation is easy to change with new
requirements.
 Abstraction solves problem at design level while Encapsulation solves
problem at implementation level.
 Abstraction hides the irrelevant details found in the code whereas
Encapsulation helps developers to organize the entire code easily.
Difference between Abstraction and Encapsulation:
Abstraction Encapsulation
Abstraction is the process or
While encapsulation is the process or
method of gaining the
method to contain the information.
information.

In abstraction, problems are While in encapsulation, problems are


solved at the design or solved at the implementation level.
interface level.

Whereas encapsulation is a method to


Abstraction is the method of
hide the data in a single entity or unit
hiding the unwanted
along with a method to protect
information.
information from outside.

We can implement Whereas encapsulation can be


abstraction using abstract implemented using by access modifier
class and interfaces. i.e. private, protected and public.

In abstraction,
While in encapsulation, the data is
implementation complexities
hidden using methods of getters and
are hidden using abstract
setters.
classes and interfaces.

The objects that help to


Whereas the objects that result in
perform abstraction are
encapsulation need not be abstracted.
encapsulated.

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).

Ques 6 Describe the relation of functional model, object model and


dynamic model. What is the relationship and difference between OOA
and OOD.
AKTU 2014-15, Marks 10

Answer:

Object Model

1. It represents the static structure of the application.


2. It specifies to whom it happens to.
3. Operations in an object model corresponds to events in dynamic model
and functions in functional model.
4. It is represented using class diagrams.

Dynamic Model

1. It represents the essential behavior of the application.


2. It specifies when it happens.
3. Dynamic model describes the control structure of the objects. It defines
decisions which are dependents of object values and which can cause
action to change object values and invoke their functions.
4. It is represented using state diagrams.

Functional Model

1. It represents what the application does and not how it does.


2. It specifies what happens.
3. It describes functions to be invoked by operations in object model and
actions in dynamic models.
4. It is represented using data flow diagrams.
Ques 13 What do you mean by multiple inheritances? Explain it with
example. Can you implement multiple inheritances in java?
AKTU 2010-11, Marks 05

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.

Ques 11 What are the different aspects of packaging?


Answer
The different aspects of packaging are −

 Hiding Internal Information from Outside View − It allows a class to


be viewed as a “black box” and permits class implementation to be
changed without requiring any clients of the class to modify code.
 Coherence of Elements − An element, such as a class, an operation,
or a module, is coherent if it is organized on a consistent plan and all its
parts are intrinsically related so that they serve a common goal.
 Construction of Physical Modules − The following guidelines help
while constructing physical modules −
o Classes in a module should represent similar things or
components in the same composite object.
o Closely connected classes should be in the same module.
o Unconnected or weakly connected classes should be placed in
separate modules.
o Modules should have good cohesion, i.e., high cooperation
among its components.
o A module should have low coupling with other modules, i.e.,
interaction or interdependence between modules should be
minimum.

Ques 12 What do you mean by


documentation? What are the various considerations in
documentation designing? Explain.
AKTU 2011-12, Marks 05

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 −

 In designing software that is being developed by a number of


developers
 In iterative software development strategies
 In developing subsequent versions of a software project
 For evaluating a software
 For finding conditions and areas of testing
 For maintenance of the software.
Contents
A beneficial documentation should essentially include the following contents −

 High–level system architecture − Process diagrams and module


diagrams
 Key abstractions and mechanisms − Class diagrams and object
diagrams.
 Scenarios that illustrate the behavior of the main aspects −
Behavioural diagrams
Features
The features of a good documentation are −

 Concise and at the same time, unambiguous, consistent, and complete


 Traceable to the system’s requirement specifications
 Well-structured
 Diagrammatic instead of descriptive
Ques 1 Write a short note on Object-Oriented Analysis and Object-
Oriented Design.

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-

1. The information domain is modeled.


2. Behavior is represented.
3. Function is described.
4. Data, functional, and behavioral models are divided to uncover greater
detail.
5. Early models represent the essence of the problem, while later ones
provide implementation
details.

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 −

 Computational Complexity − Complexity determines the efficiency of


an algorithm in terms of computation time and memory requirements.
 Flexibility − Flexibility determines whether the chosen algorithm can be
implemented suitably, without loss of appropriateness in various
environments.
 Understandability − This determines whether the chosen algorithm is
easy to understand and implement.
Optimization of Algorithms
In object-oriented systems, optimization of data structure and algorithms are
done in a collaborative manner. Once the class design is in place, the
operations and the algorithms need to be optimized.
Optimization of algorithms is obtained by −
Rearrangement of the order of computational tasks
Reversal of execution order of loops from that laid down in the functional
model
Removal of dead paths within the algorithm
Ques 8 Describe implementation of control in OOD.
Answer
Implementation of Control
The object designer may incorporate refinements in the strategy of the
state–chart model. In system design, a basic strategy for realizing the dynamic
model is made. During object design, this strategy is aptly embellished for
appropriate implementation.
The approaches for implementation of the dynamic model are −

 Represent State as a Location within a Program − This is the


traditional procedure-driven approach whereby the location of control
defines the program state. A finite state machine can be implemented
as a program. A transition forms an input statement, the main control
path forms the sequence of instructions, the branches form the
conditions, and the backward paths form the loops or iterations.
 State Machine Engine − This approach directly represents a state
machine through a state machine engine class. This class executes the
state machine through a set of transitions and actions provided by the
application.
 Control as Concurrent Tasks − In this approach, an object is
implemented as a task in the programming language or the operating
system. Here, an event is implemented as an inter-task call. It
preserves inherent concurrency of real objects.
Ques 9 What do you mean by object representation.
Answer
Object Representation
Once the classes are identified, they need to be represented using object
modelling techniques. This stage essentially involves constructing UML
diagrams.
There are two types of design models that need to be produced −
 Static Models − To describe the static structure of a system using class
diagrams and object diagrams.
 Dynamic Models − To describe the dynamic structure of a system and
show the interaction between classes using interaction diagrams and
state–chart diagrams.
Ques 17 Write a short note on Jackson structured development.
AKTU 2011-12, 2012-13, 2013-14, Marks 05

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)

 Actual Parameter : The variable or expression corresponding to a


formal parameter that appears in the function or method call in the
calling environment.
Syntax:
func_name(variable name(s));
 Pass By Value: Changes made to formal parameter do not get
transmitted back to the caller. Any modifications to the formal parameter
variable inside the called function or method affect only the separate
storage location and will not be reflected in the actual parameter in the
calling environment. This method is also called as call by value.
 Java in fact is strictly call by value.

 Call by reference(aliasing): Changes made to formal parameter do get


transmitted back to the caller through parameter passing. Any changes
to the formal parameter are reflected in the actual parameter in the
calling environment as formal parameter receives a reference (or
pointer) to the actual data. This method is also called as call by
reference. This method is efficient in both time and space.

You might also like