Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 125983
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T05:14:44+00:00 2026-05-11T05:14:44+00:00

I have a C# client and a java server. I have data object that

  • 0

I have a C# client and a java server. I have data object that go on the wire back and forth. Lets call them FooData.cs where everything is just a get and a set (no logic)

FooData data = new FooData(); data.Price = 10; data.Quantity = 20; 

i have other derived fields that i want to use in the application but dont need to be sent on the wire so i have anothe class

FooWrapper.cs.

I inject the data object into the wrapper

FooWrapper wrapper = new FooWrapper(Foodata); wrapper.Price = 10; wrapper.Quantity = 20; double total  = wrapper.GetTotal(); 

and the wrapper has a lot of the same properties as the data object (and we just delegate down) or the wrapper also has a number of calculated properties. The only state the wrapper has is the data object (no other member variables)

We were having a debate about using this model versus using converters. The converter way would be to instead of having FooWrapper, have a FooBusinessObject and instead of injecting the ‘on the wire’ object, we call a convert method that passes all of the data from the on the wire object to the business object.

FooData data = new FooData(); FooBusinessObject busObj = new FooBusinessObject(); busObj.Price = data.Price; busObj.Quant= data.Quantity; double total  = busObj.GetTotal(); 

Any thoughts on what is better (wrapper versus business object / converter)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T05:14:44+00:00Added an answer on May 11, 2026 at 5:14 am

    (edit) What version of C# are you using? With C# 3.0 you could place the ‘logic’ bits (calculations etc) in extension methods in a busines logic assembly, but still see them via the DTO – i.e.

    (data layer)

    public class Foo {     public int Bar {get;set;} } 

    (business layer)

    static class FooExt {     public static int Blop(this Foo foo) {return 2 * foo.bar;} } 

    (ui layer)

    Foo foo = ... int blop = foo.Blop(); 

    What model are you using to transfer the data? web services? xml? data-contracts? binary? Most would allow you to ignore the extra properties without any extra code (i.e. no need for a wrapper/facade object):

    XmlSerializer:

    [Serializable] public class MyData {     public int Foo {get;set;} // is sent     [XmlIgnore]     public int Bar {get {...} set {...}} // is ignored } 

    DataContractSerializer:

    [DataContract] class MyData {     [DataMember]     public int Foo {get;set;} // is sent     public int Bar {get {...} set {...}} // is ignored } 

    If you are talking binary, there are portable java/C#-friendly models such as ‘protocol buffers‘ – Jon Skeet has a C# port of the official java version (allowing you to use very similar code on both sides) – or I have a more C#-idiomatic version (protobuf-net):

    ProtoSerializer:

    [ProtoContract] class MyData {     [ProtoMember(1)]     public int Foo {get;set;} // is sent     public int Bar {get {...} set {...}} // is ignored } 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 153k
  • Answers 153k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Please check this thread: File uploading in AJAX updatepanel without… May 12, 2026 at 10:15 am
  • Editorial Team
    Editorial Team added an answer This might be of interest: Electronic Banking Guidance (but check… May 12, 2026 at 10:15 am
  • Editorial Team
    Editorial Team added an answer This is certainly an interesting area of, should I say,… May 12, 2026 at 10:15 am

Related Questions

I have been doing socket programming for many years, but I have never had
I am writting a .Net/C# client to a Java Server on Solaris. The Java
I recently wrote a quick-and-dirty proof-of-concept proxy server in C# as part of an
I have a web-service written in Java, hosted on an Axis2 / Tomcat /

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.