Presentation is loading. Please wait.

Presentation is loading. Please wait.

INTRODUCTION TO OBJECT-ORIENTED PROGRAMMING

Similar presentations


Presentation on theme: "INTRODUCTION TO OBJECT-ORIENTED PROGRAMMING"— Presentation transcript:

1 INTRODUCTION TO OBJECT-ORIENTED PROGRAMMING
A. Vιgиєsh Kuмαя

2 Alpha Breathing (1 Mins)
The three steps for alpha breathing are Breathe in Breathe out Hold (Repeat the three steps for 8 times) Vιgиєsh Kuмαя 5/15/2018

3 RECAP (5 min) Vιgиєsh Kuмαя 5/15/2018

4 Evocation (3 mins) Vιgиєsh Kuмαя 5/15/2018

5 PROGRAMMING LANGUAGES
Programming languages allow programmers to code software. The three major families of languages are: Machine languages. Assembly languages. High-Level languages. Vιgиєsh Kuмαя 5/15/2018

6 MACHINE LANGUAGES Comprised of 1s and 0s
The “native” language of a computer Difficult to program – one misplaced 1 or 0 will cause the program to fail. Example of code: Vιgиєsh Kuмαя 5/15/2018

7 ASSEMBLY LANGUAGES Assembly languages are a step towards easier programming. Assembly languages are comprised of a set of elemental commands which are tied to a specific processor. Assembly language code needs to be translated to machine language before the computer processes it. Example: ADD ,

8 HIGH-LEVEL LANGUAGES High-level languages represent a giant leap towards easier programming. The syntax of HL languages is similar to English. Historically, we divide HL languages into two groups: Procedural languages Object-Oriented languages (OOP) Vιgиєsh Kuмαя 5/15/2018

9 PROCEDURAL LANGUAGES A program in a procedural language is basically a list of instructions. As programs become larger they are usually broken down into smaller units, such as functions, procedures, subroutines. Functions can be grouped together into modules according to their functionality, objectives and tasks. Structured programming is a programming paradigm that to a large extent relies on the idea of dividing a program into functions and modules. Vιgиєsh Kuмαя 5/15/2018

10 PROBLEMS WITH STRUCTURED PROGRAMMING
Functions have unrestricted access to global data Function A: Function B: Function C: local data local data local data global data X global data Y global data Z Large number of potential connections between functions and data it is difficult to tell which functions access the data

11 PROBLEMS WITH STRUCTURED PROGRAMMING
Data and function are considered as two separate entities. Makes it difficult to model things in the real world. Complex real world objects have both attributes and behaviours. Attributes People: name, date of birth, eye color, job title. Cars: horse power, number of doors, color. Behaviours People: ask a person to bring you a coffee. Cars: apply the brakes, turn on the engine. Vιgиєsh Kuмαя 5/15/2018

12 OBJECT ORIENTED PROGRAMMING
class - collections of objects object- instance of class

13 OBJECT ORIENTED APPROACH-Characteristics of OOPS
data functions Encapsulation: integrate data and functions into one object. Data items are called attributes or instance variables .

14 OBJECT ORIENTED APPROACH
Separation: objects interact with each other only via the their membership functions. Separation helps to maintain the integrity of the entire Program. Object A data functions Object C data functions Object B data functions

15 Abstraction Abstraction is the concept of taking some object from the real world, and converting it to programming terms. Create a Human class and giving it int health, int age, String name, etc. properties, and eat() etc. methods. Vιgиєsh Kuмαя 5/15/2018

16 CLASSES VERSUS OBJECTS
A class is a prototype specification from which one can generate a number of similar objects. A class can be considered as an object factory. An object is said to be a member or instance of a class.

17 INHERITANCE In our daily lives we use the concept of classes divided into subclasses, for example vehicles are divided into cars,trucks, buses and motor cycles. The principle in this sort of division is that each sub-class shares some common features with the base class from which it is derived, but also has its own particular features. base class Vehicle wheels engine Car Truck wheels engine trunk wheels engine trailer sub-classes or derived classes trunk trailer

18 REUSABILITY Reusability means that a class that has been designed,
created and debugged once can be distributed to other programmers for use in their own programs. The concept of inheritance provides an important extension to the idea of reusability, as it allows a programmer to take an existing class without modifying it and adding additional features and functionality. This is done by inheriting a new sub-class from the exisiting base class.

19 POLYMORPHISM & OVERLOADING
Polymorphism means ”having many shapes”. A polymorphic variable can refer to objects of Different classes, for example a graphic object can Be either a circle or a triangle. Overloading: an existing operator, such as + or = is given The capability to operate on a new data type, for example Define the operator + for the class complex such that It realizes the addition of two complex numbers.

20 WHY OOP? Modularization Abstraction Encapsulation Portability
Hierarchy Continuity

21 Procedure Oriented Programming Object Oriented Programming
Divided Into In POP, program is divided into small parts called functions. In OOP, program is divided into parts called objects. Importance In POP,Importance is not given to data but to functions as well as sequence of actions to be done. In OOP, Importance is given to the data rather than procedures or functions because it works as a real world. Approach POP follows Top Down approach. OOP follows Bottom Up approach. Access Specifiers POP does not have any access specifier. OOP has access specifiers named Public, Private, Protected, etc. Data Moving In POP, Data can move freely from function to function in the system. In OOP, objects can move and communicate with each other through member functions.

22 Expansion To add new data and function in POP is not so easy. OOP provides an easy way to add new data and function. Data Access In POP, Most function uses Global data for sharing that can be accessed freely from function to function in the system. In OOP, data can not move easily from function to function, it can be kept public or private so we can control the access of data. Data Hiding POP does not have any proper way for hiding data so it is less secure. OOP provides Data Hiding so provides more security. Overloading In POP, Overloading is not possible. In OOP, overloading is possible in the form of Function Overloading and Operator Overloading. Examples Example of POP are : C, VB, FORTRAN, Pascal. Example of OOP are : C++, JAVA, VB.NET, C#.NET.

23 C++ Programming Basics
Basic program Construction: #include <iostream> using namespace std; int main() { cout << “Welcome to CSE Department \n”; return 0; } Every C++ program has one function name called main() Main() is where the program execution starts.

24 Functions Collection of statements to do some particular task.
Functions separate the concept (what is done) from the implementation (how it is done). Functions make programs easier to understand. Functions can be called several times in the same program, allowing the code to be reused.

25 Functions Functions are one of the fundamental building blocks of C++.
The above program consists almost entirely of a single function called main(). The only parts of this program that are not part of the function are the first two lines—the ones that start with #include and using.

26 Braces and the Function Body
The body of a function is surrounded by braces. These braces play the same role as the BEGIN and END keywords in some other languages. Every function must use this pair of braces around the function body.

27 Always start with main()
When we run a C++ program, the first statement executed will be at the beginning of a function called main(). The program may consist of many functions, classes, and other program elements, but on startup, control always goes to main(). If there is no function called main() in your program, an error will be reported when we run the program.

28

29 Discussion (10 mins) Vιgиєsh Kuмαя 5/15/2018

30 Mind Map (7 mins) Polymorphism Structured Programming Encapsulation
Object Oriented Programming Data Hiding Abstraction Inheritance Class & Objects

31 Summary/ presentation (3 mins)
Vιgиєsh Kuмαя 5/15/2018

32 STIMULATING QUESTIONS
Identify the type of application for which object oriented programming can be used. Can you list some scenario where procedural language is still being the best? Vιgиєsh Kuмαя 5/15/2018

33 Vιgиєsh Kuмαя 5/15/2018


Download ppt "INTRODUCTION TO OBJECT-ORIENTED PROGRAMMING"

Similar presentations


Ads by Google