File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes OO, Patterns, UML and Refactoring and the fly likes business model to view model anamoly Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » OO, Patterns, UML and Refactoring
Bookmark "business model to view model anamoly" Watch "business model to view model anamoly" New topic
Author

business model to view model anamoly

Dhwaj Kuul
Greenhorn

Joined: Jul 10, 2006
Posts: 7
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

Joined: Apr 16, 2008
Posts: 2187
Now the solution seems to violate object oriented design principles


Which object-oriented design principles are you refferring to?
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Yeah, it's not clear to me what this violates--it's perfectly normal and reasonable. The way you're doing #2 seems bizarre.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: business model to view model anamoly
 
Similar Threads
Class referencing question
inner-join?
OOP considered harmful (was: C. Date on UML book)
OO design
Marshalling XML with Spring (How to handle referenced classes)