|
Joe Pluta wrote: > I ought to do a primer someday on using RPG procedures to mimic OO behavior. > It's actually quite fascinating, and relatively easy to accomplish. Each > "class" is actually a module with one procedure for each "method". There is > also a "constructor" which allocates a chunk of memory (or multiple chunks, > depending on the object) and returns a pointer to it - this pointer becomes > the object "handle". Every other method in the module takes as its first > argument a handle, which is used within the module to access the memory. And I for one would like to see such a "primer". What you've described is more appropriately called "object-based", and not "object-oriented". Although it may well "mimic" some aspects of OO behavior, you still haven't accounted for things like polymorphism and inheritance. Without those things, you just don't get most of the advantages of true OO. Confusing the two concepts seems to be fairly common (especially by marketing types), but the difference is substantial. In "object-based" design, you have a reference to some object (or rather some area of storage), which can then be passed to specific procedures or API's. It is the caller's responsibility to ensure that the correct procedure is called. In contrast, in "object-oriented" design, it is the responibility of the object (not the caller) to determine the appropriate action when a particular method is invoked. In other words, when you see the term "object-based", think "procedural". For example, in an OO design, you can have two objects that both implement method "glorp". When you apply method "glorp" to one object, it might have one particular effect, but applied to the other, something different might happen. But (hopefully) in either case, a "glorp" action appropriate to the object would happen. The caller doesn't have to understand how it works, or rather, which particular implementation is invoked. The caller only has to know that the object is "glorp-able", and just has to invoke it using some direct syntax like "obj.glorp()", instead of by using a big "select" statement with a "when" clause for each type of "glorp-able" object. (And that only touches on the concept of polymorphism.) Might it be possible to "simulate" true OO behavior in RPG in *all* its glory? Well, I've tried to come up with a design for it, and have given up on it, quickly. But then again, why bother when there are so many other good *truly* OO languages available? Cheers! Hans
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.