views:

10

answers:

1

I am new to JSF2 and would like to know something from a design perspective. For e.g. if we have multiple multiple usecases based on various actor types, which is better way in terms of design by considering below two scenarios?

e.g In a module having total usecases count say 10,

(Scenario 1) in this scenario for 1st & 5th usecase(UC) - ManagedBean1(MB1), 2nd UC - MB2, 3rd 4th & 10th UC - MB3, 6th 7th &8th UC - MB4 and for 9th UC - MB5. Here there are 5 managed beans for 10 usecases.

(Scenario 2) Just one ManagedBean for all ten usecases.

Also, assuming each usecase has minimum of 5-15 number of form fields and some considerable amount of activities(i.e.assume as java methods) for each usecase.

I wanted to know the Pro's and Con's of both the scenario if being implemented. Thank you all in advance.

Jai

A: 

There is not simple answer for such question. One pattern is to create ManagedBean for every JSF page.

If you create many beans, you have nicely separated responsibilities. On the other hand, if it makes you copy&paste code it doesn't make much sense.

You could also refactor repeating code into some abstract class, or utils.

amorfis
Your answer is upto point and i appreciate that. But from a design perspective, what are the factors that need to be thought in well advance other than seperating responsibilities and reusabilty as you have mentioned?This will surely wake up my mind to go more than what i can do right now. Thanks in advance.
Jai
Other factors? I don't know other factors. Sorry :( I would try to make separate beans and then check if there is repeating code. If there is -> refactor.
amorfis