On 8/10/05, David Haynes <[EMAIL PROTECTED]> wrote:
> In poking around with various JSF tutorials/articles, I have seen a
> number of different directory layouts used to contain the backing beans,
> controllers, etc. Is there a 'best practices' consensus for a layout?
> 
> I have seen the controllers separated from the backing beans with each
> in its own directory (i.e. for bean 'foo', there is a fooBean.java in
> directory model, and a fooController.java in directory controller) and
> backing beans and controllers together under a bean directory. (i.e. in
> directory foo, there will be fooBean.java and fooController.java). I
> have also seen everything smooshed together but I am not a fan of this
> approach.
> 
> Ideas/Suggestions? Did I miss any documentation already discussing this?
> 

It would definitely be interesting to accumulate the wisdom of
experience on this topic -- perhaps in a Wiki page?  Here's a bunch of
"rule of thumb" ideas to get started:

* Model tier and persistence classes should *always* be
  in their own packages.  I've started being draconian on myself
  in this regard, to the extent that I build the model/persistence
  stuff in a completely separate project and just import the libraries,
  so I don't get tempted to intermix.  IDEs make this trivially simple.

* For a small project ("small" is a taste issue, for now lets use <=
10 pages) --
  put all the beans in one package per project, and all the JSP pages in the
  top level directory.  It's just not enough code to worry about sorting out.

* For a larger project, I tend towards:

  - Sort the JSP pages into subdirectories by use case

  - Put the corresponding backing beans into packages with the
    same hierarchical structure as the JSP subdirectories

  - Put adapter beans, as well as session/application scope backing
    beans into a package separate from the page-related backing beans.

Craig

  

> Thanks!
> -david-
> 
> 
> 
>

Reply via email to