Class Design Question...
| From: | anachronism at mengelt dot com | Date: | Wed, 06 Aug 2003 16:33:54 +0000 |
| Subject: | Class Design Question... | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-158512@lists.php.net to get a copy of this message | ||
Hello,
I'm rewriting a lot of code and have decided to use classes... I'm wondering
if this would be considered bad design or not...
Basically in the class I have methods that perform a task, and return true
on success, or false on failure. Easy enough. If it returns false however, I
want to display errors for the user. The best way I can think of doing this
is adding a member variable to the class (an array). With each error
encountered it would push them on the array and at the end of the function
return false. Then in the code I would check if it returned false, and if so
dive into the error member variable array of the class and display them...
For example:
if($user->login($username, $password))
echo "You have successfully logged in.";
else{
foreach($user->loginError as $err){
echo $err . "<br>";
}
}
This sound like good design? Any suggestions?
Thanks...
-Dennis