05-09-2009, 06:38 PM
|
#6 (permalink)
|
|
The Gregarious
Join Date: Feb 2009
Location: New York
Posts: 645
Thanks: 64
|
Quote:
Originally Posted by Enfernikus
Do not make them Children of the validation class pass the validation object to them or have the Loader class class it inside. Example.
PHP Code:
<?php
class Member
{
private $validation;
public function __construct()
{
$this->validation = Loader::LoadClass('validation');
}
}
OR
PHP Code:
<?php
class Member
{
private $validation;
public function __construct(Validation $val)
{
$this->validation = $val;
}
}
$validation = new Validation;
$member = new Member($validation);
Also, the logout function in the session class should be in your member handling object. Alternatively you can rename it to session_destroy_all, it seems nitpicky but it's in the effort of keeping your objects well structured.
|
Thank you! Nitpick away, I am always looking for better approaches. I don't see that as a nitpick at all, if it's cleaner..
I like your first option, it seems better....quick question about this part:
$this->validation = Loader::LoadClass('validation');
I take it that we can now use "$this->validation" all throughout the class right? So if I had a validation class method called: html_clean().
Then within the member class, I can do this?
$this->validation->html_clean($some_var);
Is that correct?
I will also take your suggestion and modify the logout() function for the member class and not the session class...
|
|
|
|