Home Computer Class Computer Programming

Class Computer Programming

39
0

Objects and Classes

Overview

Object-oriented programming (OOP), is a programming paradigm that uses the concept of objects. These objects may contain data in the form fields or code in the form procedures. One of the most important features of objects is the ability of their procedures to access and modify the data fields associated with them (objects have a notion or “this” or “self”. There are many OOP languages. However, the most common are class-based. This means that an object’s procedures can access and often modify the data fields of the object with which they are associated (objects have a notion of “this” or “self”).

Discussion

We have so far focused on procedural programming. Structured programming is a way to organize the steps of a procedure (routines or subroutines or functions). A procedure can be called at any stage of a program’s execution by another procedure or it self. Procedural programming focuses on breaking down programming tasks into data structures and variables. [2] It is easier to create small programs and scripts using a simple procedural approach.

Instead, object-oriented programming breaks down a programming task in objects that expose behavior (methods), data (members and attributes) using interfaces. The main difference is that object-oriented programming bundles both procedural and object-oriented programming. This means that larger programs can benefit from more code isolation and data reuse.

Many objects and classes are designed to be able to represent real-world objects. As an example, consider a door. Many doors are limited in functionality. Doors can be locked or unlocked, opened and closed. We might use procedural programming to create functions that open, close, lock and unlock doors, such as the following:

Object-oriented programming is a combination of code and data. Instead of having different functions that act on doors, we design them with methods that can operate on their own. Methods are something that an object can do and are usually defined using verbs. This is how an object-oriented door pseudocode might look:

Attributes are what an object can be or have. These attributes are usually defined with nouns and adjectives. Some examples of door attributes include:

A door class is created when we create code to define a generic opening. A door class would include all the possible methods and attributes that a door could have. The class would be used to create objects (instances) that could represent specific doors such as a door in a room, a door in the front, back, or side of a house or a door in a car.

Key Terms

Attribute
A specification that describes a property of an object.
Class
An extensible program-code-template for creating objects, providing initial values for state (member variables) and implementations of behavior (member functions or methods).[5]
For example
:Concrete occurrence of an object. [6]
Method
A specification that describes a procedure or behavior for an object. [7]
object
An example of a class in which the object can be a combination variable, function, or data structure. [8]

 

Previous articleAmazon Elastic Compute Cloud
Next articleCloud Computing Security

LEAVE A REPLY

Please enter your comment!
Please enter your name here