Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>It doesn't look like there are too many beans, but of course it depends on what the beans do and how they are used. The "one bean per view" rule is quite common and there is usually nothing wrong with this. Of course, if you can write some beans that are more general and can be used on many/all views, you should certainly do this, just try to keep their purpose clear and focused on a single task.</p> <p>The fact that most of your beans are request-scoped is good. Only beans which have to keep some state during the whole duration of a user session should be put into session scope (hence the name). This also keeps the per session memory consumption low. Application scope is usually used for beans that have to be created once and are used by all users of your site. Like global variables/singletons, you should use them sparingly.</p> <p>But about your idea that one session bean is enough: There is no general rule how many beans have to be in which scope. Design and develop the beans and then decide in which scope they need to be. As I said, it's very likely to have the number of beans in session scope lower than the number of beans in request scope, but if a bean has to be in session scope to work properly, you shouldn't be afraid of it.</p> <p>Don't try to squeeze everything into a single session bean, just because you want to have only one bean in session scope. This would be called a <a href="http://en.wikipedia.org/wiki/God_object" rel="nofollow noreferrer">God Object</a>, which is an <a href="http://en.wikipedia.org/wiki/Anti-pattern" rel="nofollow noreferrer">anti-pattern</a>.</p> <p>So for example, you have some user information (e.g. full name, status, role...) stored in a database, which you want to display on all pages when a user is logged in (like the grey bar at the top here on SO). This would be something you could implement as a session-scoped bean which is used on all of your pages (or better yet, in some header which is included on every page). This bean would be created as soon as the user logs on and fetches the information just once from the database.</p> <p>In an online store, another session scoped bean could be used for storing the shopping basket of the user. Yet another session scoped bean could be used for managing a separate shopping list...</p> <p>Apart from that, I would like to comment on the naming rules/style you and your team uses:</p> <ul> <li>You should decide on one language (preferrably English) and stick to it, so no class/method/variable names like "PasswordVergessen"</li> <li>Every class/method/variable should have a descriptive and self explaning name, so don't use somthing like "ApplicationBean1"</li> <li>Try to organize your faces-config into blocks (separate navigation rules from bean definitions, etc.)</li> </ul>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload