× 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: Can RPGLE simulate OO programming?
  • From: "Scott Klement" <infosys@xxxxxxxxxxxx>
  • Date: 17 Feb 2000 13:42:56 -0600

Hi Tom...

"Tom Tufankjian" <Tom_Tufankjian@hbltd.com> wrote:
>
> Lately a question has been floating through my mind:  "Can RPGLE be
> used in a way simulate object oriented programing?"

I'd say the answer is "somewhat".  You can use sub-procedures like
you use methods...   But the whole idea of "inheritance" is just about
impossible to implement.   Furthermore, you can't really declare
different "objects" of a "class".   If your service program is an
object, you can't define 3 other objects of that same type (at least
not easily or on-the-fly) and you certainly can't have an array of
objects all of the same class that have different copies of the same
methods.

> In OO programming you don't pass parms all the time.  You call metho
> to "set" or "get" values.  That is the "public interface".
<<SNIP>>

I disagree with that statement.  You do pass parms -- when you set
values, you pass a parm containing the value to set it as...  when
you call a method, you pass parms to the method.

You can also set variables directly if they're defined as part of
the public interface of a class (tho most of the time this is frowned
upon because you can't guarentee their integrity) you can do the same
thing in ILE using activation group exports.

>
> One problem is that procedure names cannot be qualified by service
> program (I don't think).  So if you used two servie programs that
> contained the same procedure name, rpg would be confused.

This isn't a huge problem (at least in comparison to the inheritance
and class/object ones).   You can simply declare each procedure within
a service program as beginning with the service program name, like
"CustRec_SetStatus" and "ItemRec_SetStatus" would be procedures in
the CustRec and ItemRec service programs, respectively.

Then you'd call them as    CustRec_SetStatus('A') and perhaps
CustRec_Update() if you wanted to update the customer record.

>
> Sorry for being so long winded.  Any comments out there?
>

So, my conclusion is "not really" since two of the main concepts of
OO programming are inheritance, and the concept that objects are
declared as instances of a class are both pretty much impossible
in RPG.

Thanks for the brain workout :)
+---
| 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 ...

Follow-Ups:

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.