Link to home
Start Free TrialLog in
Avatar of gudii9
gudii9Flag for United States of America

asked on

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

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
ASKER CERTIFIED SOLUTION
Avatar of Sharon Seth
Sharon Seth
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of gudii9

ASKER

>>>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
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.
Avatar of gudii9

ASKER

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.
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.