任何人都可以解釋如何做享元模式工作的下面的代碼: public class FlyweightFactory {
Hashtable hash = new Hashtable();
public BallFlyweight getFlyweight(int r, Color col, Container c, AStrategy a) {
BallFlyweight
我遇到了一個採訪問題,要求設計一個文字處理器。 經過我的研究,我發現Flyweight設計模式是一種方法。我想出了下面的代碼(忽略語法)。但我很難考慮什麼是我的關鍵,以及我對文字處理器的價值。 public class格式 { public readonly string _fontname; public readonly string _weight; public readonly int
要應用flyweight模式,我們需要將Object屬性分爲內在屬性和外部屬性。固有屬性使對象唯一,而外部屬性由客戶端代碼設置並用於執行不同的操作。 但我的問題是爲什麼我們不能同時擁有內部屬性和外部屬性作爲實例變量(請參見下面的Email類),只需在循環外部創建一個對象並在循環中設置參數併發送多個具有不同參數的電子郵件。 public class Test {
public static