jimfog Posted November 12, 2012 Share Posted November 12, 2012 Suppose you have 2 types of users for your app, business and regulars, and these, fill in a different type of registration form, with different fields each. The question is, do you write one function for the registration, for both type of users, or 2 functions, each called depending on the user type. From your experience what you would do. I think of writing one, but complexity worries me. Link to comment Share on other sites More sharing options...
thescientist Posted November 12, 2012 Share Posted November 12, 2012 depends on the registration requirements of each, but probably better to write two. as you are already anticipating, the cyclomatic complexity could get troublesome if their differences are significant enough. Perhaps there are some reusable elements you could share between the two of them (like validation or something like that) but even from a testing standpoint, the simpler the function, typically the better. Link to comment Share on other sites More sharing options...
murfitUK Posted November 12, 2012 Share Posted November 12, 2012 Will your users know if they are regular or business users before they fill the form in? What if they fill in a business form and then find out they should have filled in the regular form (or the other way round)? To make it easier for your users - and for you - why not have just one form. Some fields will always have to be filled in (name, email etc) and some will be optional and these can all be on the same form. One of the things I have learned since taking up programming and web design is that the best way of starting a project is to get a pen and paper and write down EXACTLY what it is you want to achieve and then the steps you can take to reach it. So the first question you should ask (based on your post) if... why do I need two different forms? If you have no good answer than stick to one. Link to comment Share on other sites More sharing options...
Paul67 Posted November 13, 2012 Share Posted November 13, 2012 I would say it depends on the size of, and amount of commonality between, the two datasets. If you have two registration forms, each containing dummy values in hidden fields for the data not applicable to each registration, although it may be a little less efficient in terms of data storage, you should end up with just one relatively simple (if big) function that handles both registration types. If you want to post an overview of the datasets involved, I'll try to offer a more definative opinion. Link to comment Share on other sites More sharing options...
jimfog Posted November 13, 2012 Author Share Posted November 13, 2012 (edited) The differences between the two forms are not big.In the business form, the user just fills also the type of business(carshop, hairdresser...etc). Of course all the other fields are common-name, username, password...etc.I think is is better to have one registration form and 1 function to handle it. An when the user who is going to register is a business I will just use javascript to reveal(the otherwise hidden) the corresponding fields. That is the plan I have come. Edited November 13, 2012 by jimfog Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now