× 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: Web apps on the AS/400
  • From: "Nathan M. Andelin" <nathanma@xxxxxxxxx>
  • Date: Sun, 18 Mar 2001 16:23:29 -0700


>Classes and subroutines are completely different
>programming entities.  Subroutine take parameters
>passed to them and do things to those parameters.
>Classes, on the other hand, have an internal state...

Actually, I see more similarities than differences between Java Classes
and ILE Subprocedures.  For example consider the following statements
in Java:

Vector v1 = New Vector(5);
Vector v2 = New Vector(5);

The variables, v1 and v2 both hold a different reference to a Vector class.
The "state" or "properties" of v1 can be referenced and manipulated
independently of those associated with v2, for example.

But, consider an RPG alternative:

Eval v1 = vectorNew(5)
Eval v2 = vectorNew(5)

In this case, both v1 and v2 are pointers that reference separate instances
of the same data structure that define the "state" or "properties" of the
ILE Vector.  The ILE syntax is a little different, but the results are
similar to the Java statements above.  To continue the example, the
following RPG statements:

CallP vectorStringAdd(v1: 1: myString)
CallP vectorStringAdd(v2: 1: myString)

might provide the same functionality as the Java equivalent:

v1.add(1,myString);
v2.add(2,myString);

The main difference is syntax.  A pointer must be passed to the RPG Vector
"method" in order to reference the correct internal data structure, while in
Java, the pointer precedes the "method".  But the "Add" methods may do the
same thing.

The trick to making this work in RPG is very simple.  Use the Based keyword
on the data structure that defines the Vector properties.  Then use the
Alloc opcode create a new instance of those properties, and return the
pointer to the program that called the vectorNew() method.

Anyway, I hope I've been able to make a point that it's easy to create ILE
objects that hold internal state just like their Java counterparts.  In
fact, by learning a few simple techniques, you begin to wonder why people
say RPG isn't "object oriented".

Now, I realize there's much more to "object orientation" than the simple
example I've outlined.  But, the more I learn, the less pronounced the
differences become.

Nathan.



+---
| This is the Midrange System Mailing List!
| To submit a new message, send your mail to MIDRANGE-L@midrange.com.
| To subscribe to this list send email to MIDRANGE-L-SUB@midrange.com.
| To unsubscribe from this list send email to MIDRANGE-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 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.