|
-
question about passing object references,Me and serialisation
Hi,
I have a class called Person. It inherits from a base class PersistentObject
that exposes Load() and Save() functions and contains an ObjectID.
I WANT to write the Load() method like this:
class PersistentObject
sub Load()
PersistentManager.LoadObject(Me) 'where Me is a By Ref parameter
end sub
The persistence layer uses .NET serialisation to return a populated object,
based on the persons ObjectId which must be populated when Load() is called.
(or does a refresh). It also examines other properties of the PersistentObject,
such as whether this is a proxy object or not.
Now the problem. Me cannot be assigned a new object. Likewise making the
parameter in LoadObject() By Ref and passing it Me does not work (interestingly
it compiles without complaint but simply does not change).
So I have resorted to making Load() a method that returns the newly loaded
object, meaning I have to write the ugly code:
class PersistentObject
function Load()
dim oObj as PersistentObject
oObj=PersistentManager.LoadObject(Me)
return oObj
end function
and in the main program:
person=person.Load()
when what I want to be able to write is
person.Load()
It's nice having Load() a method of the object, rather than having to call
a function in the persistance layer. Any idea's on how I could get the object
to change itself to the new object, within the Load() method, or solve this
design problem someother way? Guess I am missing something because this must
be a common scenario 
If not I guess the best thing is to put a method on the PersistanceManager
so I can write
PersistenceManager.Load(person)
Then there are no problems having Person being passed by ref and returning
a new object. (PersistenceManager is a singleton)
Any ideas?
Thanks,
Will
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks