design_model(7)bridge

1.Bridging mode

Based on the minimal design principle of classes, different classes take on different responsibilities by using encapsulation, aggregation, and inheritance behaviors. Its main feature is to separate the abstraction from the implementation so that the parts remain independent.Sex and coping with their functional expansion.

2.Example

public interface Brand {

}

public class Huasuo implements  Brand{
	
}

public interface  Computer {

}

public class Desktop  implements Computer{
   private Brand  brand;

  public Desktop(Brand brand) {
	super();
	this.brand = brand;
  }
  
}

public class Client {
   public static void main(String[] args) {
	 Desktop desktop = new Desktop(new Huasuo());
  }
}

 

Leave a Reply

Your email address will not be published. Required fields are marked *