× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.


  • Subject: Re: OO in RPG
  • From: Jim Langston <jimlangston@xxxxxxxxxxxxxxxx>
  • Date: Mon, 04 Dec 2000 10:00:07 -0800
  • Organization: Pacer International

I program in OO a bit, but I don't know all the terms.  I can thing of 
doing just about everything I do in OO with the exception of function
calls.

It is a simple matter to make an "object" a data structure.  We can do that
for all the variable types, and with some creative programming can store
pointers in a data structure.  But... how do you store a function call into
a data structure?

How do I define
    virtual Create(void);
in a data structure?  Is it possible to call a function using a pointer to 
the function in RPG?  Not that I've seen.  It is a simple matter to copy
a data structure for inheritance.  But how do we change the call to the 
function, that we couldn't store in the data structure in the first place?

In C it's not problem, you can store a pointer to a function, and call that
function via the pointer.  So you can emulate OOP in regular C using a 
preprocessor.  But the same functionality doesn't exist in RPG.  But the
real question is, do we want it to?

If we are able to start throwing pointers around willie nillie, don't we 
get into the same hassles as in C, that its a pain in the neck to debug because
so many of your variables are pointers, or pointers to pointers that looking
at the contents tells you nothing.  Do we want this headache in RPG?

With free form RPG we are getting closer to OOPs, and perhaps in the next
version of RPG after that we will have some true OOPs.  But it's probably 
better to let the compiler folks such as Hans and Barbara work on it so
RPG doesn't become a nightmare to work with.

Regards,

Jim Langston

Joel Fritz wrote:
> 
> I actually reviewed the state of the thread before responding.  I agree that
> ILE provides some things that are associated with OO, but I also agree with
> Hans that RPG isn't ideal.  IMHO what you can do is:
> 
> Encapsulation:  You probably already do this with subroutines and dynamic
> calls, but if you use sub procedures and service programs, you get better
> protection against side effects from the use of global variables and forced
> passing of parameters by reference.
> 
> Abstract data types and true objects:  You can't really do it, but service
> programs can give you some of the features of an object.  Maybe someone else
> has figured out a way to do it, but the sticking point is multiple instances
> of the same object.
> 
> Polymorphism:  You can't really do it, but you can do some things with
> argument lists and operational descriptors that give you some of the same
> thing with a lot more work.
> 
> Inheritance:  Nope.
> 
> Another question, probably good for a Friday, is how useful is the object
> oriented model?  I like it as a way of approching problems, but has it
> revolutionized application development the way people thought it would ten
> years ago, or so.  I seem to remember predictions of a whole new class of
> programmers who would build applications from "boxes" of components and
> write almost no code except to pass messages back and forth between the
> components--all drag, drop, and connect the dots.
+---
| This is the RPG/400 Mailing List!
| To submit a new message, send your mail to RPG400-L@midrange.com.
| To subscribe to this list send email to RPG400-L-SUB@midrange.com.
| To unsubscribe from this list send email to RPG400-L-UNSUB@midrange.com.
| Questions should be directed to the list owner/operator: david@midrange.com
+---

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

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.