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 wrong with the implementation. In my view, all the business can be performed manually; it is just a matter of how slow it is, how inefficient it is without relying on technology. Even big data analysis can be performed by just paper and pencil, it is just very slow, not scalable. With all that being said, business logic does not HAVE to depend on anything, not UI, not database, not service location, not data delivery mechanism, just nothing. It is complete, self-contained, and fully testable w/o the need for anything.

The data processing logic(the business logic), data fetching(not business logic) and data updating(not business logic) are different concerns. Once those things are mixed together, we would have to mock up DB calls/service calls, which is a clear indicator of NOT separating the concerns. The separation of concerns can be manifested at all different levels - system, service, component, class, and method.

Some list of different concerns:

functional vs non-functional

Stable logic and versatile logic, static vs dynamic

Data vs presentation

Data vs data structure

Event vs method

Who vs when

Behavior vs sequence of behaviors(flow or orchestration/collaboration)

Fetch data vs update data

Distributed vs localized.

Employing separation of concerns would lead to fewer interactions across boundaries and less complexity. SoC also gives us different dimensions of software - space dimension, time dimension, data dimension, etc. Eventually, it gives us a clear structure, leads to maintainable, and understandable software.

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

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…

  • Stability is the ultimate goal of a system.

    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…

  • 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…

  • Interface

    Interface

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

社区洞察

其他会员也浏览了