PAPER 2 - ⇑ Fundamentals of programming ⇑

← Number bases Object-oriented programming concepts Binary number system →


Specification

edit
Specification coverage
  • 4.1.2 Programming paradigms
    • 4.1.2.2 Procedural-oriented programming
    • 4.1.2.3 Object-oriented programming

Object-oriented programming

edit
Procedural programming languages - languages where the programmer specifies the steps that must be carried out in order to achieve a result.


The key difference between procedural and object-oriented programming is that in procedural programming, the lines of code and the data the code operates on are stored separately. An object-oriented program puts all the data and the process that can be carried out on that data together in one place called an object and allows restrictions to be placed on how data can be manipulated by the code.

Object-oriented programming can be described as being organised in a way that reflects the real world. For example, in real life you may have an object, such as a bank. Inside that object there are various other objects such as customers and financial transactions. Inside each of those objects there are a number of data items and behaviours. For example, there are data about customers. These data are handled in a particular way and therefore have to be processed accordingly. For example, one process might be to add new customer data.

Another process might be that money withdrawn needs to be deducted from the balance.

In object-oriented programming, a banking application would be created to mirror these real-life relationships. So there might be one object will then contain customer data and all the processes needed for that data.

In most OOP languages classes are used, this allows the efficiency of programming to be increased.

Modular design - a method of system design that breaks a whole system down into smaller units, or modules.


There are a number of advantages to this approach:

  • Programs are written in modules, which means that it is easy to amend programs as only the affected module needs editing
  • It is also easier to add new functionality to a program by adding a new module
  • Most programs are written by teams of programmers so the modular design approach allows groups of programmers to work independently on self-contained modules
  • Objects can inherit attributes and behaviours, making code reusable throughout the program
  • Changes carried out to data are made within an object rather than in the program. This makes it less likely that changes made to code will inadvertently affect the results of another routine, which is a common cause of bugs in software programs
  • Libraries can be created, enabling code to be reused easily