c# fundamentals (oops) part 1

11
iFour Consultancy Basics of OOPS

Upload: ifour-institute-sustainable-learning

Post on 09-Feb-2017

48 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: C# fundamentals (OOPS) Part 1

iFour Consultancy

Basics of OOPS

Page 2: C# fundamentals (OOPS) Part 1

DefinitionFundamentalsClassObjectsEncapsulationInheritanceProcedure v/s Object Oriented Programming

INDEX

http://www.ifourtechnolab.com/

VB.NET Software Development Companies India

Page 3: C# fundamentals (OOPS) Part 1

Definition

Programming language model organized around objects rather than "actions" and data rather than “logic”. Historically, a program has been viewed as a logical procedure that takes input data, processes it, and produces output data

For a programming language to be a true OOP language, the language must meet the following criteria:

Abstraction, Encapsulation,Polymorphism Inheritance

•A markup language is a set of markup tags •A markup language is a set of markup tags

http://www.ifourtechnolab.com/

VB.NET Software Development Companies India

Page 4: C# fundamentals (OOPS) Part 1

Fundamentals Classes and Objects

The terms class and object are sometimes used interchangeably, but in fact, classes describe the type of objects, while objects are usable instances of classes. So, the act of creating an object is called instantiation. Using the blueprint analogy, a class is a blueprint, and an object is a building made from that blueprint

Abstraction Abstraction manages the complexities of a business problem by allowing you to identify a set of objects involved with that business

problem Encapsulation

Encapsulation hides the internal implementation of an abstraction within the particular object Polymorphism

It provides for multiple implementations of the same method. For example, different objects can have a Save method, each of which perform different processing

InheritanceThe excitement of Visual Basic .NET lies in inheritance. Visual Basic 5 introduced the concept of interface inheritance, which allows

you to reuse the interface of a class, but not its implementation

http://www.ifourtechnolab.com/

VB.NET Software Development Companies India

Page 5: C# fundamentals (OOPS) Part 1

What is a class?

It can be defined as a template/blueprint that describes the behaviors/states that object of its type support

Example of simple class with member properties and member methods.public class Circle{

private decimal _radius; public double radius {get{return _radius;} set{_radius = values} } public double Area() {

return 3.141592 * _radius * _radius; }

}

http://www.ifourtechnolab.com/

VB.NET Software Development Companies India

Page 6: C# fundamentals (OOPS) Part 1

It represents a particular instance of a class. There can be more than one instance of an object. Each instance of an object can hold its own relevant data

Example of Simple instantiate of an object of the class in the example of previous slidesCircle objCircle = new Circle(); //here objCircle is an instance of a classCircle objCir = new Circle(); //here objCir is an instance of a class

Both the instantiation(Objects) holds the related data and members of the class and can be used for different purposes

What is Object?

http://www.ifourtechnolab.com/

VB.NET Software Development Companies India

Page 7: C# fundamentals (OOPS) Part 1

Encapsulation

Hiding irrelevant data from the user A class may contain much information that is not useful for an outside class or interface So classes use encapsulation to hide its members that are not relevant for an outside

class or interface It can be done using access specifiers

In the same example of Circle class “Private” is a specifier used for Member variable. So It hides the data to be used outside the class:

private decimal _radius;

http://www.ifourtechnolab.com/

VB.NET Software Development Companies India

Page 8: C# fundamentals (OOPS) Part 1

Use in the small, when a derived class "is-a" base classenables code reuseenables design reuse & polymorphic programming

Example:a Student is-a Person

Inheritance

Undergraduate

Person

Student Employee

Graduate Staff Faculty

http://www.ifourtechnolab.com/

VB.NET Software Development Companies India

Page 9: C# fundamentals (OOPS) Part 1

It is a methodology to write the program where we specify the code in form of classes and objects

Object-oriented programming is the successor of procedural (structural) programming Procedural programming describes programs as groups of reusable code units

(procedures) which define input and output parameters. Procedural programs consist of procedures, which invoke each other

The problem with procedural programming is that code reusability is hard and limited – only procedures can be reused and it is hard to make them generic and flexible.

There is no easy way to work with abstract data structures with different implementations This is how objects came to be. They describe characteristics (properties) and behaviour

(methods) of such real life entities

Procedure v/s Object Oriented Programming

http://www.ifourtechnolab.com/

VB.NET Software Development Companies India

Page 10: C# fundamentals (OOPS) Part 1

https://www.tutorialspoint.com/csharp/ http://www.c-sharpcorner.com/UploadFile/mkagrahari/introduction-to-object-oriented-

programming-concepts-in-C-Sharp/

References

http://www.ifourtechnolab.com/

VB.NET Software Development Companies India

Page 11: C# fundamentals (OOPS) Part 1

Questions?

http://www.ifourtechnolab.com/

VB.NET Software Development Companies India