You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by David Haynes <da...@sympatico.ca> on 2005/08/10 17:40:55 UTC

Recommended directory layout?

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?

Thanks!
-david-




Re: Recommended directory layout?

Posted by Craig McClanahan <cr...@gmail.com>.
On 8/10/05, David Haynes <da...@sympatico.ca> 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-
> 
> 
> 
>

RE: Recommended directory layout?

Posted by Eric Kelm <er...@vsgadmin.com>.
I personally separate the logic of processing from the bean itself. To me,
the methods for processing should not be in the bean class itself. I think
having methods for processing in a bean violates the definition of bean.
But I digress.  I use the following structure:
com.Xcomp.projX.beans.FooBean           <-- the FooBean for projX
com.Xcomp.projX.handlers.FooHandler     <-- methods using FooBean of projX

Of course the getter/setter methods still exist in FooBean, otherwise it's
not a bean, right :)

---------
Eric Kelm
Developer, VSG Worldwide LLC


->-----Original Message-----
->From: David Haynes [mailto:david.haynes2@sympatico.ca]
->Sent: Wednesday, August 10, 2005 10:41 AM
->To: users@myfaces.apache.org
->Subject: Recommended directory layout?
->
->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?
->
->Thanks!
->-david-
->
->