Solved

BO(business object classes) vs VO(value object classes) in java

Posted on 2013-11-22
5
2,352 Views
Last Modified: 2013-12-02
Hi,

I see  AbcVendor.java is under the vendor-org-bo package.(i think it is business objects)

When I see AbcVendor.java code it like as below  
import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Version;


/**
 * The persistent class for the vendor_organization database table.
 *
 */
@Entity
@Table(name="vendor_aaa_organization")
//@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)

public class AbcVEndorBo implements Serializable {

	@Column(name="VENDOR_PRICE_CHECK")

	private String vendorPriceCheck;

	public String getVendorPriceCheck() {
		return vendorPriceCheck;
	}

	public void setVendorPriceCheck(String vendorPriceCheck) {
		this.vendorPriceCheck = vendorPriceCheck;
	}

Open in new window



with its getter and setters. There are bunch of other fields also with getters and setters.



There is also AbcVendorVO .java under vendor-org-businessservice package which has exactly same fields( without column names)  and again their getters and setters.

import java.io.Serializable;
import java.util.Date;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class AbcVendorVO implements Serializable, Cloneable {

private String vendorPriceCheck;

	public String getVendorPriceCheck() {
		return vendorPriceCheck;
	}

	public void setVendorPriceCheck(String vendorPriceCheck) {
		this.vendorPriceCheck = vendorPriceCheck;
	}

Open in new window


My question is are we using both Business object and Value object design patterns in my code. I wonder why we need same getters and setters in both places.

why the 'AbcVendor.java' is under vendor-org-bo package.(business object package which seems to me plain hibernate mapping file).

Why AbcVendorVO.java is under vendor-org-businessservice package ?

Is this kind of structure is same in any kind of organization?
is there is a good book or link which tells me clearly differces between these confusing terms like 'businesss objects', 'value objects', 'business services', 'bo', 'vo' etc jargon
please advise
Any links resources ideas highly appreciated. Thanks in advance
0
Comment
Question by:gudii9
  • 3
  • 2
5 Comments
 
LVL 12

Accepted Solution

by:
Sharon Seth earned 500 total points
Comment Utility
In many cases , a Value Object is same as the DTO(Data transfer object) . In your case , ABCVendor.java is the business object(BO) i.e, the actual business entity object . This is the class that represents your real world vendor . This is what gets persisted to the DB .
ABCVendorVO.java is like a DTO . It will be used across the application as a vendor , but finally is used to populate the BO . DTO merely is for transferring data from one layer to the persistent entity.
0
 
LVL 7

Author Comment

by:gudii9
Comment Utility
>>>ABCVendor.java is the business object(BO) i.e, the actual business entity object . This is the class that represents your real world vendor . This is what gets persisted to the DB .


It makes more sense. ABCVendor.java is the business object(BO) i.e, the actual business entity(i am assuming database entity tables) object

>>DTO merely is for transferring data from one layer to the persistent entity.

Do we need separate VO/DTO for transferring data across UI to persistence entity(which is BO right)??

We are using the JSF2.0 with primefaces for front end and have bunch of managed bean classes also. So managed beans pass the data to VO/DTO which in turn pass it on to BO class. where i can read more about these internal working which are not so obvious to me.

Please advise
0
 
LVL 12

Expert Comment

by:Sharon Seth
Comment Utility
That's what a DTO is for . Whether we need DTO or not depends on the context . You can just google for DTO for more info/reading , but it's only when you pick a couple of already implemented projects online  and start analysing them that you can actually relate to what you have read . SO , I suggest pick a good project on sourceforge and analyse it.
0
 
LVL 7

Author Comment

by:gudii9
Comment Utility
but it's only when you pick a couple of already implemented projects online  and start analyzing them that you can actually relate to what you have read . SO , I suggest pick a good project on sourceforge and analyze it.

can you please point me to good 'already implemented online projects'

I searched on Google with key word 'sourceforge implemented java j2ee projects'

i do not see much relevant links there.

Not sure how to search/use/look for old projects in sourceforge for 'already implemented online projects' as i never used it.
0
 
LVL 12

Expert Comment

by:Sharon Seth
Comment Utility
I meant , there are some java frameworks out there  which are considered to be 'good' and efficient as a result of good design . Pick up anything randomly . Go for hibernate if you like.
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Updating Java 9 87
topping3 challenge 14 48
HashMap Vs TreeMap 12 48
Strange loading of website behaviour 3 23
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now