You are on page 1of 14

Session 1

Total.net / Programming in C# / Session 1/ 1 of 14

Session Objectives
Discuss the following Drawbacks of traditional programming Need for Object Oriented approach Object Oriented techniques

Discuss Object Oriented Concepts Objects Classes Abstraction Inheritance Encapsulation Polymorphism
Total.net / Programming in C# / Session 1/ 2 of 14

Introduction

Total.net / Programming in C# / Session 1/ 3 of 14

Need for OOP


Languages like C use the traditional programming approach for application development. In this approach, we divide the application into several tasks and write code for all tasks. Therefore, the focus in this approach is on the tasks and not on the objects

The traditional programming approach was not able to handle the increasing demand of software applications.
Total.net / Programming in C# / Session 1/ 4 of 14

Need for OOP


The drawbacks of Traditional Programming approach are Unmanageable Programs Code Reusability not Optimum Problems in Modification of Data

Difficulty in Implementation

Total.net / Programming in C# / Session 1/ 5 of 14

Need for OOP


Benefits of Object Oriented Programming approach are OOP offers better implementation OOP offers better data security OOP offers better code reusability

OOP offers more flexibility


OOP offers better manageable programs
Total.net / Programming in C# / Session 1/ 6 of 14

OOP Concepts
An object represents an entity in the real world.
An object is simply something that is relevant to a particular application.

An object is a concept or a thing, with defined boundaries, that is relevant to the problem being dealt with.
Total.net / Programming in C# / Session 1/ 7 of 14

OOP Concepts
A class is a mould or a template of an object.
A class is what defines all the data members and the methods that an object should have.

The class defines the characteristics that the object will possess; it could also be referred to as a blueprint of the object.
Total.net / Programming in C# / Session 1/ 8 of 14

OOP Concepts
Each object is said to be an instance of the class.
A class can contain any of the following as its members Properties / Fields Methods Constructors & Destructors
Total.net / Programming in C# / Session 1/ 9 of 14

OOP Concepts
Properties A characteristic required of an object when represented in a class is called a property or a field. Method A method is similar to a function, routine or a procedure; here it is associated to a class. Constructor / Destructor These are special types of methods that execute when an object is initialized or destroyed respectively.
Total.net / Programming in C# / Session 1/ 10 of 14

OOP Concepts
Data abstraction enhances security as use of data is restricted to certain functions only. Abstraction is more used where you want only a certain number of functions/methods are accessing data.

Total.net / Programming in C# / Session 1/ 11 of 14

OOP Concepts
We can incorporate the functionality of existing classes into any other class just by inheriting the new class from the existing class. The existing class is called the BASE class and the newly created class is called the DERIVED class.
Total.net / Programming in C# / Session 1/ 12 of 14

OOP Concepts

Grouping of data and methods into a single entity is known as Data Encapsulation

Total.net / Programming in C# / Session 1/ 13 of 14

OOP Concepts
Object Oriented languages try to make existing code easily modifiable without changing the code much.
Polymorphism allows functions to take more than one form. Polymorphism enables the same method to behave differently on different classes.
Total.net / Programming in C# / Session 1/ 14 of 14

You might also like