Classes and Objects - the 10,000 view

There are primarily two programming methods in use today: procedural and object-oriented. The earliest programming languages were procedural, meaning a program was made of one or more procedures. A procedure is a set of programming statements that, together, perform a specific task. The statements might gather input from the user, manipulate data stored in the computer’s memory, and perform calculations or any other operation necessary to complete its task.

Procedural programming is centered on creating procedures; object-oriented programming is centered on creating objects. An object is a software entity that contains data and procedures. The data contained in an object is known as the object’s attributes. The procedures, or behaviors, that an object performs are known as the object’s methods. The object is, conceptually, a self-contained unit consisting of data (attributes) and procedures (methods).

OOP addresses the problem of code/data separation through encapsulation and data hiding. Encapsulation refers to the combining of data and code into a single object. Data hiding refers to an object’s ability to hide its data from code that is outside the object. Only the object’s methods may then directly access and make changes to the object’s data. An object typically hides its data, but allows outside code to access the methods that operate on the data.

 

Class = Blueprint