– we remember 4+/-1 item in our short memory, then they fade away.
– in our brain facts/knowledge pieces are grouped, chunked and CHUNKS are linked.
– we process input with our focus/locus of attention (one thing at the same time in the same space)
– focus/locus is called CONTEXT
– MENTAL MODEL is what our brain builds from CHUNKS in CONTEXT
– Problems with me our mental models are many. Brain needs an extra work if mental models are:
– rebuilt by switching contexts (which is expensive)
– dealing with abstractions
– are similar or ambiguous
– there is mental noise (extra unrelated input)
– we process negation
– All these obstacles increase COGNITIVE LOAD – amount of mental effort we invest in processing.
– More cognitive load incrementally decrease our mental capacity or efficiency, if you will.
Length is not a virtue in a name; clarity of expression IS.
The longer name also doesn’t help creating a better context, effectively it is just noise.
The more complex single variable states are during method execution,
the harder it gets to track all the changes at the same time.
Idioms are groups of words that took different meaning |
that is not deductible from each word separately.
Programming language expressions can turn into idioms,
at least in hour own minds and in small teams.
Conclusion: same expressions written with same names/words
create implicit idioms in our mind and are easier to read over time.
The more consistent the code base is in naming, formatting, structure, interaction etc.
the easier it is to jump into arbitrary code and understand it.
No matter how good/bad is your architectural or coding decision is
(about code organization, naming convention etc.)
the best way to proceed with it is to be consistent about it.
Ambiguity & Similarity (DDD: Ubiquitous language)
[1, 2, 3].filter(i, i >= 2)
Client may be a different thing in shipping and billing modules
Comments should provide CONTEXT by answering WHY question.
Answering on WHY something was written in a particular way or WHY it does something it does
most certain must provide some kind of detailed context around the code.