Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
7 views

Programming languages

The document provides an overview of programming languages, defining key concepts such as programs, software, and programming paradigms. It distinguishes between low level, assembly, and high level languages, and explains the differences between procedure-oriented and object-oriented programming. Additionally, it details the structure of classes and objects, illustrating how they are used to encapsulate attributes and behaviors in programming.

Uploaded by

dssamana1011
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

Programming languages

The document provides an overview of programming languages, defining key concepts such as programs, software, and programming paradigms. It distinguishes between low level, assembly, and high level languages, and explains the differences between procedure-oriented and object-oriented programming. Additionally, it details the structure of classes and objects, illustrating how they are used to encapsulate attributes and behaviors in programming.

Uploaded by

dssamana1011
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 35

Introduction to Programming

Languages
Program:-
A computer program is a set of instructions
arranged in a step by step process based on
some algorithm to perform a specific task.

Software: -
Software is a collection of programs and data
files that are designed to perform some
operations.
Programming Language: -

Programming language is
a language developed for
writing programs for a
computer in a well-
defined way and with a
set of rules.
Types of
Programming
Languages

• Low level language

• Assembly language

• High level language


➢Low Level Language:
Low level language is also called as machine level language where instructions
are written in binary code(using 1’s and 0’s). These instructions will be
executed directly.
➢Assembly Language:
In assembly language, programs are written using symbolic names called
mnemonics for performing operations. An assembler is a software which
converts assembly language program to machine language.
➢High Level Language:
High level languages use English like keywords, constructs for sequence and
use of variables and constants. Eg:-C, C++, Python.
Translators

❖The program written in High Level Language is called(Source Code).


❖Program converted into machine language is called(Object Code).
Differences
between
compiler and
Interpreter
Programming Paradigm
➢ Programming paradigm is an approach to programming
and refers to the style of writing programs.

➢Computer program consists of 2 elements - code and data.

CODE DATA PROGRAM


A computer program can be organized around
→its code or around its data.
The two types of Programming paradigms are

❑Procedure Oriented Programming.


❑Object Oriented Programming.
Procedure Oriented Programming
(Process Centric Approach)
Procedure
Oriented
Programming:-
(Organised
around
process)
The problem is divided into small programs called
functions(procedures or subroutines).

Procedure A program written in procedural language contain one or


more procedures.
Oriented
Programming The primary focus stays on the functions which will be
used to accomplish the task.
(Organised
around a These functions can be invoked from anywhere between
the program structure.
Process)
Data move freely around the system from one function to
another leading to data loss.
Example:- BASIC, Pascal, Fortran.
Limitations

Procedure The focus is on processing, the emphasis is on doing things.

Oriented Procedural languages are difficult to relate with the real-world


objects. As the code gets larger, maintenance of the program

Programming becomes a problem.

(Organised Most functions share global data leaving data at risk of corruption.

around a The module in a procedural language is dependent on each other so


Process) that reusability is restricted.

Procedural language code is not flexible to change. Since they are


interlinked ,the complete program should be changed if there is any
error.
Object Oriented
Programming
Construction of an office building

Objects involved for designing the software


model are:-
a) Paint object
b) Interior design object
c) Plumbing object
d) flooring object
Object Oriented Programming
(Data Centric Approach)
Object Oriented Programming
(Data Centric Approach)
In Object Programming Concepts, computer programs are
designed by using objects that interact with one another. For
example:-
➢ An online shopping system might have objects such as
shopping cart, customer, product, etc.
➢ A banking system consists of objects such as customer,
account, employee, etc.

Examples of Object Oriented Programming languages are


C++,java, python, Ruby, perl, R, swift, etc
❑ It is a programming paradigm
based on the concept of “objects”.
Object Oriented ❑The object-oriented approach
views a problem in terms of objects
Programming involved rather than procedure for
doing it.
( Organised ❑Software is developed by breaking
the application into components
around data) called objects.
❑An object contains data and the
code to perform operations.
Objects are basic elements of
Object Oriented Programming.

Object:-
An object is a real world
entity having some
characteristics and
behaviour.
It has its own unique
identity.
Object Characteristics Behaviour
(Attributes)
Table Flat Top, Made of Wood, Keep_things
colour
Fan 3 blades, 1 handle, Circulates_air,
colour , motor exhaust, cooling
purpose
Inspection of Keyboard Plastic, colour, no of enter data, give
an object keys, cable commands

Pen Colour of the case, write, scribble,


colour of the ink ,nib draw
material
Motor Wheels, handle, side applybreaks,
Bike mirrors, seat, engine, accelerate
gears etc
Objects
Object Name:- Student Object Name:- dog Object Name:- water bottle

Attributes:- Name, rollno, address, etc Attributes:- colour, breed, etc Attributes:- material, colour, capacity

Behaviour:- read, play, etc Behaviour:- barking, wagging tail etc Behaviour:- filling, open,close etc

Object Name:- car Object Name:- TV

Attributes:- modelno, colour, currentspeed, Attributes:- model, screensize, display, etc

etc
Behaviour:- watching, changechannel,
increasevolume, etc
Behaviour:- drive, applybreak, changegear,
slow down, turn left/right etc
More examples of an object

Bird smartphone

Name: parrot Name: iphone


colour: green colour: grey
Attributes Attributes
habitat: garden Price: Rs 45000
:

fly( ) call( )
beakWiping( ) behaviour createAccount( ) behaviour
wingFlapping( ) sendMessage( )
What is a class?

The class is a blueprint of an object and it is the


description and definition of an object.
class
Class is a blueprint or template that defines the attributes and behaviour to
create multiple objects that has its own unique identity. For example:-
One class, multiple objects….
Once a class is created, using single class we can create any number of objects.
Classes and objects
Using blue print (class) we create objects........

Class car

OBJECTS
How to Create a class?

To create a class first, we need to find the following….

Name - What is it ?
Student, Employee, BankAccount, Document, Car, Box…..
Characteristics/
Attributes - What describes it ? Properties/data
name, salary, balance, size, color, width…..
Operations
Behavior - What can it do ? /Methods
read, play, search, save, create, print, close, open, deposit…..
Example class

Creating a Box class

Name - Box

Attributes - length, breadth, height

Behaviour - open( ), close( ), calculateArea()


Example class

Box
ClassName

List
Of
length
Attributes
.breadth
.height

List
Of
open( )
Operations
close( ) Box1 Box2 Box3
.calculateArea()
.

class Objects (instances)


Example class

Creating a Student class

Name - Student

Attributes - RollNo,name,contact_no, sub1,sub2,sub3

Behaviour - accept( ), calculateTotal( ), editContact_no( ), calculate_Average( )


Example class

Student
ClassName
Rahul Jayasree
name Asha 67
List 12
RollNo 34 9980023123
Of 9023412345
contact_no 9900192345 89
Attributes 78
56 72
.sub1 80
78 44
.sub2 87
sub3 98

List
accept( )
Of
calculateTotal( )
Operations Rahul Asha Jayasree
edit_contact_no( )
.
calculate_Average( )
.

class Objects (instances)


Example class

Creating a Bank Account class

Name - BankAccount

Attributes - name, AccNo, balance, dateOpened, accountType, branch

Behaviour - open( ), close( ), deposit( ), withdraw( )


Example class

ClassName
BankAccount

Rahul Asha Jayasree


List
name
23456 54321 67894
Of
accountNumber
25000 1800 15000
Attributes
balance
3/6/2020 3/6/2013 23/5/2014
.dateOpened
Savings Savings Current
.accountType
Delhi Bengaluru Chennai
branch

List
open( )
Of
close( )
Operations RahulAcct AshaAcct JayaAcct
deposit( )
.
withdraw( )
.

class Object (instance)


Class :- Object Factory
➢Class contains all the information(attributes and behaviour) which is needed
to create an object.
➢Class is used to create multiple objects having attributes and behaviour.

Object :- (Instance)
➢Object is a representation of a class that includes the characteristics and
behaviour defined within the class.

➢An object has its own unique identity.


Quick Recap
Class is a template or blueprint used to create multiple instances. Each instance
of a class is called object.

Example 1:
class: House
Attributes: Address, Color, Area
Behavior: Open door, close door

Example 2:
class: car
Attributes: Model,colour, reg_No
Behavior: applyGear(), drive(), brake()

You might also like