Suggestions for an effective approach to use for designing a form RRS feed

  • Question

  • Hi,

    I need to develop a form which has to be used by various markets around the globe. The form has a couple of text boxes for input and just a button for submitting it.

    The tricky part is, based on each market, some of the text boxes are different, also, the layout of these text boxes changes based on the market for ex US might have a first name, last name text box while Taiwan could just have a single textbox called name. Another interesting thing is the rules that are attached to the input boxes, say if there is a textbox for phone, it might accept numbers in a different way for different countries, in short, there are rules associated for each country.

    As i mentioned above, the layout becomes most critical in the address section as different countries have different ways how people enter addresses, basically the form elemensta re the same but their positioning changes.

    I wanted to check what could be some good ways for approaching this problem?
    Thursday, November 19, 2009 9:25 PM

All replies

  • hi there,
    i think you might be able to benefit from the model-view-controller (mvc) or even model-view (mv) for that matter for what you describe is very similar to say wanting to display a web page but being visible on various devices (computers, pdas, phones etc).   or even a 3 tier system that allows clients to use rich-clients (win32) or thin (web).

    the component that is responsible for displaying a view in the first place needs to know something about where the actor is and what type of environment they are in. then it is a simple matter of displaying the most appropriate view to suit the actor.

    there are many ways to do this. you could have one form with dynamically adjusting user controls, or create specific forms to suit each locale. 

    considering that you have only a few controls, you could probably generate the form at runtime with appropriate layout and client-side logic

    Micky D
    Friday, November 20, 2009 9:13 AM
  • Model View Presenter (MVP)  can be a good option as here.

    MVP is a variant of MVC . with MVP  the View talks to the Presenter and the Presenter talks to the Model

    basically what you want to do is to have different views (layout for  different markets)  and a common Presenter (logic for saving your data to the model)

    a brief code will be

    public interface IMyPageView
        bool IsPhoneNumberValid();
        bool IsNameValid();
    when you implement the view  you can delegate the validation related to the market to that view and let the presenter to only handel business rules (like what to before saving)

    so when you want to cater for a new  market you can just implement the view .

    Friday, November 27, 2009 1:26 AM
  • Gaurav,

    There are multiple things that you need to do here to achieve what you want, and also I'd say you might need to consider left to right reading direction as well as right to left (just to complicate things further!)

    As the other guys have already commented - you need to split the application logic form the presentation logic using the pattern of your choice (MVC, MVP, MVVM, etc)  You need to identify the aspects of the system that will change dependent upon the location that the application is running.  Something else you might like to think about is whether you want to 'automagically' work out all these aspects as the application starts up, or whether such a process, which will have a performance hit is really necessary.  This will lead to whether you then want to create new presentation logic in seperate assemblies to be used with the controller (and there is nothing for the application to work out location wise) or whether you want the layout of a single form to be dynamically created at runtime.

    The first option, to me, would be the simplest, and I'd choose that personally - you could then have an object that is executed and starts your application, an interface factory if you like, that using a strategy and factory pattern will return the correct interface at runtime based on the locality.  The correct interface can then be injected into the controller, which will contain your logic, and, bob's your uncle!  I'm assuming that this is a web application, because if it were a windows forms based implementation, then you would make this decision once, at installation time, instead.

    Dont think that this will be a difficult thing for you to do at all, but if you're still struggling, please ask more questions,

    MCSD, MCTS, MCPD. Please mark my post as helpful if you find the information good! http://www.consultantvault.com
    Friday, November 27, 2009 2:20 AM