DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
The Latest "Software Integration: The Intersection of APIs, Microservices, and Cloud-Based Systems" Trend Report
Get the report
  1. DZone
  2. Coding
  3. Languages
  4. Transfer Obejcts vs Business Objects - Which Approach Works Best?

Transfer Obejcts vs Business Objects - Which Approach Works Best?

ALVARO VILAPLANA GARCIA user avatar by
ALVARO VILAPLANA GARCIA
·
Nov. 17, 09 · Interview
Like (0)
Save
Tweet
Share
24.86K Views

Join the DZone community and get the full member experience.

Join For Free
I would like to get the community's feedback on a common technical discussion about what is the best approach, Transfer objects or Business objects (JPA entities) across the tiers. I don't believe there's a golden rule. It depends on the use case, the complexity of the application in terms of architecture and frameworks used.

Transfer Object across the tiers

Pros
  • Reduces network traffic in distributed systems. Transfer objects are passed to the client in a single remote call.
  • Improves client performance by removing any need to assemble data models.
  • Decouples business logic from the client and keeps it in the business tier.
  • Improves transaction performance by isolating the components that can be updated.

Cons
  • Data in transfer objects might get obsolete. The transfer object has a copy of the data which is not automatically updated if the data changes on the server.
  • The system can be complicated when using concurrent access or transaction management processes.
  • Synchronization logic can complicate the system if updatable transfer objects are used.
    Object creation overhead on the server side increases.

Business Object across the tiers

Pros
  • Good approach in simple presentation tier design.
  • Makes easier the development in business and presentation tier because there is no need to assemble data models.

Cons
  • Couples presentation tier and business tier. (Note: If the business requirements don’t change often I consider that is good point to use them but otherwise it could be a nightmare for each single change to adapt the presentation tier.)
  • In the case that the user interface requires a complex set of properties, passing the domain model across the tiers can become heavyweight in terms of memory.
  • The development in the presentation tier can be complex because we need to navigate across multiple business objects to get the properties.
  • The development in business tier can become very tedious because we will load a lot of properties in the domain model (properties from BO1 -> properties from BO2 -> properties from BO3 and so on). There are two approaches to have all the properties in presentation tier:
  •                      In business tier: Eager relationships in JPA entities.
  •                      In business tier: “Fetch Join” in application services.

      Note: Some frameworks keep transaction opened during the render of the user interface.      


  When relationships in the JPA entities can be defined as LAZY, we don't have to worry about exceptions such as org.hibernate.LazyInitializationException when using Hibernate as JPA provider.

What are your thoughts? Has any one particular approach worked better for you?

Object (computer science) Transfer (computing)

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • DevOps for Developers: Continuous Integration, GitHub Actions, and Sonar Cloud
  • How To Choose the Right Streaming Database
  • REST vs. Messaging for Microservices
  • Solving the Kubernetes Security Puzzle

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: