Design pattern for customised versions of a Spring app

Discussion in 'Java' started by WombatDeath@gmail.com, Mar 15, 2007.

  1. Guest

    Hi,

    I have a Spring/JSP/Hibernate web app which needs to be implemented in
    a few different countries, each country having slightly different
    requirements. The language issue is easy to resolve but I'm wondering
    how best to implement the different properties, entity relationships
    and business rules which are adopted by each country.

    As an example, let's say that when a user enters a customer account
    into the app, the new account is assigned to an account manager. In
    the UK the assignation is based upon customer type, in the US its
    based upon the customer's postcode (zip code) and in Germany the
    account is assigned manually by the user.

    In addition, in the US we store the customer's email address while in
    Germany and the UK we don't. But in the UK we need to allow the user
    to enter as many phone numbers for the customer as they wish, while
    the US and Germany allow only one.

    It's been suggested to me that we could have one big app with
    conditional logic for each country ("if UK do this; if US do that; if
    Germany do something else"). A nicer idea, to my mind, is to have a
    "core" app from which the customised countries inherit as necessary.
    But I'm not really a Java programmer and am likely to be talking
    rubbish.

    It strikes me that this must be a solved problem, and any advice would
    be much appreciated.

    Thanks
    Wombat
     
    , Mar 15, 2007
    #1
    1. Advertising

  2. Eric Sosman Guest

    wrote On 03/15/07 11:31,:
    > Hi,
    >
    > I have a Spring/JSP/Hibernate web app which needs to be implemented in
    > a few different countries, each country having slightly different
    > requirements. The language issue is easy to resolve but I'm wondering
    > how best to implement the different properties, entity relationships
    > and business rules which are adopted by each country.
    >
    > As an example, let's say that when a user enters a customer account
    > into the app, the new account is assigned to an account manager. In
    > the UK the assignation is based upon customer type, in the US its
    > based upon the customer's postcode (zip code) and in Germany the
    > account is assigned manually by the user.
    >
    > In addition, in the US we store the customer's email address while in
    > Germany and the UK we don't. But in the UK we need to allow the user
    > to enter as many phone numbers for the customer as they wish, while
    > the US and Germany allow only one.
    >
    > It's been suggested to me that we could have one big app with
    > conditional logic for each country ("if UK do this; if US do that; if
    > Germany do something else"). A nicer idea, to my mind, is to have a
    > "core" app from which the customised countries inherit as necessary.
    > But I'm not really a Java programmer and am likely to be talking
    > rubbish.
    >
    > It strikes me that this must be a solved problem, and any advice would
    > be much appreciated.


    Another approach that might be useful is to have an
    abstract DataGatherer class that's extended by USdataGatherer
    and UKdataGatherer and DEdataGatherer. (A similar thing could
    be done with interfaces.) The "one big app" would concern
    itself with storing the data, making computations on it, and
    so on, but not with the country-specific rules.

    This is a lot like your "one big app with conditional
    logic," except that the logic is factored out into separate
    pluggable pieces and the conditionalization lies in the
    way Java dispatches to methods of polymorphic objects.

    --
     
    Eric Sosman, Mar 15, 2007
    #2
    1. Advertising

  3. Daniel Pitts Guest

    On Mar 15, 8:31 am, wrote:
    > Hi,
    >
    > I have a Spring/JSP/Hibernate web app which needs to be implemented in
    > a few different countries, each country having slightly different
    > requirements. The language issue is easy to resolve but I'm wondering
    > how best to implement the different properties, entity relationships
    > and business rules which are adopted by each country.
    >
    > As an example, let's say that when a user enters a customer account
    > into the app, the new account is assigned to an account manager. In
    > the UK the assignation is based upon customer type, in the US its
    > based upon the customer's postcode (zip code) and in Germany the
    > account is assigned manually by the user.
    >
    > In addition, in the US we store the customer's email address while in
    > Germany and the UK we don't. But in the UK we need to allow the user
    > to enter as many phone numbers for the customer as they wish, while
    > the US and Germany allow only one.
    >
    > It's been suggested to me that we could have one big app with
    > conditional logic for each country ("if UK do this; if US do that; if
    > Germany do something else"). A nicer idea, to my mind, is to have a
    > "core" app from which the customised countries inherit as necessary.
    > But I'm not really a Java programmer and am likely to be talking
    > rubbish.
    >
    > It strikes me that this must be a solved problem, and any advice would
    > be much appreciated.
    >
    > Thanks
    > Wombat


    Search for the Strategy pattern.
    You could basically have plug-in objects that override certain
    behavior depending on the country. It would then be a simple
    configuration change (or it could be automated) to look up the proper
    Strategy implementation which differs for that country.

    It similar to your concept of a "core" app with extended countries,
    except that the "core" app calls into the Strategy interface at
    specific times.

    Hmm, I just read Eric Sosman's reply to you, and he's basically saying
    the same thing, but the official name for that concept is the
    "Strategy pattern". Googling for it will give you some good
    resources, I'm sure.

    Hope this helps,
    Daniel.
     
    Daniel Pitts, Mar 15, 2007
    #3
  4. Guest

    Thank you both very much; that's given me lots to think about. I have
    some reading to do!

    Thanks again,
    Wombat
     
    , Mar 16, 2007
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. rmn190
    Replies:
    2
    Views:
    2,366
    Arne Vajhøj
    Jan 10, 2008
  2. Goldfish
    Replies:
    1
    Views:
    718
    Goldfish
    Nov 6, 2008
  3. Pallav singh
    Replies:
    0
    Views:
    363
    Pallav singh
    Jan 22, 2012
  4. Pallav singh
    Replies:
    0
    Views:
    404
    Pallav singh
    Jan 22, 2012
  5. Pallav singh
    Replies:
    1
    Views:
    452
    Peter Remmers
    Jan 22, 2012
Loading...

Share This Page