Object Oriented Programming Paradigm (OOPP)
The ObjectOriented programming paradigm plays an important role in human
computer interface. It has different components that takes real world objects and
performs actions on them, making live interactions between man and the
machine. Following are the components of OOPP −
This paradigm describes a real-life system where interactions are among
real objects.
It models applications as a group of related objects that interact with each
other.
The programming entity is modeled as a class that signifies the collection of
related real world objects.
Programming starts with the concept of real world objects and classes.
Application is divided into numerous packages.
A package is a collection of classes.
A class is an encapsulated group of similar real world objects.
Objects
Real-world objects share two characteristics − They all have state and behavior.
Let us see the following pictorial example to understand Objects.
In the above diagram, the object Dog has both state and behavior.
An object stores its information in attributes and discloses its behavior through
methods. Let us now discuss in brief the different components of object oriented
programming.
Data Encapsulation
Hiding the implementation details of the class from the user through an objects
methods is known as data encapsulation. In object oriented programming, it binds
the code and the data together and keeps them safe from outside interference.
Public Interface
The point where the software entities interact with each other either in a single
computer or in a network is known as pubic interface. This help in data security.
Other objects can change the state of an object in an interaction by using only
those methods that are exposed to the outer world through a public interface.
Class
A class is a group of objects that has mutual methods. It can be considered as the
blueprint using which objects are created.
Classes being passive do not communicate with each other but are used to
instantiate objects that interact with each other.
Inheritance
Inheritance as in general terms is the process of acquiring properties. In OOP one
object inherit the properties of another object.
Polymorphism
Polymorphism is the process of using same method name by multiple classes and
redefines methods for the derived classes.
Example
Object Oriented Modeling of User Interface Design
Object oriented interface unites users with the real world manipulating software
objects for designing purpose. Let us see the diagram.
Interface design strive to make successful accomplishment of users goals with the
help of interaction tasks and manipulation.
While creating the OOM for interface design, first of all analysis of user
requirements is done. The design specifies the structure and components
required for each dialogue. After that, interfaces are developed and tested against
the Use Case. Example − Personal banking application.
The sequence of processes documented for every Use Case are then analyzed for
key objects. This results into an object model. Key objects are called analysis
objects and any diagram showing relationships between these objects is called
object diagram.
Analysis of Algorithms
In theoretical analysis of algorithms, it is common to estimate their complexity in
the asymptotic sense, i.e., to estimate the complexity function for arbitrarily large
input. The term "analysis of algorithms" was coined by Donald Knuth.
Algorithm analysis is an important part of computational complexity theory, which
provides theoretical estimation for the required resources of an algorithm to solve
a specific computational problem. Most algorithms are designed to work with
inputs of arbitrary length. Analysis of algorithms is the determination of the
amount of time and space resources required to execute it.
Usually, the efficiency or running time of an algorithm is stated as a function
relating the input length to the number of steps, known as time complexity, or
volume of memory, known as space complexity.
The Need for Analysis
By considering an algorithm for a specific problem, we can begin to develop
pattern recognition so that similar types of problems can be solved by the help of
this algorithm.
Algorithms are often quite different from one another, though the objective of
these algorithms are the same. For example, we know that a set of numbers can
be sorted using different algorithms. Number of comparisons performed by one
algorithm may vary with others for the same input. Hence, time complexity of
those algorithms may differ. At the same time, we need to calculate the memory
space required by each algorithm.
Analysis of algorithm is the process of analyzing the problem-solving capability of
the algorithm in terms of the time and size required (the size of memory for
storage while implementation). However, the main concern of analysis of
algorithms is the required time or performance. Generally, we perform the
following types of analysis −
Worst-case − The maximum number of steps taken on any instance of
size a.
Best-case − The minimum number of steps taken on any instance of size a.
Average case − An average number of steps taken on any instance of size a.
Amortized − A sequence of operations applied to the input of
size a averaged over time.
To solve a problem, we need to consider time as well as space complexity as the
program may run on a system where memory is limited but adequate space is
available or may be vice-versa. In this context, if we compare bubble
sort and merge sort. Bubble sort does not require additional memory, but merge
sort requires additional space. Though time complexity of bubble sort is higher
compared to merge sort, we may need to apply bubble sort if the program needs
to run in an environment, where memory is very limited.
Rate of Growth
Rate of growth is defined as the rate at which the running time of the algorithm is
increased when the input size is increased.
The growth rate could be categorized into two types: linear and exponential. If the
algorithm is increased in a linear way with an increasing in input size, it is linear
growth rate. And if the running time of the algorithm is increased exponentially
with the increase in input size, it is exponential growth rate.
Proving Correctness of an Algorithm
Once an algorithm is designed to solve a problem, it becomes very important that
the algorithm always returns the desired output for every input given. So, there is
a need to prove the correctness of an algorithm designed. This can be done using
various methods −
Proof by Counterexample
Identify a case for which the algorithm might not be true and apply. If the
counterexample works for the algorithm, then the correctness is proved.
Otherwise, another algorithm that solves this counterexample must be designed.
Proof by Induction
Using mathematical induction, we can prove an algorithm is correct for all the
inputs by proving it is correct for a base case input, say 1, and assume it is correct
for another input k, and then prove it is true for k+1.
Proof by Loop Invariant
Find a loop invariant k, prove that the base case holds true for the loop invariant
in the algorithm. Then apply mathematical induction to prove the rest of
algorithm true.
Abstract Data Type in Data Structures
The Data Type is basically a type of data that can be used in different computer
program. It signifies the type like integer, float etc, the space like integer will take
4-bytes, character will take 1-byte of space etc.
The abstract datatype is special kind of datatype, whose behavior is defined by a
set of values and set of operations. The keyword “Abstract” is used as we can use
these datatypes, we can perform different operations. But how those operations
are working that is totally hidden from the user. The ADT is made of with primitive
datatypes, but operation logics are hidden.
Some examples of ADT are Stack, Queue, List etc.
Let us see some operations of those mentioned ADT −
Stack −
o isFull(), This is used to check whether stack is full or not
o isEmpry(), This is used to check whether stack is empty or not
o push(x), This is used to push x into the stack
o pop(), This is used to delete one element from top of the stack
o peek(), This is used to get the top most element of the stack
o size(), this function is used to get number of elements present into
the stack
Queue −
o isFull(), This is used to check whether queue is full or not
o isEmpry(), This is used to check whether queue is empty or not
o insert(x), This is used to add x into the queue at the rear end
o delete(), This is used to delete one element from the front end of the
queue
o size(), this function is used to get number of elements present into
the queue
List −
o size(), this function is used to get number of elements present into
the list
o insert(x), this function is used to insert one element into the list
o remove(x), this function is used to remove given element from the list
o get(i), this function is used to get element at position i
o replace(x, y), this function is used to replace x with y value