Hello,
Throughout the forums, you'll notice 3 main approaches for the management of the session in a winforms application:
a) keeping 1 session open for the whole application
b) having 1 session per form
c) having 1 session for each atomic piece of data access
I do not think (a) is a good idea. In fact, it really is a very bad idea because everything you loaded during your applications' lifetime, stays in the session. This boils down to a huge memory leak. The only advantage is that you don't have to care about lazy-loading.
A lot of people seem to like the 1 session per form approach, and also seem to be satisfied with it. I can emphasize with that, but this approach means you are binding the lifetime of your session to a forms' lifetime (suppose you're building a 3-tier application, how can you manage that ?).
Also, if objects are passed from one form to another, you'll have to rebind you object to another session anyway.
Personally, I think approach (c) is the way to go. Of course, I do realize that it is a pain in the ass to manage the lazy loading this way, but on the other hand it allows you to freely pass objects from one session to another and to have a stateless application server without having to keep track of which session was used to retrieve which object.
So it boils down to this: what kind of application are you building? For a middlesized application, I think approach (b) can be handy because you don't have too much hassle with the lazy loading. For an entreprise-grade application, I'm thinking approach (c) would be the best.
Unfortunately, there aren't many examples of approach (c) to find, so I'm building in my spare time an example of a 3-tier application using remoting, that I will post here somewhere in the next week. It won't be a beauty, but it might help.
_________________ Please rate this post if it helped.
X.
|