DiscoBiscuit Posted February 12, 2009 Share Posted February 12, 2009 Hi, I have a User class which has lots of small methods to validate a users details, such as check_username_length, check_passwords_match etc. Is it better to call each of the methods separately or to just combine them into one large method and call that instead? Secondly, I recently read a tutorial which suggested using heredoc syntax to add the entire contents of the page to a single variable and then echoing this at the end of the code, is this really a good idea, or would it be better to simply use lots of include files? I realise it may just be up to personal preference, but I'm interested in other people's opinions. Thanks. Quote Link to comment Share on other sites More sharing options...
d_barszczak Posted February 12, 2009 Share Posted February 12, 2009 Hi, I would usually do both. Have the smaller methods such as usr_check() that actually do the tasks and the a lager method such as usr_create() which uses the smaller methods to complete the whole task. That way your script can create a user in this example but should you need to create another script that needs to check a user you don't need to rewrite the usr_check() code. Plus if you ever wanted to create users in a different way you can always copy the usr_create() rename the function and make the changes. The core of the code would more than likely be the same and therefore would still be able to function using the smaller methods. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.