Page 2 of 2

Posted: Sat Apr 22, 2006 1:21 pm
by Christopher
Ree wrote:Unfortunately we don't have McGruff here.
:roll: :roll:

Posted: Sat Apr 22, 2006 1:25 pm
by Christopher
n00b Saibot wrote:
arborint wrote:You also might want to try composition rather than creating objects internally.
This needs elaboration...

Code: Select all

class User
{
 // Variables...

 var $_UserID;
 var $_Area;
 var $_DB;

 // Functions...

 function User($UserID = '', $Area = '', $db)
 {
  $this->_DB = $db;
  if (is_int($UserID))
   $this->setUserID($UserID);
  if($Area != '')
   $this->_Area = $Area;
 } 
...
}

$user = new User($userid, $area, new DB($dsn));
That way the User class only needs to know about how to use the DB class (the interface) and not how to instantiate it as well.

Posted: Sat Apr 22, 2006 1:28 pm
by Ree
Jcart wrote:
Ree wrote:Unfortunately we don't have McGruff here.
:roll:
Here's the first one...

Jcart, we all know the story and we all know it didn't improve McGruff's reputation, but you do have to give him credit for many helpfull posts in the OOP/unit testing department. Many did find his input very useful, myself included. And that's exactly what I had in mind when posting.

So you don't have to roll your eyes.

Posted: Sat Apr 22, 2006 1:37 pm
by John Cartwright
McGruff was a valued member of a community, but unrightfully did claim it as his own. I really respected him before that all happened, but I do not miss him for what he did. Either way, lets get back to the topic at hand. :)

Posted: Sat Apr 22, 2006 1:38 pm
by n00b Saibot
Ree wrote:
Jcart wrote:
Ree wrote:Unfortunately we don't have McGruff here.
:roll:
Here's the first one...

Jcart, we all know the story and we all know it didn't improve McGruff's reputation, but you do have to give him credit for many helpfull posts in the OOP/unit testing department. Many did find his input very useful, myself included. And that's exactly what I had in mind when posting.

So you don't have to roll your eyes.
That does have a bit there, only dullified by his own self. OK drop this off-topic rant right now!!!
Let's move on...

well, arborint thanks to you. I am going some pretty good direction. These were just thoughts in my mind which you materialized in the form of concrete examples. I have had speculated them some time back. Now I have to incorporate these changes in my `system` ;)

You talked about Repository-Factory type impl. can you show me an example on this road.

Posted: Sat Apr 22, 2006 3:56 pm
by n00b Saibot
Now after spending about 1-2 hours on phpPatterns.com site and reading Factory pattern, I find it to be most valuable suggestion to use Factory Pattern in my code. It suits me well and will help clear some mess in my library. thanks, arborint & timvw :)