每个开发者都应该知道的七个原则( 三 )


// 正确的方法:组合class CanFlyComposition {fly() {console.log('Flying in the sky!');}}class BirdCompose {constructor() {this.flyingCapability = new CanFlyComposition();}fly() {this.flyingCapability.fly();}}class AirplaneCompose {constructor() {this.flyingCapability = new CanFlyComposition();}fly() {this.flyingCapability.fly();}}
【每个开发者都应该知道的七个原则】


推荐阅读