TY - GEN
T1 - Understanding Logical Expressions with Negations
T2 - 28th International Conference on Evaluation and Assessment in Software Engineering, EASE 2024
AU - Baron, Aviad
AU - Granot, Ilai
AU - Yosef, Ron
AU - Feitelson, Dror
N1 - Publisher Copyright: © 2024 Owner/Author.
PY - 2024/6/18
Y1 - 2024/6/18
N2 - The flow of control in computer programs is shaped by conditional branches. The Boolean expressions which determine the outcome of a branch may have an effect on the readability of the code. In particular, negations can make such expressions harder to understand. We conduct an experiment with 205 professional developers who needed to understand different logical expressions. The results show that the time needed to understand different expressions of similar size can vary significantly. In general, expressions with more negations take more time, and double negations are especially troublesome. However, there are multiple other factors that also have an effect. For example, literals which are TRUE take less time to process than literals that are FALSE. Regularity (where either all variables have negations or all do not, or where either all literals are TRUE or all are FALSE) also helps. But there are many confounding interactions between the factors, leading to complex outcomes. For example, when comparing De Morgan's logically-equivalent pairs of expressions, we found that understanding a negated OR took slightly more time than the AND of two negations, but there was no difference between a negated AND and the OR of two negations. The factors we identified as influencing the understanding of expressions may contribute to advancing our knowledge of cognitive processes involved in understanding logical expressions, but much additional work is still needed. At the same time, the comparisons of equivalent forms provide some practical advice on how to write more understandable expressions.
AB - The flow of control in computer programs is shaped by conditional branches. The Boolean expressions which determine the outcome of a branch may have an effect on the readability of the code. In particular, negations can make such expressions harder to understand. We conduct an experiment with 205 professional developers who needed to understand different logical expressions. The results show that the time needed to understand different expressions of similar size can vary significantly. In general, expressions with more negations take more time, and double negations are especially troublesome. However, there are multiple other factors that also have an effect. For example, literals which are TRUE take less time to process than literals that are FALSE. Regularity (where either all variables have negations or all do not, or where either all literals are TRUE or all are FALSE) also helps. But there are many confounding interactions between the factors, leading to complex outcomes. For example, when comparing De Morgan's logically-equivalent pairs of expressions, we found that understanding a negated OR took slightly more time than the AND of two negations, but there was no difference between a negated AND and the OR of two negations. The factors we identified as influencing the understanding of expressions may contribute to advancing our knowledge of cognitive processes involved in understanding logical expressions, but much additional work is still needed. At the same time, the comparisons of equivalent forms provide some practical advice on how to write more understandable expressions.
KW - Code comprehension
KW - Logical expression
KW - Negation
UR - http://www.scopus.com/inward/record.url?scp=85197407892&partnerID=8YFLogxK
U2 - 10.1145/3661167.3661180
DO - 10.1145/3661167.3661180
M3 - منشور من مؤتمر
T3 - ACM International Conference Proceeding Series
SP - 303
EP - 312
BT - Proceedings of 2024 28th International Conference on Evaluation and Assessment in Software Engineering, EASE 2024
Y2 - 18 June 2024 through 21 June 2024
ER -