What is Object Orientated Programing? ![]() ![]() Object-oriented programming (OOP) is
a programming paradigm using "objects"
– data structures consisting of data fields and methods together with their interactions to design applications and computer programs. Programming techniques may include features such as data abstraction, encapsulation, messaging, modularity, polymorphism, and inheritance. Many modern programming languages now support OOP. ![]() The simplest method to explain Object Orientated/Oriented Programming is through a simple program that incorporates user accounts. Generally the program will incorporate multiple units. The first unit will hold our array class, each subsequent object will be stored in the array, as an instance, held within this class. By personal default I name & save this unit as IdentifyingNameArrayU. Class Declaration:Now within the array unit you, will need to define a class. As follows: unit SpyArrayU;
//Jesar|Arts
//Jeremy Paton
//Open Source - Free Ware
interface
uses Sysutils, SpyU, ZeroSpyU, DBU; //As required
Type TSpyArray = Class //Declaration of class
Private //Accessible only from this calss
SpyArr: Array[1..100] of spy; //Will require a Loop in most code.
Size: Integer;
protected //Accessible by inheritors
Public
Constructor create; //Always in Public.
//Accessor Methods - Assess value.
Function getMethod(s)
//Mutator Methods - Changes value.
Procedure setMethod(s)
//Other Methods - Returns value or Changes value.
Procedure
Function
End; //Array class end
![]() Object/Instance Declaration:Once you have created the array class you will need to create an object class, the array will be populated by instances of this object. By personal default I name & save this unit as IdentifyingNameU. unit SpyU;
//Jesar|Arts
//Jeremy Paton
//Open Source - Free Ware
interface
uses sysutils;
Type spy = class //Single object (not multiple array).
Private
Protected
Constructor create(F: String); //Parameterized
Public
//Accessor - Assess value.
Function getMethods(s)
Function getNaam: String; //Example
//Mutator - Changes value.
Procedure setMethods(s)
Procedure setNaam(F:String); //Example
//Other - Returns value or Changes value.
Function toString: String; //Example
End; //Spy class end
![]() Object/Instance Base Code:Once you have created the the object class you will need to complete all the base code, this code must be written in the same unit. A quick way to produce the base code procedure and function statements is to hold Shift + Ctrl + C. Base code is all the code for the objects Constructor, Accessor, Mutator and User Defined methods. Constructor Create: Example Constructor spy.create(F: string); begin Naam:= F; end; Accessor Method: Example Function spy.getNaam: String; begin Result:= Naam; end; Mutator Method: Example Procedure spy.setNaam(F: String); begin Naam:= F; end; ![]() Array population Declaration:There are multiple methods of importing data into your program such as, text files and databases. The most common method intermediate users will start of using is via text file extraction. You can find loading from text file code here and loading from database here. |
Object Orientated Programming: ![]() |


An Introduction to OPP



