what does composition example vs aggregation

Posted by meWantToLearn on Programmers See other posts from Programmers or by meWantToLearn
Published on 2012-10-24T12:53:25Z Indexed on 2012/11/17 5:17 UTC
Read the original article Hit count: 290

Filed under:
|
|

Composition and aggregation both are confusion to me. Does my code sample below indicate composition or aggregation?

class A {
     public static function getData($id) {
         //something
     }

     public static function checkUrl($url) {
         // something
     }

 class B {
    public function executePatch() {
           $data = A::getData(12); 
     }

    public function readUrl() {
           $url = A::checkUrl('http/erere.com');
     }

    public function storeData() {
            //something not related to class A at all
     }
  }
}

Is class B a composition of class A or is it aggregation of class A? Does composition purely mean that if class A gets deleted class B does not works at all and aggregation if class A gets deleted methods in class B that do not use class A will work?

© Programmers or respective owner

Related posts about php

Related posts about composition