patterns

Object Oriented Programming: Data Mapping

Auteur: 
Jason Lotito

The What

Just because you use objects doesn’t mean you are programming in an object oriented manner.  A function like this defeats the purpose:

public function init()
{
$user = new User();
return $user;
}

It immediate creates a dependency.  Whatever object init() is in, we know it relies on User.  It also prevents us from testing init() without User.  User needs to be in place, and it needs to work.  If init() fails, we don’t know if it’s init() or User.

Syndiquer le contenu