Maybe I'm repeating myself, but I give myself a last try :-) 
 

> -----Ursprüngliche Nachricht-----
> Von: Michael Jouravlev [mailto:[EMAIL PROTECTED] 
> Gesendet: Donnerstag, 12. Mai 2005 21:43
> An: Struts Users Mailing List
> Betreff: Re: [POLL] What do you use action forms for?
> 
> On 5/12/05, Leon Rosenberg <[EMAIL PROTECTED]> wrote:
> > Well the question was, why to use ActionForm if a POJO will 
> do it es well?
> 
> Umm... No reason, unless one wants to use same ActionForm for 
> input, edit, view, etc.

Well I'm a beliefer of  design by responsibility. When I design an
application I identify responsibilities to form and define components,
modules and layers. Therefore I like each class to have a clear contract. 
As Frank said it may be a balancing act, but experience teached me, that
it's better to have 50 small classes with clearly defined 
contracts then 10 butterflies. I don't like to create unnecessary
dependencies, if I have to change a page, I change the action
which prepares the page, the bean, which is used in this page and the jsp. I
don't want to care about, where do I use this bean either.


> > And keeping current object in session isn't a solution to 
> all problems...
> > 
> > Just to give you an example, in our current application we 
> have about 
> > 5000-7000 active session on each webserver. We have tons of 
> object, so 
> > if we would keep _EVERYTHING_ in session, what amount of ram the 
> > server would need?
> 
> With 10K per session that would be 70 Megs. Not much. Also, I 
> store only one object per session, this is why it is current. 
> But I do not have to deal with 7000 sessions simultaneously :)
> 
> On the other hand, you need to keep request data somewhere as 
> well. It is the same RAM. Ok, request is cleaned 
> automatically, session is not.
> To help with that, I have certain modes/pages, which 
> invalidate session. Like, if I load item list, I invalidate 
> current item. That is, I remove it from the session. I do not 
> think that all users look at the item, and then leave the 
> site. They might go to the list, and then leave the site ;) 
> Also, session timeout can be adjusted.
> 

Well it maybe get too detailed, but if you keep objects in sessions instead
of request you are actually working against the garbage collector. Objects
in request are freed as soon, as the request is served. Since most
application has less use cases then requests, the 
chances aren't bad, that similar request (request to same action) will come
in shortly. With the modern garbage collector, the vm can
'reuse' the object scheduled to collection without actually manipulating the
heap. At least in theorie you can reduce the effort for 
proper garbage collection run to a minimum.

If objects are stored in sessions on the other hand, this process becomes
more asynchronous, and you can't use natural dynamics of user's behaviour to
your advantage.

Other, very powerful anti-session-argument is concurrency. If your session
object actually represent a business data object, which is 
managed by some business logic components or stored in the db (or both) you
have to watch for changes done by other users/actors. This mean that you
actually have to notify the webservers about any changes to the objects (or
implement very complicated locking mechanism), so they can clean their
session-object-cache. It's just an additional effort, and it's often faster
and easier to get a new copy of the object on request, as to maintain and
synchronize that kind of cache. 

> I am not saying here that my approach is the best. But I do 
> not think that it is a "bad practice" either :)

No we just discussing it, and it is surely suitable for some applications,
but it also brings enough problems to keep it off the "best practices" in my
opinion :-))) 

Regards
Leon

> 
> Michael.
> 
> P.S. If a problem can be solved by adding more RAM, it is not 
> a real problem ;) This is what Microsoft keeps proving with 
> Windows: 640K, 1M, 4M, 16M, 64M... But people still use it, 
> they just put more memory in their machines. Someone can 
> still advertise OS which fits on one floppy and has 
> full-blown GUI, multitasking, etc. But who cares, if 
> polishing assembly code takes so much more than simply using VB?
> 

I'm using a linux software router at home, which fits on a floppy. The
advantage is, that it's booting fast and is copy-protected, 
so noone can modify my configs for longer then reboot time. But it's very
offtopic now :-)




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to