You are on page 1of 45

Module-I

Chapter-1

By
Rani Dubey
An Introduction to Programming
(Chapter-1)
• Different Types of programming languages
• Description of compiler and Interpreter
• Object Oriented Programming
• Advantage of Object Oriented Programming
• Features of Object Oriented Programming
Different Types of programming languages
Available (18-08-2020)
• Name?
–C
– C++
– Python
– C Sharp
– Matlab
– Java
– HTML
– Fortran(Formula Translation)
– COBOL (Common Business Oriented Language)
Categorise Programming approaches
• Monolothical programming
– Within one block we complete the code required
• Modular Programming
– Simple
– Efficiency
– Small(managable)
– Rectifying error is easy
– (Dividing the task into subtasks)
– Examples of constructs used in Programming languages
• Subroutine
• Procedure
• function
• Structural Programming
– A modular program with Single entry and single exit point
– C is a structural programming Language
• Object oriented Programming
Description of compiler and
Interpreter (19-08-2020)(Translator)
• Compiler
– Compiler is a computer program that translates
source code from a high-level programming
language to a lower level language to create an
executable program.
– E.g. C, C++, Pascal, Cobol, Fortran etc.
Interpreter
• Interpreter
– An interpreter is a computer program that directly
executes instructions written in a programming
language or scripting language
– Step wise translation and execution of the Source
program
– E.g. Basic, Perl, Python, Matlab
Compiler Vs. Interpreter
Sl. No. Compiler Interpreter
1 Translate High level language program to Translate and execute high level language
Low level Language program program
2 Accepts the program as a whole then Accepts one statement (instruction) at a
translate into one executable file to run time if successful in execution then
accept another
3 Shows all the Errors if any in the program Stop after finding one error, does not
show all the errors
4 Once translated no need for further Each time needs to run the program will
translation can run directly the already be translated and run step by step
translated program
5 Compiler is a big program took more Interpreter occupies less amount of
amount of memory memory
6 Compiler is fast Interpreter is slow
7 Debugging is difficult Debugging is easy
8 Examples are C, C++,Pascal, Cobol Examples are Python, Basic, perl, Matlab
Object Oriented Programming
• Object
– Why
– What
– how

• Oriented
– way of approach
• Programming
– Set/Sequence of instructions
Brief Overview
• Types of Languages
– 1st generation (Binary)
– 2nd generation (Assembly language)
• Instead of using binary codes we write mnemonics(ADD), values(5)
• Translator(Assembler)
• Machine dependent
• Programmer must have the knowledge hard ware
– 3rd generation (High level language) c,…
• Paradigms of programming
• Translators(interpreter and Compiler)
• Why Object Oriented Programming
• The real world behaviour is not reflected
properly
• What is required
• How(emphasize)(stepwise)
Features/Principles of OOP
• Abstraction
• Object
• Class
• Encapsulation
• Polymorphism
• Inheritance
• Data Hiding
Abstraction
Abstraction
• Humans manage complexity through
abstraction
• Dictionary meaning
– the quality of dealing with ideas rather than events.
– freedom from representational qualities in art.
• abstraction is the process of hiding background
details and showing only essential features
pertinent to the application
Object
• Object
– Anything having physical or logical existence may
be referred as an object
• object
– Attributes + Behaviours
– Properties + Behaviour
– Data members + Functions
• Instance of a class
Class
• Blue print, Template
• N no of objects can be created through a class

• A class is a blueprint that defines the variables and


the methods common to all objects of a certain
kind
• A Class is a user defined data-type which has data
members and member functions
– Data members are the data variables(property or
attribute)
– Member functions (behaviours)are the functions used
to manipulate these variables
• When a class is defined, no memory is
allocated but when it is instantiated (i.e. an
object is created) memory is allocated.

Class - Object
Class
• Real world
– Objects of similar type are categorised as class
– Class is a collection of objects
• Programming
– Class needs to be defined first(Templet, blue print)
– Object is the instance of a class
Encapsulation
• Dictionary
– the action of enclosing something in or as if in a
capsule.
– Putting inside a cover
• Combining both attributes and behaviour
together as a single template(Class)
• Encapsulation is a principle of wrapping data
(variables) and code together as a single unit
• encapsulation refers to the bundling of data with
the methods that operate on that data, or the
restricting of direct access to some of an object's
components.
Data hiding
• Hiding the data members to be accessed
directly from outside(Objects in application)
• Achieves security
• In computer science, information hiding is the principle
of segregation of the design decisions in a computer
program that are most likely to change, thus protecting
other parts of the program from extensive modification
if the design decision is changed
• protects object integrity by preventing unintended or
intended changes
• Data hiding also reduces system complexity for
increased robustness by limiting interdependencies
between software components
Inheritance
• Inheritance is an OOPS concept in which one
object acquires the properties and behaviors
of the parent object
• It’s creating a parent-child relationship
between two classes
• With inheritance, we can reuse the fields and
methods of the existing class
• It offers robust and natural mechanism for
organizing and structure of any software
Polymorphism
• Poly means many
• Morphism means variance of form
• Polymorphism is the ability of an object to
take on many forms
• Add(“Chiku”,”Saran”)
• Add(25,63)
• Add(2.3,5.6)
• Polymorphism refers to the ability of a variable,
object or function to take on multiple forms.
• For example, in English, the verb run has a
different meaning if you use it with a laptop, a
foot race, and business.
• Here, we understand the meaning of run based
on the other words used along with it.
• The same also applied to Polymorphism.
• If one task is performed in different ways, it is
known as polymorphism.
polymorphism
Object based Vs. Object Oriented
Object based Languages Object Oriented Languages
Supports all features except inheritance , supports all the features of OOPs
polymorphism(Dynamic binding) (Abstraction, Encapsulation, Inheritance,
Polymorphism)
Objects inherit their code and data Objects can be created through the
directly from other "template" objects defined classes
Java script, Visual Basic are the examples C#, Java are the examples of object
of object bases languages oriented languages
Advantages of Object Oriented
Programming
• Reusability
• Data Redundancy
• Code Maintenance
• Security
• Design Benefits
• Better productivity
• Easy troubleshooting
• Polymorphism Flexibility
• Problems solving
Re-usability
• Reusing some facilities rather than building it
again and again
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.
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.
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
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
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.
Easy troubleshooting
• 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.
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.
• Simplicity
• Extensibility
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
Advantages
• Simplicity: software objects model real-world objects, so the
complexity is reduced and the program structure is very clear;
• Modularity: each object forms a separate entity whose internal
workings are decoupled from other parts of the system.
• Modifiability: it is easy to make minor changes in the data
representation or the procedures in an OO program. Changes inside
a class do not affect any other part of a program since the only
public interface that the external world has to a class is through the
use of methods;
• Extensibility: adding new features or responding to changing
operating environments can be solved by introducing a few new
objects and modifying some existing ones;
• Maintainability: objects can be maintained separately, making
locating and fixing problems easier.
• Re-usability: objects can be reused in different programs
• OOP provides a clear modular structure for
programs.
• It is good for defining abstract data types.
• Implementation details are hidden from other
modules.
• It is easy to maintain and modify existing
code.
• It implements real life scenario.
Advantages for software
• Improved software-development productivity
– Because of modularity, extensibility, and reusability object-
oriented programming provides improved software-
development productivity over traditional procedure-based
programming techniques
• Improved software maintainability
– Since the design is modular, part of the system can be
updated in case of issues without a need to make large-
scale changes
• Faster development
– Reuse enables faster development ,rich libraries of objects,
and code developed during projects is also reusable in
future projects
Advantages for software Cont….
• Lower cost of development
– The reuse of software also lowers the cost of
development
– Typically, more effort is put into the object-oriented
analysis and design, which lowers the overall cost of
development
• Higher-quality software
– Faster development of software and lower cost of
development allows more time and resources to be
used in the verification of the software
– Although quality is dependent upon the experience of
the teams, object oriented programming tends to
result in higher-quality software.

You might also like