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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T01:21:27+00:00 2026-05-30T01:21:27+00:00

at work we have an application that, at first, had been developed for a

  • 0

at work we have an application that, at first, had been developed for a specific country. Now a new client is interested in the application but this client is from another country. We have to change some objects to respresent the new country.

  • Country 1, properties A,B,C,D,E so java and Database contains A,B,C,D,E

  • New Country 2, properties A,D,F,G,H

Solutions we came up with.

Database :

  • Create a new table for the new country

  • Simply add F,G,H to the current table

Java :

  • Make the current address abstract with A,D then create a country specific implementation (Interesting and clear but adds the pain to work with an interface thus you have to type casts all the time)

  • Simply add F,G,H to the address (Seams an unclean solution knowing that the day a new country is to be added may end up with adding I,J,K to the object)

  • Modify the current object to have common properties and some generic fields like info1, info2. (Seams a good solution but makes the code unclear by working with info1, info2… in business logic)

Anyone know a good pattern for this kind of problem?

Regards

  • 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-30T01:21:28+00:00Added an answer on May 30, 2026 at 1:21 am

    OK, after the clarifying comments my understanding is:

    • You already have a Address class and related database table
    • Each country will require a different set of address lines for each Address
    • The behaviour of the code for each country is not particularly different (i.e. addresses behave in a similar way, apart from the fact that they have different address lines)

    In general, I would avoid creating new classes when the differences are really just pure data. So having two different Address classes seems like a bad idea, regardless of whether or not you make them inherit from a single base class. Also, inheritance hierarchies don’t usually map to databases very well.

    I think the best solution is to store the properties for each country in a HashMap or something similar, which then determines which address lines apply for each country. For simplicity, each Address might contain a HashMap<String,String>, i.e. with Strings for both the keys (address line names) and values (address data).

    If you do this, then you have a high degree of flexibility over what properties you set for each country, and if you add a third country at some point you might not need any code changes – just a new set of address lines.

    In the database I’d represent the data in two tables: Address and AddressLine, with the obvious 1-to-many relationship.

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

Sidebar

Related Questions

Say I have a third party Application that does background work, but prints out
I have an application that needs to work with a vendor-supplied API to do
I have an application that is going to work like a p2p-software where all
I have a web application that I'm working on for work and its not
I have a reference application that I use to work through DDD issues, and
I have a WCF service and a Silverlight application that work just fine when
I have read in Patterns of Enterprise Application Architecture that a Unit Of Work
I have an application which really should be installed, but does work fine when
I have a desktop application that on first execution prompts for the connection details
I have a web application at work that is similar to a ticket working

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.