• 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

Bean object updated by all 3 layers, is it good?

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

Recently I've encountered some code and figured out that there was a particular bean object which was used in all 3 layers(MVC).
The main issue here is all the 3 layers are updating information in the bean(left and right, resulting in not able to figure whats happening where to the bean object).

Not sure if this is a good practice, is there a design pattern which does this:
-- Initialize the object at once place, probably persistence layer
-- Strictly enforces other layers to follow some restrictions, so that updates are made thru' some Contract.

Regards,
Sharma
 
Rancher
Posts: 989
9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Depends on many things not specified here. Describe this bean object first. Is it an ejb 2.1 entity bean, an ejb 3 stateful session bean or what?
 
Kumara SharmaS
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Its a normal Java Bean, which rests on the Controller, but used/updated in Model as well as Presentation layer.
 
E Armitage
Rancher
Posts: 989
9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If it's a DTO then it can happen than the (disconnected) model can populate it and pass it to the model clients (controller) who can pass it to the view which is normal practice and there's nothing wrong with that.
If it's a view helper then the model should never be able to access it because it must live in your controller or view module and your model should never have dependencies to your controller or view modules.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic