2
是正常的,在我下面的代碼使用默認的策略,如:默認策略。策略模式C#
public abstract class ClContext
{
protected sealed class InitialAlgorithm : IClAlgorithm
{
public void Initialize()
{
return;
}
public void Execute()
{
return;
}
public Byte[] Result
{
get { return new Byte[1]{0}; }
}
}
protected IClAlgorithm algorithm;
protected ClContext(IClAlgorithm algorithm = null)
{
this.algorithm = algorithm ?? new ClContext.InitialAlgorithm();
}
public void Execute()
{
this.algorithm.Execute();
}
}
,並且它也很正常提供自動實現的屬性,如:
public IClAlgorithm Algorithm
{
get;
set;
}
我只是好奇從設計的角度來看它是可以接受的。
謝謝!
我使用'Initialize()'只是爲了說明,但謝謝! – lexeme