Home arrow static arrow Java Programming [Archive] - Call By Reference
Warning: Creating default object from empty value in /www/htdocs/w008deb8/wiki/components/com_staticxt/staticxt.php on line 51
Java Programming [Archive] - Call By Reference
This topic has 19 replies on 2 pages.    « Previous | 1 | 2 |

Posts:458
Registered: 7/1/03
Re: Call By Reference  
Aug 9, 2004 8:50 AM (reply 15 of 19)



 
Addendum:

Clonable is actually something of a broken mechanism and not reccommended. (Bloch, Effective Java, 2001)

As he says, "There are better ways to copy objects."

You might look into using a Dynamic proxy or some other interface design techniques to solve your problem.
 

Posts:3,258
Registered: 00-08-28
Re: Call By Reference  
Aug 9, 2004 8:53 AM (reply 16 of 19)



 
Addendum:

Clonable is actually something of a broken mechanism
and not reccommended. (Bloch, Effective Java, 2001)

As he says, "There are better ways to copy objects."

You might look into using a Dynamic proxy or some
other interface design techniques to solve your
problem.

I would second it.
 

Posts:27,518
Registered: 11/3/97
Re: Call By Reference  
Aug 9, 2004 9:31 AM (reply 17 of 19)



 
Wouldn't it just be easier to write methods that are either supposed to change the object versus those that use it but do not change it?
 

Posts:106
Registered: 8/30/01
Re: Call By Reference  
Aug 9, 2004 5:52 PM (reply 18 of 19)



 
In fact, this is the first time I came to such problem, but infact Java pass by value only the enclosing object, so in my case

I pass an Object Timetable to a method to be scheduled, I thought for a while that the original time table won't change, but in fact I realized after long battle that it does. The Timetable is Composed of Students Objects, Rooms, TeachingEvents, etc..., in the scheduling process, these has to be changed (availablity of rooms, students clashes ,etc...) Unfortunately these changes have happend in the original timetable problem. to skip over, and by the help of all posts over this forum, I had to write length, and boring copy constructor, in order to preserve the original value of the object Timetable.

I guess this is a serious topic, and it might need further discussion. Thanks any way, I will look at your chapter for sure.
Eyad
 

Posts:37,103
Registered: 3/30/99
Re: Call By Reference  
Aug 9, 2004 6:59 PM (reply 19 of 19)



 
In fact, this is the first time I came to such
problem, but infact Java pass by value only the
enclosing object, so in my case

No, Java does not pass objects at all. Java passes references. These references are passed by value. It may be that this is what you meant by "enclosing object," but it's important to get the terminology right, and even more important to understand what's really happening.

Objects are not copied or passed, only their references are, so that both the caller and the callee will have references pointing to the same object.
 
This topic has 19 replies on 2 pages.    « Previous | 1 | 2 |