Tiven Wang
chevron_rightPattern chevron_rightReactive

Reactive Design Patterns - Simple Component Pattern

Igor Miske
Wang Tiven October 16, 2017
425 favorite favorites
bookmark bookmark
share share

The Single Responsibility Principle (SRP) is a computer programming principle that states that every module or class should have responsibility over a single part of the functionality provided by the software, and that responsibility should be entirely encapsulated by the class. All its services should be narrowly aligned with that responsibility. Robert C. Martin expresses the principle as, “A class should have only one reason to change.”[1]

分而治之 (Divide and Conquer)策略讲的是把大的问题分割成更小的问题,进而找到每个小问题的方位和责任。通过这种责任划分的过程你可以更轻松的解决看似很庞大的但具有层级结构的问题。这就涉及到划分到什么程度才是合适的,SRP给出的答案是每个task(e.g. modular, class)应该具有完整的不可分割的单独的责任,或者用 Robert C. Martin 的话说,”一个类应该只有一个改变的理由。”

Applying SRP in Reactive Application





Similar Posts


Back to Top