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 857185
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T08:21:37+00:00 2026-05-15T08:21:37+00:00

How would you design an application (classes, interfaces in class library) in .NET when

  • 0

How would you design an application (classes, interfaces in class library) in .NET when we have a fixed database design on our side and we need to support imports of data from third party data sources, which will most likely be in XML?

For instance, let us say we have a Products table in our DB which has columns
Id
Title
Description
TaxLevel
Price

and on the other side we have for instance Products:
ProductId
ProdTitle
Text
BasicPrice
Quantity.

Currently I do it like this:
Have the third party XML convert to classes and XSD’s and then deserialize its contents into strong typed objects (what we get as a result of this process is classes like ThirdPartyProduct, ThirdPartyClassification, etc.).

Then I have methods like this:

InsertProduct(ThirdPartyProduct newproduct)

I do not use interfaces at the moment but I would like to. What I would like is implement something like

public class Contoso_ProductSynchronization : ProductSynchronization
{
    public void InsertProduct(ContosoProduct p)
    {
        Product product = new Product(); // this is our Entity class
        // do the assignments from p to product here

        using(SyncEntities db = new SyncEntities())
        {
            // ....
            db.AddToProducts(product);
        }
    }

    // the problem is Product and ContosoProduct have no arhitectural connection right now
    // so I cannot do this
    public void InsertProduct(ContosoProduct p)
    {
        Product product = (Product)p;

        using(SyncEntities db = new SyncEntities())
        {
            // ....
            db.AddToProducts(product);
        }
    }
}

where ProductSynchronization will be an interface or abstract class. There will most likely be many implementations of ProductSynchronization. I cannot hardcode the types – classes like ContosoProduct, NorthwindProduct might be created from the third party XML’s (so preferably I would continue to use deserialization).

Hopefully someone will understand what I’m trying to explain here. Just imagine you are the seller and you have numerous providers and each one uses their own proprietary XML format. I don’t mind the development, which will of course be needed everytime new format appears, because it will only require 10-20 methods to be implemented, I just want the architecture to be open and support that.

In your replies, please focus on design and not so much on data access technologies because most are pretty straightforward to use (if you need to know, EF will be used for interacting with our database).

  • 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-15T08:21:37+00:00Added an answer on May 15, 2026 at 8:21 am

    [EDIT: Design note]

    Ok, from a design perspective I would do xslt on the incoming xml to transform it to a unified format. Also very easy to verify the result xml towards a schema.

    Using xslt I would stay away from any interface or abstract class, and just have one class implementation in my code, the internal class. It would keep the code base clean, and the xslt’s themselves should be pretty short if the data is as simple as you state.

    Documenting the transformations can easily be done wherever you have your project documentation.

    If you decide you absolutely want to have one class per xml (or if you perhaps got a .net dll instead of xml from one customer), then I would make the proxy class inherit an interface or abstract class (based off your internal class, and implement the mappings per property as needed in the proxy classes. This way you can cast any class to your base/internal class.

    But seems to me doing the conversion/mapping in code will make the code design a bit more messy.

    [Original Answer]

    If I understand you correctly you want to map a ThirdPartyProduct class over to your own internal class.

    Initially I am thinking class mapping. Use something like Automapper and configure up the mappings as you create your xml deserializing proxy’s. If you make your deserialization end up with the same property names as your internal class, then there’s less config to do for the mapper. Convention over Configuration.

    I’d like to hear anyones thoughts on going this route.

    Another approach would be to add a .ToInternalProduct( ThirdPartyClass ) in a Converter class. And keep adding more as you add more external classes.

    The third approach is for XSLT guys. If you love XSLT you could transform the xml into something which can be deserialized into your internal product class.

    Which one of these three I’d choose would depend on the skills of the programmer, and who will maintain adding new external classes. The XSLT approach would require no recompiling or compiling of code as new formats arrived. That might be an advantage.

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

Sidebar

Ask A Question

Stats

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

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

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

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

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer try utf8_decode()ing the $amount (or the entire page you received)… May 15, 2026 at 5:48 pm
  • Editorial Team
    Editorial Team added an answer That is because the so called "iPhone Emulator" is a… May 15, 2026 at 5:48 pm
  • Editorial Team
    Editorial Team added an answer You can do any of these things, in order of… May 15, 2026 at 5:48 pm

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.