Comprehension Flashcards
program comprehension
reading code.
how do experts answer questions?
experts use prior knowledge that they have about architecture, design patterns, and the problem domain a program is built for to know what questions to ask and how to answer them.
how do novices answer questions?
novices use surface features of code, which leads them to spend considerable time reading code that is irrelevant to a question.
data dependencies
where a variable is used to compute something, what modifies a data structure, how data flows through a program, etc.
control dependencies
which components call which functions, which events can trigger a function to be called, how a function is reached, etc.
Cognitive Dimensions of Notations framework
lays out some of the tradeoffs in programming language design that result in these differences in comprehensibility.
consistency (dimension of the cognitive…. framework)
refers to how much of a notation can be guessed based on an initial understanding of a language.
low-consistency language
JavaScript, because of operators like ==, which behave differently depending on what the type of the left and right operands are.
high-consistency language
Java, == is only ever valid when both operands are of the same type.
Encapsulation through
data structures leads to better comprehension that monolithic or purely functional languages
Declarative programming paradigms (like the JavaScript view framework React) have
greater comprehensibility than imperative languages
In general, languages that are statically typed result in
fewer defects, better comprehensibility because of the ability to construct better documentation, and result in easier debugging.
dynamic languages like JavaScript and Smalltalk show that
the dynamic features of these languages aren’t really used all that much anyway.