The Computer Revolution/OOP

From Wikibooks, open books for an open world
Jump to navigation Jump to search

Object-oriented programming pronounced oop is a time saving measure of recycling used by programmers. Rather than having to recreate a program form scratch OOP uses objects or previously constructed modules which contain chunks of data and processing instructions. These processing instructions are activated when a message in sent and an action needs to be performed. These processing instructions are called methods. Essentially, OOP is recycling blocks of program code which prevents a programmer from having to start from scratch every time a new program is written. OOP takes longer to learn than programming but it is worth the investment in time because it speeds up the process of developing programs.

Concepts of OOP[edit | edit source]

OOP has three concepts which are encapsulation, inheritance, and polymorphism.

Encapsulation as the word implies encapsulates both data and processing instructions for reuse in other programs.

Inheritance use objects which are related to one another in characteristic and behavior which form a class. These classes can use hierarchies to pass on traits from one class to another subclass creating new objects.

Polymorphism or "many shapes" allows objects to take different shapes at run time. This is useful when the programmer does not know what action the user is to perform in advance.

An example of this is how the cursor takes different form depending on where it is placed on the computer screen.