Welcome to OBJECT ORIENTED PROGRAMMIN Date: 10/09/2014

28
Welcome to Welcome to OBJECT ORIENTED PROGRAMMIN Date: 10/09/2014 Prepared By Prepared By : VINAY ALEXANDER VINAY ALEXANDER PGT(CS) PGT(CS) KV jhagrakhand KV jhagrakhand

description

Welcome to OBJECT ORIENTED PROGRAMMIN Date: 10/09/2014. Prepared By : VINAY ALEXANDER PGT(CS) KV jhagrakhand. The Evolution of Programming Languages There are two type of Programming Languages - PowerPoint PPT Presentation

Transcript of Welcome to OBJECT ORIENTED PROGRAMMIN Date: 10/09/2014

Page 1: Welcome to  OBJECT ORIENTED  PROGRAMMIN Date: 10/09/2014

Welcome to Welcome to OBJECT ORIENTED PROGRAMMIN

Date: 10/09/2014

Prepared ByPrepared By :

VINAY ALEXANDERVINAY ALEXANDERPGT(CS)PGT(CS)KV jhagrakhandKV jhagrakhand

Prepared ByPrepared By :

VINAY ALEXANDERVINAY ALEXANDERPGT(CS)PGT(CS)KV jhagrakhandKV jhagrakhand

Page 2: Welcome to  OBJECT ORIENTED  PROGRAMMIN Date: 10/09/2014

The Evolution of Programming LanguagesThe Evolution of Programming LanguagesThere are two type of Programming There are two type of Programming

LanguagesLanguages1. Low Level Languages: 1. Low Level Languages: It is machine It is machine

oriented and required extensive oriented and required extensive knowledge of computer circuitry. machine knowledge of computer circuitry. machine language, in which instruction are written language, in which instruction are written in binary code(in binary code(Using 1 and 0) , is the only Using 1 and 0) , is the only language the computer can execute language the computer can execute directly. directly.

2. Assembly Language: an instruction are 2. Assembly Language: an instruction are written using symbolic names for written using symbolic names for machine operations(i.e. , READ ,ADD etc)machine operations(i.e. , READ ,ADD etc)

Page 3: Welcome to  OBJECT ORIENTED  PROGRAMMIN Date: 10/09/2014

A programming language should serve A programming language should serve two related purposes:two related purposes:

1. It should provide a vehicle for 1. It should provide a vehicle for the programmer to specify action the programmer to specify action to be executed .to be executed .

2. It should provide a set of 2. It should provide a set of concepts for the programmer to concepts for the programmer to use when thinking about what use when thinking about what can be do.can be do.

Page 4: Welcome to  OBJECT ORIENTED  PROGRAMMIN Date: 10/09/2014

Programming Language generationsProgramming Language generations

Page 5: Welcome to  OBJECT ORIENTED  PROGRAMMIN Date: 10/09/2014

First-Generation LanguagesFirst-Generation Languages Machine languageMachine language: :

Consists of binary Consists of binary numbers (numbers (00s and s and 11s)s)

Is the earliest Is the earliest programming languageprogramming language

Is the only language the Is the only language the computer understands computer understands without translationwithout translation It is machine dependent; It is machine dependent;

each family of processors each family of processors has its own machine has its own machine languagelanguage

Page 6: Welcome to  OBJECT ORIENTED  PROGRAMMIN Date: 10/09/2014

Second-Generation LanguagesSecond-Generation Languages Assembly languageAssembly language: :

Resembles machine Resembles machine language language

Is a low-level languageIs a low-level language Uses brief abbreviations for Uses brief abbreviations for

program instructions.program instructions. Abbreviations are called Abbreviations are called

mnemonicsmnemonics A program is written in A program is written in

source codesource code (text file) and (text file) and translated into machine translated into machine language by an language by an assemblerassembler

Page 7: Welcome to  OBJECT ORIENTED  PROGRAMMIN Date: 10/09/2014

Third-Generation LanguagesThird-Generation Languages Procedural languagesProcedural languages: :

=>Are high-level languages that tell the =>Are high-level languages that tell the computer what to do and how to do it.computer what to do and how to do it.

=>Create programs at a high level of =>Create programs at a high level of abstraction.abstraction.

=>Are easier to read, write, and maintain =>Are easier to read, write, and maintain than machine and assembly languagesthan machine and assembly languages

=>Use a =>Use a compilercompiler or or interpreterinterpreter to translate to translate code.code.

=>Fortran and COBOL are third-generation =>Fortran and COBOL are third-generation languageslanguages

Page 8: Welcome to  OBJECT ORIENTED  PROGRAMMIN Date: 10/09/2014

Compilers and InterpretersCompilers and Interpreters

An interpreter translates source code An interpreter translates source code one line at a timeone line at a time and and executes the instructionexecutes the instruction

A compiler is a program that changes source code to object A compiler is a program that changes source code to object code, all in one shotcode, all in one shot

Example of an interpreted language: BASIC; a compiled Example of an interpreted language: BASIC; a compiled language: Clanguage: C

Page 9: Welcome to  OBJECT ORIENTED  PROGRAMMIN Date: 10/09/2014

Fourth-Generation LanguagesFourth-Generation Languages Fourth-generation languages are non-procedural, Fourth-generation languages are non-procedural,

high-level specification languageshigh-level specification languages They do not force programmers to follow They do not force programmers to follow

procedures to produce results (they’re very procedures to produce results (they’re very close to English, sometimes)close to English, sometimes)

Types of fourth-generation languages include:Types of fourth-generation languages include: Report generators Report generators

Languages for printing database reports (Languages for printing database reports (generate a generate a programprogram to generate the report) to generate the report)

Query languagesQuery languages Languages for getting information out of databases Languages for getting information out of databases

((generate a programgenerate a program to process a query or generate to process a query or generate a form)a form)

Page 10: Welcome to  OBJECT ORIENTED  PROGRAMMIN Date: 10/09/2014

Also include visually-oriented languagesAlso include visually-oriented languages More ambitious 4GL environments attempt to More ambitious 4GL environments attempt to

automatically generate whole systems from the automatically generate whole systems from the outputs of CASE tools, specifications of outputs of CASE tools, specifications of screens and reports, and possibly also the screens and reports, and possibly also the specification of some additional processing specification of some additional processing logic, including data flow diagrams, entity logic, including data flow diagrams, entity relationship diagrams, entity life history relationship diagrams, entity life history diagramsdiagrams

Fifth-generationFifth-generation languages: It is design languages: It is design ed to make the computer solve the ed to make the computer solve the problem for you. These include problem for you. These include artificial artificial intelligenceintelligence and and neural networksneural networks oriented oriented languageslanguages

Page 11: Welcome to  OBJECT ORIENTED  PROGRAMMIN Date: 10/09/2014

Structured programming was most Structured programming was most common way to organize a common way to organize a program.program.

A programming paradigm defines A programming paradigm defines the methodology of designing and the methodology of designing and implementing program using the implementing program using the key features and building blocks of key features and building blocks of a programming languagea programming language

Page 12: Welcome to  OBJECT ORIENTED  PROGRAMMIN Date: 10/09/2014

Program: A program in a procedural Program: A program in a procedural language is a list of instruction where each language is a list of instruction where each statement tells the computer to do statement tells the computer to do

something.something.

PROCEDURAL PROGRAMMING: It is an PROCEDURAL PROGRAMMING: It is an approach to programming.approach to programming.

Lays more emphasis on procedure than dataLays more emphasis on procedure than data Separates the function and data manipulated Separates the function and data manipulated

by themby them Whenever the definition of a type changes, Whenever the definition of a type changes,

the functions referring to this type must also the functions referring to this type must also be changed to reflect the changebe changed to reflect the change

Page 13: Welcome to  OBJECT ORIENTED  PROGRAMMIN Date: 10/09/2014

=>The change in the design must also be =>The change in the design must also be modified to copy with the change in structuremodified to copy with the change in structure

that shows procedural programming is that shows procedural programming is susceptible to design changessusceptible to design changes

=>As design changes lead to many =>As design changes lead to many modification in the code this lead to modification in the code this lead to increased time and cost overheads at timesincreased time and cost overheads at times

Page 14: Welcome to  OBJECT ORIENTED  PROGRAMMIN Date: 10/09/2014

Modular programmingModular programming (also known as (also known as top down design and stepwise top down design and stepwise refinement):A set of related procedure refinement):A set of related procedure with the data they manipulate is called a with the data they manipulate is called a modulemodule

It is a software design technique that increases It is a software design technique that increases the extent to which software is composed of the extent to which software is composed of separate, interchangeable components called separate, interchangeable components called modulesmodules by breaking down program functions by breaking down program functions into modules, each of which accomplishes one into modules, each of which accomplishes one function and contains everything necessary to function and contains everything necessary to accomplish this. Conceptually, modules accomplish this. Conceptually, modules represent a represent a separation of concerns, and , and improve improve maintainability by enforcing logical by enforcing logical boundaries between components. boundaries between components.

Page 15: Welcome to  OBJECT ORIENTED  PROGRAMMIN Date: 10/09/2014

=>Modules are typically incorporated into the =>Modules are typically incorporated into the program through interfaces. A module interface program through interfaces. A module interface expresses the elements that are provided and expresses the elements that are provided and required by the module. The elements defined in required by the module. The elements defined in the interface are detectable by other modules. The the interface are detectable by other modules. The implementation contains the working code that contains the working code that corresponds to the elements declared in the corresponds to the elements declared in the interface.interface.

=> Limitations of procedural Programming: => Limitations of procedural Programming: 1. Emphasis on algorithm rather than data.1. Emphasis on algorithm rather than data.2. Change in a database being needs to be 2. Change in a database being needs to be

propagated to all functions that use the same data propagated to all functions that use the same data type. this is a frustrating and time consuming type. this is a frustrating and time consuming process.process.

3. The procedural programming does not model real 3. The procedural programming does not model real world very well.world very well.

Page 16: Welcome to  OBJECT ORIENTED  PROGRAMMIN Date: 10/09/2014

OBJECT BASED PROGRAMMING OBJECT BASED PROGRAMMING

=>In object based programming data =>In object based programming data and its associated meaningful function and its associated meaningful function are enclosed in one single entity a are enclosed in one single entity a classclass

=>Class are allowed to access its =>Class are allowed to access its interface (how the uses views) but interface (how the uses views) but cannot access its implementation cannot access its implementation details (how the process is actually details (how the process is actually taking place)taking place)

Page 17: Welcome to  OBJECT ORIENTED  PROGRAMMIN Date: 10/09/2014

Object: Object: Object is an identical entity with Object is an identical entity with some characteristics and behavior.some characteristics and behavior.

Object is the basic unit of object-Object is the basic unit of object-oriented programming. Objects are oriented programming. Objects are identified by its unique name. An object identified by its unique name. An object represents a particular instance of a represents a particular instance of a class. There can be more than one class. There can be more than one instance of a class. Each instance of a instance of a class. Each instance of a class can hold its own relevant dataclass can hold its own relevant data

Example : ram , mohan etc Example : ram , mohan etc

Page 18: Welcome to  OBJECT ORIENTED  PROGRAMMIN Date: 10/09/2014

=>=>Classes: Classes: A class is blue-print A class is blue-print representing a group of object that share some representing a group of object that share some common properties.common properties.

=>=>Classes are data types based on which Classes are data types based on which objects are created. Objects with similar objects are created. Objects with similar properties and methods are grouped properties and methods are grouped together to form a Class. Thus a Class together to form a Class. Thus a Class represents a set of individual objects. represents a set of individual objects. Characteristics of an object are represented Characteristics of an object are represented in a class as Properties. The actions that can in a class as Properties. The actions that can be performed by objects become functions of be performed by objects become functions of

the class and are referred to as Methodsthe class and are referred to as Methods

Page 19: Welcome to  OBJECT ORIENTED  PROGRAMMIN Date: 10/09/2014

BASIC CONCEPT OF OOPSBASIC CONCEPT OF OOPS

DATA ABSTRACTIONDATA ABSTRACTION ENCAPSULATIONENCAPSULATION MODULARITYMODULARITY INHERITANCEINHERITANCE POLYMORPHISMPOLYMORPHISM

Page 20: Welcome to  OBJECT ORIENTED  PROGRAMMIN Date: 10/09/2014

=>DATA ABSTRACTION: =>DATA ABSTRACTION: It is an act of It is an act of representing essential features without representing essential features without including the background details.including the background details.

=>Data Abstraction increases the power =>Data Abstraction increases the power of programming language by creating of programming language by creating user defined data types. Data user defined data types. Data Abstraction also represents the needed Abstraction also represents the needed information in the program without information in the program without presenting the detailspresenting the details

Page 21: Welcome to  OBJECT ORIENTED  PROGRAMMIN Date: 10/09/2014

=>Data Encapsulation: =>Data Encapsulation: The wrapping The wrapping up of data and function into a single up of data and function into a single unit(called class) is called unit(called class) is called encapsulation.. encapsulation.. =>=>Data Encapsulation combines data and Data Encapsulation combines data and functions into a single unit called Class. functions into a single unit called Class. When using Data Encapsulation, data is When using Data Encapsulation, data is not accessed directly; it is only accessible not accessed directly; it is only accessible through the functions present inside the through the functions present inside the class. Data Encapsulation enables the class. Data Encapsulation enables the important concept of data hiding possibleimportant concept of data hiding possible. .

Page 22: Welcome to  OBJECT ORIENTED  PROGRAMMIN Date: 10/09/2014

MODULARITYMODULARITY

MODULARITY is the property of a MODULARITY is the property of a system that has been decomposed into a system that has been decomposed into a set of cohesive and loosely coupled set of cohesive and loosely coupled modules. modules.

It reduces complexity of program to some It reduces complexity of program to some degree.degree.

It creates documented boundaries of a It creates documented boundaries of a program. program.

Page 23: Welcome to  OBJECT ORIENTED  PROGRAMMIN Date: 10/09/2014

INHERITANCE: INHERITANCE: It is capability of one It is capability of one class of thing to inherit capability from class of thing to inherit capability from another class. Advantages of Inheritance:another class. Advantages of Inheritance:

1.REUSABILITY: 1.REUSABILITY: This is This is term refers to the term refers to the ability for multiple programmers to use the ability for multiple programmers to use the same written and debugged existing class of same written and debugged existing class of data. This is a time saving device and adds data. This is a time saving device and adds code efficiency to the language. Additionally, code efficiency to the language. Additionally, the programmer can incorporate new the programmer can incorporate new features to the existing class, further features to the existing class, further developing the application and allowing users developing the application and allowing users to achieve increased performance. This time to achieve increased performance. This time saving feature optimizes code, helps in saving feature optimizes code, helps in gaining secured applications and facilitates gaining secured applications and facilitates easier maintenance on the application. easier maintenance on the application.

Page 24: Welcome to  OBJECT ORIENTED  PROGRAMMIN Date: 10/09/2014

=>=>Polymorphism:Polymorphism: It is ability for a It is ability for a message to process in more than one message to process in more than one form.form.

=>=>Polymorphism allows routines to use Polymorphism allows routines to use variables of different types at different variables of different types at different times. An operator or function can be times. An operator or function can be given different meanings or functions. given different meanings or functions. Polymorphism refers to a single Polymorphism refers to a single function or multi-functioning operator function or multi-functioning operator performing in different ways.performing in different ways.

Page 25: Welcome to  OBJECT ORIENTED  PROGRAMMIN Date: 10/09/2014

ADVANTAGES OF OOPSADVANTAGES OF OOPS=>=>simplicity:simplicity: software objects model real software objects model real

world objects, so the complexity is reduced world objects, so the complexity is reduced and the program structure is very clear; and the program structure is very clear;

=>=>modularity:modularity: each object forms a separate each object forms a separate entity whose internal workings are entity whose internal workings are decoupled from other parts of the system; decoupled from other parts of the system;

=>modifiability:=>modifiability: it is easy to make minor it is easy to make minor changes in the data representation or the changes in the data representation or the procedures in an OO program. Changes procedures in an OO program. Changes inside a class do not affect any other part of inside a class do not affect any other part of a program, since the only public interface a program, since the only public interface that the external world has to a class is that the external world has to a class is through the use of methods; through the use of methods;

Page 26: Welcome to  OBJECT ORIENTED  PROGRAMMIN Date: 10/09/2014

extensibility: extensibility: adding new features or adding new features or responding to changing operating responding to changing operating environments can be solved by environments can be solved by introducing a few new objects and introducing a few new objects and modifying some existing ones; modifying some existing ones;

maintainability: maintainability: objects can be objects can be maintained separately, making maintained separately, making locating and fixing problems easier; locating and fixing problems easier;

re-usability: re-usability: objects can be reused in objects can be reused in different programs without writing the different programs without writing the code of a program. code of a program.

Page 27: Welcome to  OBJECT ORIENTED  PROGRAMMIN Date: 10/09/2014

DISADVANTAGES OF OOPSDISADVANTAGES OF OOPS

With OOP class tend be overly With OOP class tend be overly generalized.generalized.

The relation among classes become The relation among classes become artificial at times.artificial at times.

The OOP program design is tricky.The OOP program design is tricky. Also one needs to do proper planning and Also one needs to do proper planning and

proper OOP programming.proper OOP programming.

Page 28: Welcome to  OBJECT ORIENTED  PROGRAMMIN Date: 10/09/2014

Class relationship and inheritance:Class relationship and inheritance: 1. is –a relationship: 1. is –a relationship: When a class (say When a class (say

B) inherits from another class(say A) it B) inherits from another class(say A) it becomes a “kind –of “ its base class. That becomes a “kind –of “ its base class. That is class ‘B’ IS –A kind of class ‘A’.is class ‘B’ IS –A kind of class ‘A’.

2. HAS-A Relationship: 2. HAS-A Relationship: When a class When a class owns an object of another class then it is owns an object of another class then it is class HAS- A relationship. class HAS- A relationship.

ENDEND