我正在對某些代碼進行重構。 我們有一個投資者名單,分配給每個投資者。總金額應該等於另一個總額,但有時會有幾美分的差異,所以我們使用不同的算法將這些差異分配給每個投資者。 當前的代碼是這樣的: public void Round(IList<Investors> investors, Enum algorithm, [here goes a list of many parameters]) {
我試圖使用泛型實現Strategy + Factory模式。我們的目標是返回一個客戶端類的接口DocumentDao的實現,它可以處理類型T extends Document,所以我有多個Dao接口爲DocumentDao的不同子類型擴展DocumentDao。 這裏是我的代碼: public class Document { ... }
public class DocumentA exte
使用策略模式,如何以不同的參數對待不同的execute方法? 3例策略 public function execute(string $param1, string $param2)
{
// Do something specific to this method
//
// Do some generic things across all strategi