From: Neill Harper
So why isn't there a demand for OO RPG, I want it ;-)
I would REALLY prefer that IBM NOT make RPG a fully OO Language! Procedural interfaces are better for a business oriented language, IMHO.
Notwithstanding the foregoing, Barbara Morris shared a little technique a number of years ago, which I've used extensively. OO languages generally use the "new" keyword to instantiate new objects, which encapsulate properties and methods. As an alternative, consider doing something like the following in RPG:
myPointer = myObjectNew();
Where myObjectNew() creates a new instance of a data structure, using %alloc(), and returns a pointer to it. That data structure represents a new instance of your object. All other procedures in the service program reference a particular instance of that data structure via "myPointer".
For "inheritance" purposes, consider writing service programs which are essentially wrappers around other service programs, but provide successively higher levels of abstraction.
Forget "polymorphism", it's not worth it.
Just suggestions,
-Nathan.
As an Amazon Associate we earn from qualifying purchases.