Logic

„Logic“ is a recurring term in Flow Design. You might have notices it before in „business logic“ or „domain logic“ or „presentation logic“ etc. But what exactly does it mean? It’s some form of code, but which?

Flow Design is very specific about what logic is. Logic is the part of code which creates behavior.

Obviously then, comments are not logic ūüėČ But neither are source files or class definitions or data definitions, not even function definitions.

A function, a class ‚Äď both modules ‚Äď contain logic, but they are not logic.

Logic creates effects which can be observed by a user. Logic works on some input and produces output; also it may read from and/or write to some state storage.

We consider the following programming language constructs to be logic:

  • Expressions, because they transform values (input) into other values (output).
  • API-calls, because they allow to use pre-fab transformations and hardware access. State is stored in memory to be modified¬†directly or in some „device“ made available via an API.
  • Control statements like¬†if-then-else,¬†switch-case,¬†for,¬†foreach, do-loop,¬†repeat-until etc. because they change behavior based on expression evaluation.

Based on this definition only the highlighted parts of some ordinary code are considered to be logic:

Logic is a fundamental distinct responsibility within¬†any software. As terms like „business logic“ suggest, this responsibility can be further broken down and categorized. Nevertheless logic by and of itself is a responsibility to be separated from others according to the Single Responsibility Principle (SRP).