Monday, 2 March 2015

Slog 5

OOP (Object Oriented Programming) is type of programming that relies upon the use of data structures that contain data, also referred to as objects, and upon methods that is just a series of code that perform different tasks or procedures.  The break down of the basic concepts in OOP is illustrated below:

class( data type definition )
-field (data member)
-method (function member)

object/instance (piece of data)

When defining a class we define a data type composed of a bunch of other pieces of data.  Those pieces of data, those fields, can be any type of data that exists in the language.  When creating a class, the class itself is just a blueprint for creating different pieces of data.  The actual pieces of data themselves are called instances, or more commonly, are called objects.  The other type of data associated with the class are methods.  These methods are the operations for acting upon the data.  When we instantiate a class, the instance gets its own fields that are different from all the other fields of different instances from the same class.  These instances have their own distinct fields, but they share the same methods from the class.  

Classes can inherit from other classes in order to create objects with similar characteristics from all the inherited classes.  Using an OOP approach to programming forces the programmer to place data in an area that can not be easily accessed by the rest of the system.  The data is stored within  the methods and must be called in order to retrieve or modify the data stored in them.   With OOP code can easily be reused again and again in different scenarios to solve problems.

No comments:

Post a Comment