Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

business model to view model anamoly

 
Dhwaj Kuul
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • 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!
 
Jimmy Clark
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Now the solution seems to violate object oriented design principles


Which object-oriented design principles are you refferring to?
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic