继承接口的区域准则

本文关键字:区域 接口 继承 | 更新日期: 2023-09-27 18:15:43

考虑这些接口:

interface IBar
{
    void bar();
}
interface IFoo : IBar
{
    void foo();
}

通常使用#region块对代码进行分组。在实现IFoo的具体类中,我可以想到两种有意义的区域配置。

我的问题是哪一个是首选约定?请激发你的答案。

:

class Foo : IFoo
{
    #region IFoo interface
    void foo() {}
    void bar() {}
    #endregion
}

B:

class Foo : IFoo
{
    #region IFoo interface
    void foo() {}
    #endregion
    #region IBar interface
    void bar() {}
    #endregion
}

继承接口的区域准则

如果区域划分不同的逻辑区域,则首选B(并且是我的个人偏好)。

让团队中的所有开发人员投票选出最易读的样式,然后坚持下去。