alexweber15 Posted September 27, 2008 Share Posted September 27, 2008 one of those situations where I can't decide between 2 similar ways of doing something so just wondering about efficiency and best-practices... thanks! class LoginHelper{ private $email; private $pass; function __construct($email, $pass){ $this->email = $email; $this->pass = $pass; $this->validate() ? $this->authenticate() : $this->showErr(); } private function validate(){ if(!eregi("pattern here",$this->email){ return false; // for the sake of simplicity } return true; } private function authenticate(){ $result = new LoginController($this->email, $this->pass); } } this is the way it is right now because i'm considering renaming the functions to something a bit more generic and make them all implement a 'Helper' and 'Controller' interface ('login' is obviously just a small part of the entire thing) another way of doing this would be not storing the values in the class and instead just pass them on to every function ie: private function validate($email, $pass) is there any particular reason why I should use one or the other approach? (apart from having less specific function parameters so that I can generalize and make it so that every Helper class has to have a validate() method for example and do some design by contract stuff for the other classes) thanks! 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.