Jump to content

Association, aggregation & composition


MelodyMaker

Recommended Posts

HI!

I'm a bit confused about the associations between objects, so I would like to ask you about it, by using the following example:

 

 

class DatabaseManager{     
     
    private function __construct(){} 
    private function __clone(){} 
     
    static public function getInstance(){ 
        switch (Configuration::getInstance()->DBMS){ 
            case "mysql": 
                return MySqlDB::DBgetInstance(); 
                break; 
            default: 
                return MySqlDB::DBgetInstance(); 
        } 
    } 
} 

Class Configuration{ 
    private $DBconn     = "localhost|myUser|myPwd|myDB"; 
    private $sessionExpiration = 3600; 
    private $DBMS = "mysql"; 
    private static $confInstance; 
         
    private function __construct(){} 
     
    public static function getInstance(){ 
           if (!self::$confInstance){ 
            self::$confInstance = new Configuration(); 
        } 
        return self::$confInstance; 
    }   
             
    public function __GET($property){         
        if(isset($this->$property)){ 
            return $this->$property; 
        } 
        return false; 
    } 
     
    private function __clone(){} 
} 

Class MysqlDB{ 
private $conf; 
public function __construct(){ 
  $this->conf = Configuration::getInstance(); 
  ... 
} 

...bla bla 
} 


I just would like to know what kind of association ther is between 

I just would like to know what kind of association ther is between the configuration and the other two classes. I've just started to draw UML diagrams, and I'm getting mad about it...

 

Thanks in advance!

 

Davide

Link to comment
https://forums.phpfreaks.com/topic/101389-association-aggregation-composition/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.