× 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.



I'm not sure I'm following along but if you need two empty copies of a class so you can store values separately, you just create two new objects of the type you want to use. Using your example, it would be:

MyClass copy1 = new MyClass();
MyClass copy2 = new MyClass();

If you want "copy2" to have the same values as "copy1", then that class should either accept a MyClass object in the constructor or provide a copy method. That is the OO way of doing things. What you're complaining about is sort of like complaining about having to peel oranges because you don't have to peel apples to eat them.

This type of thing did confuse me at first but I read a book called "Beginning Java Objects" that really helped out. Once you understand the principals, it will all make sense.

Matt

-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Lim Hock-Chai
Sent: Thursday, June 19, 2008 3:50 PM
To: RPG programming on the AS400 / iSeries; RPG programming on the AS400 / iSeries
Subject: RE: Is RPG 'DEAD"

That is the point that I tried to make. Java class provides some neat features that developer can use to develop code. However, it also has a lot of limitation.

BTW, I doubt it is that easy to create a generic and reuseable CopyFrom class to do this. Remember that the copy-from-class is likely to also contain other class variables. So, simply calling copy-from-class's get method might do no good.
As far as create a copy from construtor, that isn't that programmer friendly, is it? That means everytime I need to make a copy of a class, I've to add a copy from Constructor if it does not already have one. What if the class I try to make copy from belongs to thrid party vendor?

And also, should I code the CopyFrom class or contructor to throw an exception if it encounter a problem making a copy?
if so, my code that need to do a copy would probably look like something below:
try {
MyClass saveIt = new MyClass(originalClass);
}
catch (CopyError e) {
//will I better call my generic logging method to log the error
logIt((Exception) e);
// I also better try to send to email to notify me that some go wrong
// Wait a mintues, our reusable send email class also throw exception
try {
// instead of hard code my email address,
//I probably should use a property file to do that
...Properties...
//Instead of hard code the message, I probably should use a
// resource bundle file to get the message I want
.. Resource....
// now send the message
sendEmail(...);
.. exit program
}
catch (Exception e) {
//uumm not sure what I should do, just log it I guess
logIt(e);
}
}

wait, what was I suppose to do in this class to meeting the project requirement now?


Java is a great language, but to blindly say that RPG is dead and java can easily replaces all those old RPG codes is not a easy pill for RPG folks to take.


________________________________

From: rpg400-l-bounces@xxxxxxxxxxxx on behalf of Walden H. Leverich
Sent: Thu 6/19/2008 11:39 AM
To: RPG programming on the AS400 / iSeries
Subject: RE: Is RPG 'DEAD"



In RPG, you do saveDS = originalDS. In java, you can either ...

Yes, because java doesn't support operator overloads. If it did you
could do:

MyClass saveObject = originalObject;

And the addition of decimals would also be trivial as the + operator
would be overloaded to work as expected.

You could define a method on the class called something like CopyFrom()
or create a copy constructor that created one object from another.

-Walden

--
Walden H Leverich III
Tech Software
(516) 627-3800 x3051
WaldenL@xxxxxxxxxxxxxxx
http://www.TechSoftInc.com <http://www.techsoftinc.com/>

Quiquid latine dictum sit altum viditur.
(Whatever is said in Latin seems profound.)
--
This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.



--
This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.



As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
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.