File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes OO, Patterns, UML and Refactoring and the fly likes Business Layer Design in J2ee Poject Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » OO, Patterns, UML and Refactoring
Bookmark "Business Layer Design in J2ee Poject" Watch "Business Layer Design in J2ee Poject" New topic

Business Layer Design in J2ee Poject

amit gole

Joined: Aug 31, 2012
Posts: 1
Hi to all members,

Currently the project on which I am working on a j2ee project which is being developed with Spring, Hibernate and struts. The business layer consists of simple java beans with no behavior in them only properties with getter and setter methods.The services in business layer acts on these simple java beans like populate them from data access data and then return to presentation tier.My questions is that is it object oriented way of designing business layer or simply the procedure way in which the data and the functions on which they operate are not together. Please provide your thoughts and inputs on how the business logic is designed and implemented in j2ee application, is the domain model just contains simple objects with no business methods in it and services are written on these java beans which implements the business logic.
whats are the design patterns used in the development of business layer.

Thanks And Regards

Junilu Lacar

Joined: Feb 26, 2001
Posts: 6529

Data-only domain objects are smelly. It doesn't mean they're necessarily wrong but it's an indication that maybe your business service classes might be overstepping their bounds. There are no cut and dry rules for this kind of thing though, as far as I can tell. I use testing to help me find bad choices. When it's hard to test some behavior because of too much setup or too much coupling, then I know it's probably time to refactor. I can't think of a good example off the top of my head but I know I've encountered situations where I've moved logic from a business service class back into a domain object after detecting the "data only domain object" smell. The rule of thumb I use: Business Services coordinate work between different objects. Domain objects keep track of the integrity of its relationships with other objects. Another guideline I use that helps with properly assigning responsibilities: Define the transaction boundaries at the business service level, not at the domain object level.

Hope this helps.

Junilu - [How to Ask Questions] [How to Answer Questions]
Junilu Lacar

Joined: Feb 26, 2001
Posts: 6529

... and Welcome to the Ranch!
I agree. Here's the link:
subject: Business Layer Design in J2ee Poject
It's not a secret anymore!