• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Web application design concerns

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi ranchers!

I have recently started studying frameworks such as EJB, JSF and JPA. To learn these techniques I have decided to implement a web portal for a recreational badminton leauge. Via the portal, the players should be able to post and analyze results. As I started to implement the application I have started to wonder if my application design is "correct", and if not, what is the "correct" way to implement such an application.
At the moment, my application is basically structured in the following way:

web page (JSF) <---> Service bean (Managed bean, often ViewScoped) <---> Session bean (DAO) <---> Entity (JPA)

Is this a good application structure?

Question/Reflection 1: How should lazy loading of collections be handled with this scheme?
(The application contains many 1 --> N relations, e.g. Division|1 --> N|Team and Team|1 --> M|GameSeries)
From what I have gathered, there are primarily two techniques to handle this. Either by using the extended transaction scope with stateful DAO:s, or creating queries which fetches the collections eagerly (join left fetch) with stateless DAO:s.
I have gotten the impression that you should avoid the stateful beans to the greatest extent possible to avoid performance issues. This is perhaps not relevant for my current application, since it's a very small one. But I don't want to learn bad habits.


Question/Reflection 2: Where do I put the business logic?
At the moment I have put the business logic inside the service beans. However, sometimes this feels non-intuitive. Take the Game (entity) for example. It contains the fields homePlayer (entity), awayPlayer (entity) and the gameResult. To decide which player that won the game, the application calls a method in the GameService bean. This feels a bit akward to me. If I for instance want to decide a winner of a game from the DivisionService bean (to calculate the division standings), I have to declare a GameService bean inside it.
A more intuitive solution would be to implement this functionality inside the Game entity itself. But then the separation of concerns is somewhat lost.
What is the best practice to solve this?

Best regards
Tomas




 
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Tomas
I am not sure if there is a need to use JPA and EJB in same app , or if there is some extra advantage one gains by using the two in same app.
JSF also gives you session scoped beans , so why use EJB Session bean ??

more shortly
reply
    Bookmark Topic Watch Topic
  • New Topic