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

  • SEARCH
  • Home
  • 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 3438244
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T08:09:50+00:00 2026-05-18T08:09:50+00:00

My application receives XML messages to update it’s data objects. The XML message contains

  • 0

My application receives XML messages to update it’s data objects. The XML message contains details on how the data is to be modified. The XML looks something like:

<data>
   <stuff> .... </stuff>
   <stuff> .... </stuff>
   <objs>
      <obj attr1=... attr2=... />
      <obj attr1=... attr2=... />
   </objs>
</data>

How should I update the fields of the objects?

  1. Create a modify(String xml) method. Parse the message, extract <stuff> data, then reconstruct the following <obj attr1=... /> as a String and pass into modify().

  2. Create a modify(NamedNodeMap xml) method. Parse the message, extract <stuff> data, keep the results of the parsing (Document object), find the relevant Node and pass into modify().

  3. Create a modify(String attr1, String attr2, …) method. Parse the XML, extract the fields, pass into modify(). Probably a very bad idea, because if I need more attributes, I need the change the method signature, and breaks everything that depend on the modify() method.

  4. Create setters for every field. Parse the XML, then set the fields individually. Then we run into the whole getter and setter debate, and in the context of this application, the fields of my data objects should only be modified by these XML messages, not anywhere else.

Personally I’m torn between 1 and 2. I think 1 would be more flexible, in case we decided not to use DOM, I can change how the String is parsed inside the modify(String xml) method. But then I would have to parse the XML twice, once to obtain the <stuff> data, then reconstructing the XML as String, and being parsed again inside the modify() method.

Should XML parsing even be done inside my data classes? Is there any reason to choose the other choices? Thanks.

[Edit]
In general, how much should I “unpack” data before passing into a method?

  • 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. Editorial Team
    Editorial Team
    2026-05-18T08:09:50+00:00Added an answer on May 18, 2026 at 8:09 am

    I’d suggest option 4, mostly because you probably don’t want your data objects to be so closely tied to the message transport mechanism.

    With options 1 and 2 if you decide to change your XML schema (or if you decide that XML is too verbose, or if you want to include encryption etc etc) then you probably now have to change your data object implementation – the same reason that option 3 is bad.

    Are you absolutely certain that your current set of XML messages will be the only reason that data will change, ever? I mean really absolutely 100% certain that no-one will ever not want to use XML? If not, then go with 4. Decoupling implementation (data object) from interface (XML messages) is the best way to ensure your code is maintainable.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My application receives strings that represent objects. I have to parse the strings to
I have an application containing 4 MDB's each of which receives SOAP messages over
My application needs to send/receive xml data via a tcp socket. There is no
I need to perform some action when my application receives focus. I've tried hooking
I have a server application that receives information over a network and processes it.
Currently I have an application that receives an uploaded file from my web application.
I have a networking Linux application which receives RTP streams from multiple destinations, does
Right now I'm working on a web application that receives a significant amount of
I'm writting a financial C# application which receive messages from the network, translate them
I am going to develop real time application which will receive stock market data

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.