Kategorier: Alla - encapsulation - abstraction - classes - objects

av Zalfri Iqwan för 4 årar sedan

311

Introduction to Object Oriented Programming

Object-oriented programming (OOP) is a paradigm that emphasizes the use of objects to represent both data and behaviors in a program. Key principles of OOP include abstraction, encapsulation, polymorphism, and inheritance.

Introduction to Object Oriented
Programming

Introduction to Object Oriented Programming

Principle of OOP

Abstraction
An abstraction denotes the essential characteristics of an object that distinguish it from all other kinds of objects and thus provide crisply defined conceptual boundaries, relative to the perspective of the viewer. [Booch] Abstraction denotes a model, a view, or some other focused representation for an actual item. It's the development of a software object to represent an object we can find in the real world. Encapsulation hides the details of that implementation.
Polymorphism
Object oriented programming lets programmers create procedures for objects whose exact type is not known until runtime. For example, a screen cursor may change its shape from an arrow to a line depending on the program mode. The routine to move the cursor on screen in response to mouse movement can be written for "cursor", and polymorphism lets the right version for the given shape be called.
Inheritance
Classes may be created in hierarchies, and inheritance lets the structure and methods in one class pass down the class hierarchy. By inheriting code, complex behaviors emerge through the reuse of code in a parent class. If a step is added at the bottom of a hierarchy, only the processing and data associated with that unique step must be added. Everything else above that step may be inherited. Reuse is considered a major advantage of object orientation.
Encapsulation
Refers to the creation of self-contained modules (classes) that bind processing functions to its data members. The data within each class is kept private. Each class defines rules for what is publicly visible and what modifications are allowed.

OOP Features

OOP allows decomposition of a problem into a number of entities called objects and then builds data and functions around these objects.
The functions of one object can access the functions of another object.
The data of the objects can be accessed only by the functions associated with that object.
The software is divided into a number of small units called objects. The data and functions are built around these objects.
Object Oriented Programming (OOP) is a programming model where programs are organized around objects and data rather than action and logic.

Object Oriented Programming Feature

Object Oriented Programming (OOP) is one of the most popular programming languages. This article is an introduction to Object Oriented Programming (OOP) and how to implement OOP in C# including abstraction, encapsulation, inheritance and polymorphism.