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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T00:58:52+00:00 2026-05-17T00:58:52+00:00

I have a dilemna that needs I’ve been thinking a while but still haven’t

  • 0

I have a dilemna that needs I’ve been thinking a while but still haven’t figured it out how to effectively and efficiently code (design) it.

I have object data that get returns in 3 text-based formats: JSON, XML, ATOM. In JSON, the data can be a JSON Object or JSON array. XML and ATOM are xml.

Based on these 3 formats, I have to create objects (let’s say A, B, C, D, E). I thought of having a Builder Pattern to generate these objects, so my interface builder is:

public interface Builder<T, E, A> { //Where E = Element, A is Element array, this is useful for JSON
   public T create(E element);
   public T[] create(A array);
}

public class ABuilder implements Builder<A, JSON, JSONArray> {
  public A create(JSON json) {...}
  public A[] create(JSONArray array) {...}
}

The problem is that I want to create a dynamic Factory/Alternative design pattern that can create an object based on the format….

i.e. I want a functionality such that, I can do

public class Resource {

   public A getA(String formatString) {
      return new Something().createA(formatString); //or something better....
   }
}

Do you have any better way of making this issue possible? Bear in mind, all this is based on the 3 possible formats. The goal is to generate objects dynamically based on the format, without really worrying about the format structure.

  • 1 1 Answer
  • 2 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-17T00:58:53+00:00Added an answer on May 17, 2026 at 12:58 am

    I’m not 100% sure I understand what you need, but the first design pattern that came to my mind was Strategy

    with this simple and elegant pattern, you can implement a concrete strategy for each implementation you have (xml, json, atom) and you also have a flexible solution that can be easily extended in the future to support new formats without breaking any existing code (that is the Open-Close principle).

    so, you would have a Factory method that would provide a “Build”/”Get” method which input would be an enum representing the required format (just an example, you can implement any way you want), and that factory method would use a strategy to actually build the object. that way, the client is 100% unaware of how the object is built, and doesn’t even have to know what format it is.

    good luck!

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

Sidebar

Related Questions

I have a Windows Phone application I am developing that needs to persist some
I have a little dilemma that maybe you can help me sort out. I've
I have a dilemma that I've encountered before. What's the best in terms of
I have got a designing dilema. I have a class named UserAccount that represent
I ran into an interesting dilemma today. I have a function that handles information
I have just started learning MVVM and having a dilemna. If I have a
I have a dilemma on my hands. After much trial and error, I still
I'm having a dilemma. I have a field hashedX that is a hashed/salted value
I have an application that's suppose to be realized in plugin pattern. Plugins are
We have to have a register method available via web service that is written

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.