一、//example
public class Car {
Engine engine;
public Car(){}
public void start(Key key){
Doors doors = new Doors();
//4. parameter
boolean authorized = key.turns();
if(authorized){
//1.component of the object
engine.start();
//2.the object itself
updateDashboardDisplay();
//3. new object
doors.lock();
}
}
public void updateDashboardDisplay(){ }
}
二、Advantages&Disadvantages
Advantages:reduce the dependencies between objects
and reduce software maintenance
Disadvantages:result in more "wrapper" classes being written to handle method calls to other components.
This can result in increased complexity and development time as well as decreased runtime performance.