Programming with a language such as VBA is known as ‘structured programming’ or ‘procedural programming’. Object oriented programming (OOP) is a fundamentally different programming paradigm. The features of structured and object oriented programming are listed below:
Structured Programming
- Structured programming involves decomposing a problem into smaller, soluble problems.
- Smaller problems coded as functions and procedures (known as Procedural Programming).
- Data is passed between programs as parameters.
- There is a clear separation between programs and data.
Objected Oriented Programming (OOP)
- Models real entities such as a Car, an Employee, an Order or a Booking.
- Objects store their own data…
- Objects have properties (also known as ‘fields’ or ‘attributes’).
- Objects contain the operations that can be performed on the data they store…
- Objects have methods (also known as ‘behaviours’ or ‘operations’).
Benefits of OOP
- Code Reuse: Classes can be put into code libraries then easily reused in other programs.
- Encapsulation: Programmers need not understand the details of how a program works in order to call it from another program. This allows a large application to be divided up between software engineers with different levels of skill.
- Design Benefits: OOP requires careful a design phase, in terms of entities, the relationships between them, their properties and their behaviours. Careful design results in applications with fewer flaws.
- Extensibility and Maintenance: OOP applications are relatively easy to improve and maintain. They have a logical structure. Code in one program can often be changed without requiring changes to other programs that call it. New classes can also be created quickly by extending existing classes through inheritance.