Intro to Programming
Programming language is a language in which develop programs
program is a set of instructions - on what to do & how to do a task
Computer is a dumb machine that does nothing until you tell it what to do and how to do with the help of a program.
Levels of programming language
----------------------------------------
computer understands only binary language - (binary means it is made up of only two things - 0 and 1) - programming in binary language is very difficult and time consuming
1. Low level or Machine language - programming done with 0's and 1's
very fast and efficient - very difficult for developers
2. Middle level language - Consists some keywords - mnemonics - we can program using mnemonics
ADD, MUL, STO, MOV - little slower than low level , translation needed, time consuming
a bit easier for programmer
Ex. 8086 - Microprocessors
3. High level language - English like language - speed is low, translation needed,
easy for developers
Ex. C, C++, Java, Python etc.
We need translators which convert middle or high level language to low level language. This job is done by software
1. Compiler - translates the source code to binary all at once
2. Interpreter - translates the source code line by line
we need software to develop the code and also need software to translate code
Software --> is a set of programs
1. System Software - Operating System - software needed to start the system - Windows, Linux, Unix, MacIntosh....
2. Application Software - Any software which runs in System software
MS office , VLC Media player, TempleRun , Super Mario
Program can be divided in to functions - one big task can be divided in to smaller tasks - for easy development - later we combine/call all functions in to one main function
Function is a group of statements - which performs a task
For example
Student Management System - software may be divided in to following functions
Student info -- function
Student Marks -- function
Student Result -- function
Programming Paradigm(Style/Model/Types of programming)
-------------------------------------------------------------------------
1. Structured/Procedure Oriented Programming
2. Object Oriented Programming
1. Structured/Procedure Oriented Programming
Program is divided in to functions - data is not secure
Ex. C language, C++ (hybrid)
We have a main() method calling other functions
Top Down approach - Divide big problem in to smaller problems/functions
Reusability is high.
Flexibility is less
Example: (In C language)
-------------------------------
int result(int marks1, int marks2, int marks3){
return (marks1+marks2+marks3);
}
void main()
{
int m1, m2, m3;
m1 = 45; m2 = 90; m3=89;
int result = result(m1,m2,m3);
}
2. Object Oriented Programming
---------------------------------------
The basic unit of programming here is an Object
Object
---------
Real world entity - anything existing in the world is an Object
Every object has some attributes/properties that help us to uniquely identify it and it exhibits some behavior.
Ex. Bank Account, ATM Machine, Barcode reader, Pen, Laptop, You and Me , Mouse, Mobile etc
More realistic way of programming
Bottom Up approach
Reusability is high
Flexibility is high
Example (in Java)
----------------------
class Student{
int id;
String name;
String collegeName;
String branch;
public void studentInfo() {
//logic for student info
}
public void studentMarks() {
//logic to get marks
}
public int result(int marks1, int marks2, int marks3){
totalMarks= marks1+marks2+marks3;
return totalMarks;
}
public static void main(String args[]) {
Student obj = new Student(); //object
obj.studentInfo();
obj.studentMarks();
obj.result(34,45,56);
Student s1 = new Student();
}
}
OOPS (Object Oriented Programming)
----------------------------------------------
**Concepts
=========
1. Class - class is a blue print or template for creating objects - it is a group of similar type of objects - class helps to create objects
2. Object - real world entity - memory is not allocated until object is created. Objects have attributes and behavior
attributes - characteristics which help us identify object, differentiate from others-- technically represented by data members or variables in a program
behavior - functionality - technically represented by methods
3. Abstraction - hiding internal implementation details from the end user
4. Encapsulation - Wrapping up of data members (variables) and member functions (methods in to single unit - like capsule - provides security to data
5. Inheritance - Reusability concept - DRY concept (Don't Repeat Yourself)
6. Polymorphism - Poly = many , morphos = forms ---> something existing in multiple forms
Comments
Post a Comment