software design: One way is to make it so simple that there are obviously no deficiencies and the other way is to make it so complicated that there are no obvious deficiencies. “ Tony Hoare, 1980 Turing Award Speech
outside – treating the system as a “black box”. We make conclusions about a system based on how it behaves in response to specific inputs. INFORMAL REASONING Informal reasoning gains an understanding of the system from the inside, by directly examining its code and data. Since more information is available, hopefully a more accurate understanding can be achieved.
kind) on a system or component that is in one particular state tells you nothing at all about the behavior of that system or component when it happens to be in another state. INFORMAL REASONING Large amounts of state make a system hard to reason about, because a developer must mentally model the behavior of the system in all possible states, as well as the code paths than can potentially lead to each state. Each additional bit of state doubles total number of possible states.
OOP rely on state and in general all behavior is affected by this state. As a result of this. OOP suffers directly from the problems associated with state.”
state and no side effects – or impure, which while recommending that developers avoid state, still allow their use. REFERENTIAL TRANSPARENCY A property of systems that implies that when supplied with the same inputs, a given function will always return exactly the same result. Guaranteed referential transparency removes a weakness of testing, since external state can no longer effect the validity of the test.
and so suffer from the same control flow complexity as other languages. Some languages can a small advantage because they encourage a function-based approach to control flow (i.e., map and reduce instead of normal flow statements like for and while).
complexity of a system – only mutable state does. procedure int getNextCounter() { // counter is declared elsewhere counter := counter + 1 return counter } This procedure relies on external state, and so its behavior cannot reliably be reasoned about or tested with automated tests.
in external dependencies and returning a new, modified result. procedure int getNextCounter(int oldCounter) { newCounter := oldCounter + 1 return newCounter } This modified procedure maintains referential transparency and can be reasoned about and tested.
does not reduce the complexity of the system. Notably, this is the approach taken by Redux – all system state is passed from transform to transform. Referential transparency is maintained because each transform does not mutate the global state – they return modified copies.
– and so is visible to the user. ACCIDENTAL Accidental complexity is everything else – complexity with which the dev team would be able to avoid in an ideal world (i.e., complexity due to performance issues, bad design decisions, or a suboptimal language choice).
doesn’t even know what something is, then it cannot possibly be essential. “ Optimistically assuming that the users actually understand the problem they want solved, of course.