• 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
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

business model to view model anamoly

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am developing in a SOA arch with a web service as the business service and a JSF front-end.

Problem-
The business model nearly always has a hierarchy similar to a classic - "A Department has many Employees." And there can be multiple Departments. So we have class Department and class Employee. With the list of Employees aggregated in the class Department.

Now the view can either be-
1. List the departments with a drill down on employees in a department. This is fine no probs here.
2. List the Employees along with their department details.

displaying view # 2 becomes a pain on the jsp since one has to iterate over the department list and then iterate(nested) over the employees list. This is the only way we can reference the department of an employee.

A simple solution that can solve this is to have a each employee object keep a reference to its department maybe in the view model. And iterate over only the employee list wherever required with still a reference to the department. Now the solution seems to violate object oriented design principles but it is very practical. Greatly appreciated any other solutions\ opinions. Thanks!
 
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Now the solution seems to violate object oriented design principles



Which object-oriented design principles are you refferring to?
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yeah, it's not clear to me what this violates--it's perfectly normal and reasonable. The way you're doing #2 seems bizarre.
 
moose poop looks like football shaped elk poop. About the size of this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic