我对模式的这些状态的差异感到困惑Flyweight
。
我知道intrinsic
状态是共享的状态,而Extrinsic
不是共享的状态。
但是,我看不到extrinsic
状态在模式或以下示例中的重要性:
public static void main(String[] args) {
// Create the flyweight factory...
EngineFlyweightFactory factory = new EngineFlyweightFactory();
// Create the diagnostic tool
DiagnosticTool tool = new EngineDiagnosticTool();
// Get the flyweights and run diagnostics on them
Engine standard1 = factory.getStandardEngine(1300); //intrinsic
standard1.diagnose(tool); //extrinsic
Engine standard2 = factory.getStandardEngine(1300); //intrinsic
standard2.diagnose(tool); //extrinsic
Engine standard3 = factory.getStandardEngine(1300); //intrinsic
standard3.diagnose(tool); //extrinsic
Engine standard4 = factory.getStandardEngine(1600); //intrinsic
standard4.diagnose(tool); //extrinsic
Engine standard5 = factory.getStandardEngine(1600); //intrinsic
standard5.diagnose(tool); //extrinsic
参考维基百科中关于文本编辑器的示例。内在状态是字母,外在状态是字体、颜色等吗?