Presentation is loading. Please wait.

Presentation is loading. Please wait.

INTRODUCTION TO OBJECT-ORIENTED PROGRAMMING (OOP) & CONCEPTS

Similar presentations


Presentation on theme: "INTRODUCTION TO OBJECT-ORIENTED PROGRAMMING (OOP) & CONCEPTS"— Presentation transcript:

1 INTRODUCTION TO OBJECT-ORIENTED PROGRAMMING (OOP) & CONCEPTS

2 OOP concept Enable programmers to create modules that do not need to be changed when a new type of object is added. Programmer can simply create a new object that inherits many of its features from existing objects Makes object-oriented programs easier to modify type of programming in which programmers define not only the data type of a data structure, but also the types of operations (functions) that can be applied to the data structure. In this way, the data structure becomes an object that includes both data and functions. In addition, programmers can create relationships between one object and another. For example, objects

3 History of OOP Many people believe that OOP is a product of the 1980s (Bjarne Stroustrup). Actually, SIMULA 1 (1962) and Simula 67 (1967) [earliest object-oriented languages] The work on the Simula languages (Ole-John Dahl and Kristen Nygaard) at the Norwegian Computing Center in Oslo, Norway. Most of the advantages of OOP available in the earlier Simula languages, it wasn't until C++ became entrenched in the 1990s that OOP began to flourish.

4 Advantages of using OOP
OOP provides a clear modular structure for programs which makes it good for defining abstract data types where implementation details are hidden and the unit has a clearly defined interface. OOP makes it easy to maintain and modify existing code as new objects can be created with small differences to existing ones. OOP provides improved software maintainability Reusability provides faster development

5 Terminologies of OOP Classes Object Encapsulation Data Abstraction
Inheritance Polymorphism

6 CLASSES A collection of objects of a similar type.
Once a class is defined, any number of objects can be created which belong to that class. A class is a blueprint, or prototype, that defines the variables and the methods common to all objects of a certain kind. A class is a blueprint or prototype from which objects are created. This section defines a class that models the state and behavior of a real-world object. It intentionally focuses on the basics, showing how even a simple class can cleanly model state and behavior.

7 OBJECT An instance of a class.
A class must be instantiated into an object before it can be used in the software. A software bundle of related state and behavior. More than one instance of the same class can be in existence at any one time.

8 ENCAPSULATION Storing data and functions in a single unit (class).
Mechanism that binds together code and data in manipulates. Keeps both safe from outside interference and misuse. Data cannot be accessible to the outside world and only those functions which are stored in the class can access it.

9 DATA ABSTRACTION Abstraction refers to the act of representing essential features without including the background details or explanations. Classes use the concept of abstraction and are defined as a list of abstract attributes.

10 INHERITANCE Provides a powerful and natural mechanism for organizing and structuring your software. This section explains how classes inherit state and behavior from their superclasses, and explains how to derive one class from another using the simple syntax provided by the Java programming language.

11 POLYMORPHISM The ability to take more than one form.
An operation may exhibit different behaviors in different instances. The behavior depends on the data types used in the operation. In general, polymorphism means “one interface, multiple method” Reduce complexity by allowing the same interface to be used to specify a general class of action.

12 Distinguish between abstraction and encapsulation
Refers to showing only the necessary details to the intended user Means to hide (data hiding). Wrapping, just hiding properties and methods. Used in programming languages to make abstract class. Used for hide the code and data in a single unit to protect the data from the outside the world. Abstraction is implemented using interface and abstract class Encapsulation is implemented using private and protected access modifier.

13 examples ABSTRACTION ENCAPSULATION Class Encapsulation {
Class Encapsulation {     private int marks;     public int Marks     {       get { return marks; }       set { marks = value;}     } } abstract class Abstraction     public abstract void doAbstraction(); public class AbstractionImpl: Abstraction     public void doAbstraction()        //Implement it    }

14 Structured Programming
Differences Structured Programming OOP Follow top-down approach to program design. Follow bottom-up approach in program design. Data and Functions don’t tide with each other. Functions and data are tide together. Large programs are divided into smaller self contained program segment known as functions. Programs are divided into entity called Objects. Data moves openly around the system from function to function. Data is hidden and can’t be accessed by the external world Functions are dependent so reusability is not possible Functions are not dependent so reusability is possible


Download ppt "INTRODUCTION TO OBJECT-ORIENTED PROGRAMMING (OOP) & CONCEPTS"

Similar presentations


Ads by Google