Unit-1 CC
Unit-1 CC
COM IT
COURSE CONTENT
CLASS : II B.COM IT
UNIT :1
Syllabus
Unit - I
Object oriented programming: Software Evolution – OOP paradigm – Concepts, benefits, Object
UNIT-I
• Most of the programmers use only one language & one programming style
• The problem & difficult to choosing a style more appropriate to the problem
• Programming style is defined as a way of organizing the ideas on the basis of some
conceptual model of programming
1. Paradigm
• Paradigm can also be termed as method to solve some problem or do some task.
• Apart from varieties of programming language there are lots of paradigms to fulfil each
and every demand
1. Monolithic programming
2. Procedural programming
3. Structured programming
1. MONOLITHIC PROGRAMMING
2. PROCEDURAL PROGRAMMING
Features
• Programs are organized in the form of subroutines and all data items are global
• STRUCTURED PROGRAMMING
Features
• concept user defined data types & support for modular programming
Disadvantage:
• Decomposition of problem into number entities called objects and builds data and
functions around these objects.
Software Evolution
Many programming approaches have been into play from the time of inventions
of the computer. These techniques include modular programming, top-down programming,
bottom-up programming and structured programming. The primary motivation in each case has
been the concern to handle the increasing complexity of programs that are reliable and
maintainable.
Conventional programming, using high level language such as COBOL, PASCAL and C is
commonly known as Procedure-Oriented Programming (POP). In the procedure Oriented
Approach, the problem is viewed as a sequence of thing to be done such as reading, calculating
and printing. A number of functions are written to accomplish these tasks. The focus is on
function
The technique of hierarchical decomposition has been used to specify the task to be completed
for solving a problem.
It emphasis on doing things. Data is given a second class status even through the
data is the reason for the existence of the program.
Since every function has complete access to the global variables, the new
programmer can corrupt the data accidentally by creating function. If new data is
to be added, all the function needed to be modified to access the data.
OOP POP
Program is divided into objects Program is divided into small chunks based on
depending on the problem. the functions.
Each object controls its own data. Each function contains different data.
The main priority is data rather than Functions are more important than data in a
functions in a program. program.
The functions of the objects are linked via Different parts of a program are
message passing. interconnected via parameter passing.
The major motivating factor in the invention of object-oriented approch is to remove some
of the flaws encountered in the procedural approch. OOP treats data as a critical element in
the program development and does not allow it to flow freely around the systems. It ties
data more closely to the functions that operate on it, and protects it from accidental
modification from outside functions. OOP allows decomposition of a problem into a number
of entities called objects and then builds data and functions around these objects. The data
of an object can be accessed only by the function associated with that object. However,
functions of one object can access the functions of other objects.
Some of the features of object-oriented programming are
Evolution of C++
Class:
The building block of C++ that leads to Object-Oriented programming is a Class. It is a user-
defined data type, which holds its own data members and member functions, which can be
accessed and used by creating an instance of that class. A class is like a blueprint for an object.
For Example: Consider the Class of Cars. There may be many cars with different names and
brand but all of them will share some common properties like all of them will have 4 wheels,
Speed Limit, Mileage range etc. So here, Car is the class and wheels, speed limits, mileage are
their properties.
A Class is a user-defined data-type which has data members and member functions.
Data members are the data variables and member functions are the functions used to
manipulate these variables and together these data members and member functions
define the properties and behaviour of the objects in a Class.
In the above example of class Car, the data member will be speed limit, mileage etc and
member functions can apply brakes, increase speed etc.
Encapsulation:
In normal terms, Encapsulation is defined as wrapping up of data and information under a
single unit. In Object-Oriented Programming, Encapsulation is defined as binding together the
data and the functions that manipulate them.
Consider a real-life example of encapsulation, in a company, there are different sections like the
accounts section, finance section, sales section etc. The finance section handles all the financial
transactions and keeps records of all the data related to finance. Similarly, the sales section
handles all the sales-related activities and keeps records of all the sales. Now there may arise a
situation when for some reason an official from the finance section needs all the data about
sales in a particular month. In this case, he is not allowed to directly access the data of the sales
section. He will first have to contact some other officer in the sales section and then request
him to give the particular data. This is what encapsulation is. Here the data of the sales section
and the employees that can manipulate them are wrapped under a single name “sales section”.
Encapsulation also leads to data abstraction or hiding. As using encapsulation also hides the
data. In the above example, the data of any of the section like sales, finance or accounts are
hidden from any other section.
Abstraction:
Data abstraction is one of the most essential and important features of object-oriented
programming in C++. Abstraction means displaying only essential information and hiding the
details. Data abstraction refers to providing only essential information about the data to the
outside world, hiding the background details or implementation.
Consider a real-life example of a man driving a car. The man only knows that pressing the
accelerators will increase the speed of the car or applying brakes will stop the car but he does
not know about how on pressing accelerator the speed is actually increasing, he does not know
about the inner mechanism of the car or the implementation of accelerator, brakes etc in the
car. This is what abstraction is.
Abstraction using Classes: We can implement Abstraction in C++ using classes. The class
helps us to group data members and member functions using available access specifiers. A
Class can decide which data member will be visible to the outside world and which is not.
Abstraction in Header files: One more type of abstraction in C++ can be header files. For
example, consider the pow() method present in math.h header file. Whenever we need to
calculate the power of a number, we simply call the function pow() present in the math.h
header file and pass the numbers as arguments without knowing the underlying algorithm
according to which the function is actually calculating the power of numbers.
Polymorphism:
The word polymorphism means having many forms. In simple words, we can define
polymorphism as the ability of a message to be displayed in more than one form.
A person at the same time can have different characteristic. Like a man at the same time is a
father, a husband, an employee. So the same person posses different behaviour in different
situations. This is called polymorphism.
An operation may exhibit different behaviours in different instances. The behaviour depends
upon the types of data used in the operation.
Example: Suppose we have to write a function to add some integers, sometimes there are 2
integers, some times there are 3 integers. We can write the Addition Method with the same
name having different parameters, the concerned method will be called according to
parameters.
Inheritance:
The capability of a class to derive properties and characteristics from another class is called
Inheritance. Inheritance is one of the most important features of Object-Oriented
Programming.
Sub Class: The class that inherits properties from another class is called Sub class or Derived
Class.
Super Class:The class whose properties are inherited by sub class is called Base Class or
Super class.
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.
Example: Dog, Cat, Cow can be Derived Class of Animal Base Class.
Dynamic Binding:
In dynamic binding, the code to be executed in response to function call is decided at runtime.
C++ has virtual functions to support this.
Message Passing:
Objects communicate with one another by sending and receiving information to each other. A
message for an object is a request for execution of a procedure and therefore will invoke a
function in the receiving object that generates the desired results. Message passing involves
specifying the name of the object, the name of the function and the information to be sent.
Benefits of OOP
Moving to the advantages of OOP, we would like to say that there are many as this is one of the
core development approaches which is widely accepted. Let’s see what are the advantages of
OOP.
1. Re-usability
It means reusing some facilities rather than building it again and again. This is done with the use
of a class. We can use it ‘n’ number of times as per our need.
2. Data Redundancy
This is a condition created at the place of data storage (you can say Databases)where the same
piece of data is held in two separate places. So the data redundancy is one of the greatest
advantages of OOP. If a user wants a similar functionality in multiple classes he/she can go
ahead by writing common class definitions for the similar functionalities and inherit them.
3. Code Maintenance
This feature is more of a necessity for any programming languages, it helps users from doing re-
work in many ways. It is always easy and time-saving to maintain and modify the existing codes
with incorporating new changes into it.
4. Security
With the use of data hiding and abstraction mechanism, we are filtering out limited data to
exposure which means we are maintaining security and providing necessary data to view.
5. Design Benefits
If you are practicing on OOPs the design benefit a user will get is in terms of designing and fixing
things easily and eliminating the risks (if any). Here the Object Oriented Programs forces the
designers to have a longer and extensive design phase, which results in better designs and
fewer flaws. After a time when the program has reached some critical limits, it is easier to
program all the non-OOP’s one separately.
6. Better productivity
with the above-mentioned facts of using the application definitely enhances its users overall
productivity. This leads to more work done, finish a better program, having more inbuilt
features and easier to read, write and maintain. An OOP programmer cans stitch new software
objects to make completely new programs. A good number of libraries with useful functions in
abundance make it possible.
7. Easy troubleshooting
lets witness some common issues or problems any developers face in their work.
So, many a time it happens that something has gone wrong which later becomes so
brainstorming for the developers to look where the error is. Relax! Working with OOP language
you will know where to look for. This is the advantage of using encapsulation in OOP; all the
objects are self-constrained. With this modality behavior, the IT teams get a lot of work benefits
as they are now capable to work on multiple projects simultaneously with an advantage that
there is no possibility of code duplicity.
8. Polymorphism Flexibility
You behave in a different way if the place or surrounding gets change. A person will behave like
a customer if he is in a market, the same person will behave like a student if he is in a school
and as a son/daughter if put in a house. Here we can see that the same person showing
different behavior every time the surroundings are changed. This means polymorphism is
flexibility and helps developers in a number of ways.
It’s simplicity
Extensibility
9. Problems solving
Decomposing a complex problem into smaller chunks or discrete components is a good
practice. OOP is specialized in this behavior, as it breaks down your software code into bite-
sized – one object at a time. In doing this the broken components can be reused in solutions to
different other problems (both less and more complex) or either they can be replaced by the
future modules which relate to the same interface with implementations details.
A general relatable real-time scenario – at a high level a car can be decomposed into wheels,
engine, a chassis soon and each of those components can be further broken down into even
smaller atomic components like screws and bolts. The engine’s design doesn’t need to know
anything about the size of the tires in order to deliver a certain amount of power (as output)
has little to do with each other.
1. Client-Server Systems
2. Object-Oriented Databases
They are also called Object Database Management Systems (ODBMS). These databases store
objects instead of data, such as real numbers and integers. Objects consist of the following:
Attributes: Attributes are data that defines the traits of an object. This data can be as simple as
integers and real numbers. It can also be a reference to a complex object.
Methods: They define the behavior and are also called functions or procedures.
3. Object Oriented Databases
These databases try to maintain a direct correspondence between the real-world and database
objects in order to let the object retain their identity and integrity. They can then be identified
and operated upon.
Real time systems inherit complexities that makes difficult to build them. Object-oriented
techniques make it easier to handle those complexities. These techniques present ways of
dealing with these complexities by providing an integrated framework which includes
schedulability analysis and behavioral specifications.
It’s difficult to model complex systems due to the varying specification of variables. These are
prevalent in medicine and in other areas of natural science, such as ecology, zoology, and
agronomic systems. Simulating complex systems requires modelling and understanding
interactions explicitly. Object-oriented Programming provides an alternative approach for
simplifying these complex modelling systems.
OOP also helps in laying out a framework for Hypertext. Basically, hypertext is similar to regular
text as it can be stored, searched, and edited easily. The only difference is that hypertext is text
with pointers to other text as well.
Hypermedia, on the other hand, is a superset of hypertext. Documents having hypermedia, not
only contain links to other pieces of text and information, but also to numerous other forms of
media, ranging from images to sound.
7. Neural Networking And Parallel Programming
These include formal as well as informal electronic systems primarily concerned with
information sharing and communication to and from people inside as well as outside the
organization. Some examples are:
Email
Word processing
Web calendars
Desktop publishing
9. CIM/CAD/CAM Systems
OOP can also be used in manufacturing and design applications as it allows people to reduce
the effort involved. For instance, it can be used while designing blueprints, flowcharts, etc. OOP
makes it possible for the designers and engineers to produce these flowcharts and blueprints
accurately.
These are computer applications which are developed to solve complex problems pertaining to
a specific domain, which is at a level far beyond the reach of a human brain.It has the following
characteristics:
Reliable
Highly responsive
Understandable
High-performance
POSSIBLE 8 MARKS
POSSIBLE 1 MARK