UNIT - 3 - Assignment Questions With Answers
UNIT - 3 - Assignment Questions With Answers
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 −
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 a system around It manages system around
1
procedures. real world objects.
More importance is on
More importance is on functional
2 object model and less on
model and less on object model.
functional model.
Dominance order is functional, Dominance order is object,
3
dynamic and object. dynamic and functional.
It is much advanced
4 It is a historical approach.
approach.
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 :
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:
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
Describe the various features object-oriented languages. Compare any
two object-oriented languages.
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
(i) Reusability
(ii) Robustness
(iii) Extensibility
(iv) Abstraction
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.
Answer
KEY DIFFERENCE
In abstraction, implementation
While in encapsulation, the data is hidden
complexities are hidden using
using methods of getters and setters.
abstract classes and interfaces.
The objects that help to perform Whereas the objects that result in
abstraction are encapsulated. encapsulation need not be abstracted.
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.
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
The different aspects of packaging are −
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-
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
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 −
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
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)