You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Øyvind Stegard <oy...@bluezone.no> on 2003/05/11 18:38:47 UTC

[DBModel<->Struts] - transport of information between the two application layers

Hi,

I would first like to mention that this is not a "problem" or technical difficulty, just a question of correct application design. Secondly, I am very inexperienced in this area. (Not Java-programming, but design of larger databaseapplications)

I am developing a Struts1.1 web application where I try to completely separate the business logic from the struts-specific things. This means I have categorized factory classes for all the operations I need to perform against the database. I use these factory-classes in my Struts Action-classes to retrieve and store information. No struts-specific elements are imported into the factory classes. The information is transported back and forth in the form of javabeans that reflect my database model/tables. 

I was simply wondering what would be most correct to do, when I need to connect values/columns from different tables, and send these connected values together back to the Struts layer. Emm.. kinda hard to explain, I'll try again:
My general business logic beans represent _one_ table each. Often it is necessary to connect columns from different tables to satisfy say a certain list to be presented to the user, but I can't store this bundled information into my simple one-table-beans. The question is: Should I create new wrapper beans that wrap other beans from different tables, or perhaps extends my other simple beans, simply to satisfy my need for a specific list of properties to be presented on a web page ? Or should I make several more simple factory-method calls in the Struts action classes, and connect the values there ? I'm thinking the second option is not very effective.

Of, course, I know how to solve this the dirty way, quite easily, but I wan't my application design to be as clean, extensible and correct, as possible. What I need is the thoughts of some experienced people, and I thought I'd find some of them on this list.


Regards,
Øyvind Stegard




---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: [DBModel<->Struts] - transport of information between the two application layers

Posted by Øyvind Stegard <oy...@bluezone.no>.
Indeed, many of the problems I've thought of were addressed in this framework at ibatis.com.
Thanks for the tip!
----- Original Message ----- 
From: "Vic Cekvenich" <vc...@baseBeans.com>
To: <st...@jakarta.apache.org>
Sent: Sunday, May 11, 2003 7:26 PM
Subject: Re: [DBModel<->Struts] - transport of information between the two application layers


> I would start with implementing this: 
> http://www.ibatis.com/common/common.html.
> For there, it would be hard to make a mistake.
> 
> Also... you might not be thinking about it, but use these Standard JSP 
> tags when possible: 
> http://jakarta.apache.org/taglibs/doc/standard-doc/intro.html , they 
> ship with Struts in contrib folder.
> 
> With Struts and above 2, you will have nice reusable layers.
> hth,
> .V
> 
> Øyvind Stegard wrote:
> 
> >Hi,
> >
> >I would first like to mention that this is not a "problem" or technical difficulty, just a question of correct application design. Secondly, I am very inexperienced in this area. (Not Java-programming, but design of larger databaseapplications)
> >
> >I am developing a Struts1.1 web application where I try to completely separate the business logic from the struts-specific things. This means I have categorized factory classes for all the operations I need to perform against the database. I use these factory-classes in my Struts Action-classes to retrieve and store information. No struts-specific elements are imported into the factory classes. The information is transported back and forth in the form of javabeans that reflect my database model/tables. 
> >
> >I was simply wondering what would be most correct to do, when I need to connect values/columns from different tables, and send these connected values together back to the Struts layer. Emm.. kinda hard to explain, I'll try again:
> >My general business logic beans represent _one_ table each. Often it is necessary to connect columns from different tables to satisfy say a certain list to be presented to the user, but I can't store this bundled information into my simple one-table-beans. The question is: Should I create new wrapper beans that wrap other beans from different tables, or perhaps extends my other simple beans, simply to satisfy my need for a specific list of properties to be presented on a web page ? Or should I make several more simple factory-method calls in the Struts action classes, and connect the values there ? I'm thinking the second option is not very effective.
> >
> >Of, course, I know how to solve this the dirty way, quite easily, but I wan't my application design to be as clean, extensible and correct, as possible. What I need is the thoughts of some experienced people, and I thought I'd find some of them on this list.
> >
> >
> >Regards,
> >Øyvind Stegard
> >  
> >
> 
> -- 
> Vic Cekvenich,
> Struts Instructor,
> 1-800-917-JAVA
> 
> Advanced <a href ="baseBeans.com">Struts Training</a> and project recovery in North East. 
> Open Source <a href ="baseBeans.com">Content Management</a>  basic
> Portal sofware
> Best practice<a href ="baseBeans.com">Supported Struts v.1.1</a>
> framework ScafflodingXPress
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: [DBModel<->Struts] - transport of information between the two application layers

Posted by Vic Cekvenich <vc...@baseBeans.com>.
I would start with implementing this: 
http://www.ibatis.com/common/common.html.
For there, it would be hard to make a mistake.

Also... you might not be thinking about it, but use these Standard JSP 
tags when possible: 
http://jakarta.apache.org/taglibs/doc/standard-doc/intro.html , they 
ship with Struts in contrib folder.

With Struts and above 2, you will have nice reusable layers.
hth,
.V

Øyvind Stegard wrote:

>Hi,
>
>I would first like to mention that this is not a "problem" or technical difficulty, just a question of correct application design. Secondly, I am very inexperienced in this area. (Not Java-programming, but design of larger databaseapplications)
>
>I am developing a Struts1.1 web application where I try to completely separate the business logic from the struts-specific things. This means I have categorized factory classes for all the operations I need to perform against the database. I use these factory-classes in my Struts Action-classes to retrieve and store information. No struts-specific elements are imported into the factory classes. The information is transported back and forth in the form of javabeans that reflect my database model/tables. 
>
>I was simply wondering what would be most correct to do, when I need to connect values/columns from different tables, and send these connected values together back to the Struts layer. Emm.. kinda hard to explain, I'll try again:
>My general business logic beans represent _one_ table each. Often it is necessary to connect columns from different tables to satisfy say a certain list to be presented to the user, but I can't store this bundled information into my simple one-table-beans. The question is: Should I create new wrapper beans that wrap other beans from different tables, or perhaps extends my other simple beans, simply to satisfy my need for a specific list of properties to be presented on a web page ? Or should I make several more simple factory-method calls in the Struts action classes, and connect the values there ? I'm thinking the second option is not very effective.
>
>Of, course, I know how to solve this the dirty way, quite easily, but I wan't my application design to be as clean, extensible and correct, as possible. What I need is the thoughts of some experienced people, and I thought I'd find some of them on this list.
>
>
>Regards,
>Øyvind Stegard
>  
>

-- 
Vic Cekvenich,
Struts Instructor,
1-800-917-JAVA

Advanced <a href ="baseBeans.com">Struts Training</a> and project recovery in North East. 
Open Source <a href ="baseBeans.com">Content Management</a>  basic
Portal sofware
Best practice<a href ="baseBeans.com">Supported Struts v.1.1</a>
framework ScafflodingXPress




---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: [DBModel<->Struts] - transport of information between the two application layers

Posted by Phil Steitz <ph...@steitz.com>.
Øyvind Stegard wrote:
   > Hi,
   >
   > I would first like to mention that this is not a "problem" or
   > technical difficulty, just a question of correct application design.
   > Secondly, I am very inexperienced in this area. (Not
   > Java-programming, but design of larger databaseapplications)
   >
   > I am developing a Struts1.1 web application where I try to
   > completely separate the business logic from the struts-specific
   > things. This means I have categorized factory classes for all the
   > operations I need to perform against the database. I use these
   > factory-classes in my Struts Action-classes to retrieve and store
   > information. No struts-specific elements are imported into the
   > factory classes. The information is transported back and forth in
   > the form of javabeans that reflect my database model/tables.
   >
   > I was simply wondering what would be most correct to do, when I need
   > to connect values/columns from different tables, and send these
   > connected values together back to the Struts layer. Emm.. kinda hard
   > to explain, I'll try again: My general business logic beans
   > represent _one_ table each. Often it is necessary to connect columns
   > from different tables to satisfy say a certain list to be presented
   > to the user, but I can't store this bundled information into my
   > simple one-table-beans. The question is: Should I create new wrapper
   > beans that wrap other beans from different tables, or perhaps
   > extends my other simple beans, simply to satisfy my need for a
   > specific list of properties to be presented on a web page ? Or
   > should I make several more simple factory-method calls in the Struts
   > action classes, and connect the values there ? I'm thinking the
   > second option is not very effective.
   >
   > Of, course, I know how to solve this the dirty way, quite easily,
   > but I wan't my application design to be as clean, extensible and
   > correct, as possible. What I need is the thoughts of some
   > experienced people, and I thought I'd find some of them on this
   > list.
     >
     >
     > Regards, Øyvind Stegard
     >

Opinions differ on this stuff, so take the following as one person's
view. Here are some ideas to think about:

* The amount of time and effort that you put into arriving at and
   implementing the "best" business layer design should be driven
   by practical considerations such as the expected lifetime of
   the application and the business objects, the likelihood that the
   back end may change, the likelihood that the web platform may change,
   and how you expect the application to have to scale.

* Personally, I don't like to force business objects to map
   exactly onto database entities.  The business objects should represent
   natural abstractions that make sense in the domain and they should
   not be too tightly coupled to the back end.  This is a
   debatable view, since actually designing a business layer and
   implementing a loosely coupled interface to the back end takes
   considerably more time than just automagically mapping tables/views to
   view elements on the front end. What you choose to do should
   depend on how you see the app and business tier components evolving
   over time and how stable the back end is.  If your data model is never
   going to change much, you don't have to be worried about having your
   application infrastructure tightly coupled to it.  On the other hand,
   If it is likely to change significantly, or if you have to worry about
   accomodating addititional data sources, or if you have limited control
   over it (shared with other apps, run by DBAs, etc.) or need to worry
   about data quality or representation issues (recoding, filtering,
   etc.), then a more loosely coupled design makes sense.


IMHO, the key is to think through the use cases and the application
change scenarios before finalizing your business tier design and
data access strategy. Choose the design that gets you where you want to
be the fastest, but make sure that where it gets you is where you really
want to be ;-)

Phil

Phil

     >
     >
     >
     > ---------------------------------------------------------------------
     >

     > To unsubscribe, e-mail: 
struts-user-unsubscribe@jakarta.apache.org For
     > additional commands, e-mail: struts-user-help@jakarta.apache.org
     >








---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org