4. Object oriented concept

An object-oriented programming (OOP) language makes use of the idea of classes and objects.

A program written in an object oriented language will be made up of a number of classes and objects. These classes and objects are manipulated through their internal methods.

Before OOP languages came along, procedural languages, such as 'C', treated data and the programming instructions that act upon the data as separate things.

This separation made it very easy to write faulty code such that one part of the software would over-write data at the wrong time.

A small non-OOP clip:

global variable X;
function A() {
           X = 20;
 }
function B() {
           X = 1000;
   }

In the clip above, one part of the main software may call function A to set the global variable X, but then another part of the software could call function B at the wrong time and X gets unintentionally changed. De-bugging this kind of problem can be difficult as the conditions that made it happen can be very obscure.

So the main idea of object oriented languages is to gather the data and all the methods (functions) that act upon that data into one entity called a 'class', so making data hiding, code re-use and maintenance much easier.

Pro

  • OOP makes it easier to provide working code. A class can be fully tested and released for other coders in the team to use
  • Classes can be treated as 'black boxes'. Other coders do not need to know how the class works internally. They just need to know how to manipulate it through its methods.
  • There are many 'design patterns' available, developed over the years, that solve common programming tasks. A coder can pick up a design pattern for perhaps an user interface and begin coding straight away.
  • Code re-use. Easy to move a class from one application and re-use it on another project
  • Code portability. Just get the right compiler for the target CPU and the source code can be run on an entirely different hardware platform

Con

  • Steep learning curve, becoming proficient in an object-oriented language can take a long time as it is more complicated than a standard procedural language.
  • Complex - it needs skill to craft efficient and flexible classes.
  • Not as compact and efficient as writing code directly in a low level language

Example of OOP languages

  • JAVA created by Sun Microsystems around 1995 and is now widely used on a number of hardware platforms from web servers, back-end business applications and even mobile phones. Code is run on a 'Java virtual machine'.
  • C++ around since 1983, it has become one of the most popular OOP languages available. It has some low level language features as well as OOP high level features. It is widely used for games development, embedded software, device drivers as well as standard coding work.

 

Challenge see if you can find out one extra fact on this topic that we haven't already told you

Click on this link: OOP languages

 

 

 

 

Copyright © www.teach-ict.com