Quantcast
Channel: TriumVir News » Programming
Viewing all articles
Browse latest Browse all 7

What is Object Orientated Programming?

$
0
0

At this point I’m going to introduce the concept of an object orientated programming. Although that term may sound confusing it is actually a very simple concept…

Imagine a car – it could be your own trusty Holden Barina/Vauxhall Corsa or it could be something less exotic, such as a Porsche 911 or a Maserati Spyder. A car has certain attributes, such as number of seats, colour, number of gears, engine size, whether it has a turbo or not and so on. It can also do things such as start, go forwards, go backwards and stop.

Now I want you to think about your computer. Like your car it also has attributes, such as memory size, hard disk size, processor speed and colour. It can also do things such as boot up, run a program, close a program and shut down.

A car and a computer are objects – you can see and feel them and you can experience these objects “doing things”. The premise of object orientated programming (or OOP for short) is that the programming environment consists of objects – they may not have a physical existence (except for within your computer) but they are treated as though they do. In Excel there are many different objects (hundreds). Some of the more common ones are Range, Worksheet and Workbook.

  • Objects have attributes. In object orientated programming (again, OOP for short) attributes are known as properties.
  • Objects can do things. In OOP the command to make an object do something is called a method.
  • Objects can react to something. In OOP reactions are known as events.

As mentioned above, you change or set the value of a property by specifying the object followed by a full-stop, then the name of the property, an equals sign (=) and then the value you want to assign i.e.

Object.Property = NewValue

Note! In general, when assigning a text value to a property, you enclose the text in speech marks e.g.

ActiveCell.Value = “Hello. This cell contains text!”

However, when assigning a numeric value to a property you do not generally need to use speech marks:

ActiveCell.Value = 100

Anyway, when you want to carry out an object’s method you type the object name followed by a full-stop and then the method name e.g.

Object.DoSomething

The post What is Object Orientated Programming? appeared first on TriumVir News.


Viewing all articles
Browse latest Browse all 7

Trending Articles