【发布时间】:2009-08-13 18:15:09
【问题描述】:
我有几百行这样的代码:
if (c.SomeValue == null || c.SomeProperty.Status != 'Y')
{
btnRecordCall.Enabled = false;
}
if (c.SomeValue == null || (c.SomeProperty.Status != 'Y' &&
c.SomeOtherPropertyAction != 'Y'))
{
btnAddAction.Enabled = false;
}
if (c.SomeValue == null || c.SomeProperty.Processing != 'Y')
{
btnProcesss.Enabled = false;
}
如何正确重构它?我看到每次都调用检查'c.SomeValue == null',但它包含在其他条件中。我怎样才能消除这个重复的代码?
【问题讨论】:
标签: c# design-patterns refactoring