Stability is the ultimate goal of a system.

The stability of the system is eventually about the bottom line of business. Stability does not mean the system will not change; quite the opposite, the system would be easier to change/evolve because the system has a stable structure/architecture skeleton, which would lead to the benefits of these: the codebase would be smaller, the development cost would be lower, the quality of software would be higher(less code, less changes==less bugs), and the time to market would be faster.

The mechanism to achieve stability is through conscious system design, particularly system partitioning and abstraction.

But exactly how? extract and capture the static structure, the broadly defined intrinsic behavior of domain, which is totally independent of the context, and encapsulate the context using data. Or put it another way, identify and separate what is stable from what is volatile(context). The stable behavior portion would be represented by interfaces; interface should be very generic, about fundamental concepts of domain, the semantics. The abstraction level of interface is very high, so it would NOT require the interface to be changed even when business requirements change since the required change would be simply represented by a different context data. 

Some indicators of the stability problem of the system. The number of methods in interface/type, and the number of interfaces in a system. Interface is an external view of the system. The more exposure you have, the less stable it would become because the system would expose volatile pieces(very specific description of system) which are subject to change. Once these 2 things are mixed, we have to change either the structure or behavior when a requirement changes. Interface is a firewall and boundary, we should not be able to see through it to know what is the detail behind it. It should be strong and withstand the test of time. Some research work was done by author Juval Lowy in his book published in 2005. Some of the content might be obsolete, but principles are still very much valid.

No alt text provided for this image

Some research work on .NET Framework 2.0.

No alt text provided for this image
No alt text provided for this image

If a developer were asked to create a single method vs as many methods as they would like in a type, the result would be drastically different, since the abstraction level would be quite different.

We achieve stability by encapsulating the volatile piece in the data. For example, int is a stable type(data structure), the context of 3 meals a day, 24/7 are represented by instantiating int type with value of 3, 24, 7 at run-time. But in our real practice, we might have the equivalent of meal int type, hour int type, and day-in-week int type. So when it is time to represent days of the year, we have to introduce day-in-year int type since we do not have a type that can capture all of the numbers in a fashion that is context-independent.

If we were asked to design an interface that can capture everything in the universe, in my view, it would look like this:

interface IHappened
{

    string Happened()
}

What is your view on this topic? any comment is welcome.

Talk to you next time. 10/26/2019

More about interface, please take a look at this article and this article.

要查看或添加评论,请登录

Jay Li的更多文章

  • Some good indicators that a system is structurally stable, aka maintainable.

    Some good indicators that a system is structurally stable, aka maintainable.

    It is easy to add new functionalities. Thinking of any MVC framework - we can add an unlimited number of controllers…

  • Is this a leaky interface?

    Is this a leaky interface?

    Interface IUserRepository { list getActiveUsers(); void deactivateUser(userId) } A repository is a…

  • A reflection on software engineering

    A reflection on software engineering

    In my view, a software engineer has to be a designer first, at least for architects or senior people; this stuff is…

  • Testability and self-containment of business logic.

    Testability and self-containment of business logic.

    If we find that it is difficult to test our business logic, the unit tests have to have some mock-up code, something is…

  • Interface

    Interface

    Just share some thoughts about interface/dependency injection and the way it has been used by some projects. The…

社区洞察

其他会员也浏览了