Object Spaces programming model for an ASP.NET scenario

I just posted these questions on the microsoft.public.objectspaces newsgroup:
Lately, I’ve been wondering what the preferred or best programming model for OS is, in an ASP.NET scenario. By this I mean: how would you program with ObjectSpace or ObjectSet objects in a multithreaded/multiuser environment in a way that is most suited for OS?
An ASP.NET application typically has multiple concurrent users. ASP.NET itself is multithreaded. Some thoughts in that regard that crossed my mind:
  • Seems to me that an ObjectSpace object is typically expensive to create. How expensive is it in reality? Is creation of a new ObjectSpace object on every http request a smart thing to do or not to do?
  • If the answer to the point above is “don’t do that”, would you create one ObjectSpace or ObjectContext for every user and store it in session state (because it seems that you will need to track your objects: see point below)? Or, would you just store it in cache or application state? The documentation says: “Thread Safety: Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.” Hence, having a shared ObjectSpace or ObjectContext object does not seem like a good idea.
  • Say you would not be able to cache or store your ObjectContext (or ObjectSpace or ObjectSet) object, and you want to update your changed business object. As you were unable to track any changes, a database roundtrip seems necessary. You could either materialize the object again, transfer the values from the changed object onto the retrieved one and call PersistChanges. Or just call Resync on the object an then call PersistChanges. Is the only way to update an object without a roundtrip one where you have a tracked original? (Just like you need to retrieve the object before you can delete it using ObjectSpace.MarkForDeletion?)
How do you use OS in ASP.NET? Any thoughts are greatly appreciated.
These questions have been going through my mind for a couple of weeks now. I cannot seem to find any kindred souls that have documented on this usage scenario for ObjectSpaces. The SDK documentation on the subject is so thin, any examples always retrieve, update and delete in one go. This is not possible in a web scenario, where there is usually one request in between retrieval and storage. Sure, you could retrieve and store in one request, but that would require two database server roundtrips. Sounds like it’s not the smartest thing in the world you can come up with.

I’m very curious on the reactions I will get and the length of the thread. There must be a lot of people who have explicit ideas on this. My expectations are high.

This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s