skip to main content
10.1145/3661167.3661180acmotherconferencesArticle/Chapter ViewAbstractPublication PageseaseConference Proceedingsconference-collections
research-article
Open access

Understanding Logical Expressions with Negations: Its Complicated

Published: 18 June 2024 Publication History

Abstract

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.

References

[1]
Galit Agmon, Yonatan Loewenstein, and Yosef Grodzinsky. 2022. Negative Sentences Exhibit a Sustained Effect in Delayed Verification Tasks. J. Exp. Psy.: Learning, Memory, & Cognition 48, 1 (Jan 2022), 122–141. https://doi.org/10.1037/xlm0001059
[2]
Shulamyt Ajami, Yonatan Woodbridge, and Dror G. Feitelson. 2019. Syntax, Predicates, Idioms — What Really Affects Code Complexity?Empirical Software engineering 24, 1 (Feb 2019), 287–328. https://doi.org/10.1007/s10664-018-9628-3
[3]
Ruven E. Brooks. 1983. Towards a Theory of the Comprehension of Computer Programs. Int. J. Man Mach. Stud. 18, 6 (1983), 543–554. https://doi.org/10.1016/S0020-7373(83)80031-5
[4]
Bill Curtis, Jay Sappidi, and Jitendra Subramanyam. 2011. An evaluation of the internal quality of business applications: does size matter?. In Proceedings of the 33rd International Conference on Software Engineering, Richard N. Taylor, Harald C. Gall, and Nenad Medvidovic (Eds.). ACM, 711–715. https://doi.org/10.1145/1985793.1985893
[5]
Viviane Déprez and M. Teresa Espinal (Eds.). 2020. The Oxford Handbook of Negation. Oxford University Press.
[6]
I Deschamps, G Agmon, Y Loewenstein, and Y Grodzinsky. 2015. The processing of polar quantifers, and numerosity perception cognition. Int. J. Man Mach. Stud. 143 (2015), 115–128. https://doi.org/10.1016/j.cogni
[7]
Dror G. Feitelson. 2022. Considerations and Pitfalls for Reducing Threats to the Validity of Controlled Experiments on Code Comprehension. Empirical Software engineering 27, 6, Article 123 (Nov 2022). https://doi.org/10.1007/s10664-022-10160-3
[8]
Yosef Grodzinsky 2020. Logical negation mapped onto the brain. Brain Structure and Function 35 (2020), 19–31. ttps://link.springer.com/article/10.1007/s00429-019-01975-w
[9]
Yosef Grodzinsky 2021. A linguistic complexity pattern that defies aging: The processing of multiple negations. Journal of Neurolinguistics 58 (2021), 543–554. https://www.sciencedirect.com/science/article/pii/S0911604420301421
[10]
Sallie M. Henry and Dennis G. Kafura. 1981. Software Structure Metrics Based on Information Flow. IEEE Transactions on Software Engineering 7, 5 (1981), 510–518. https://doi.org/10.1109/TSE.1981.231113
[11]
Errol R. Iselin. 1988. Conditional Statements, Looping Constructs, and Program Comprehension: An Experimental Study. Intl. J. Man-Machine Studies 28, 1 (Jan 1988), 45–66. https://doi.org/10.1016/S0020-7373(88)80052-X
[12]
Marcel Adam Just and Patricia Ann Carpenter. 1971. Comprehension of negation with quantification. Journal of Verbal Learning and Verbal Behavior 10 (1971), 244–253. https://www.sciencedirect.com/science/article/abs/pii/S0022537171800518
[13]
Sangeet Khemlani, Isabel Orenes, and P.N. Johnson-Laird. 2014. The negations of conjunctions, conditionals, and disjunctions. Acta Psychologica 151 (2014), 1–7. https://www.sciencedirect.com/science/article/abs/pii/S0001691814001206
[14]
Robert C. Martin. 2009. Clean Code: A Handbook of Agile Software Craftmanship. Prentice Hall.
[15]
Glenford J. Myers. 1977. An extension to the cyclomatic measure of program complexity. ACM SIGPLAN Notices 12, 10 (1977), 61–64. https://doi.org/10.1145/954627.954633
[16]
Isabel Orenes, Linda Moxey, Christoph Scheepers, and Carlos Santamaría. 2016. Negation in context: Evidence from the visual world paradigm. Quarterly Journal of Experimental Psychology 69 (2016). https://doi.org/10.1080/17470218.2015.1063675
[17]
Václav Rajlich and George S. Cowan. 1997. Towards Standard for Experiments in Program Comprehension. In 5th International Workshop on Program Comprehension. 160–161. https://doi.org/10.1109/WPC.1997.601284
[18]
Margaret-Anne D. Storey. 2005. Theories, Methods and Tools in Program Comprehension: Past, Present and Future. In Proc. 13th International Workshop on Program Comprehension. IEEE Computer Society, 181–191. https://doi.org/10.1109/WPC.2005.38
[19]
Ye Tian and Richard Breheny. 2015. Dynamic Pragmatic View of Negation Processing. Negation and Polarity: Experimental Perspectives 1 (2015), 21–43. https://link.springer.com/chapter/10.1007/978-3-319-17464-8_2
[20]
P. C. Wason. 1959. The Processing of Positive and Negative Information. Quarterly Journal of Experimental Psychology 11 (1959), 92–107. https://doi.org/10.1080/17470215908416296

Recommendations

Comments

Information & Contributors

Information

Published In

cover image ACM Other conferences
EASE '24: Proceedings of the 28th International Conference on Evaluation and Assessment in Software Engineering
June 2024
728 pages
ISBN:9798400717017
DOI:10.1145/3661167
This work is licensed under a Creative Commons Attribution International 4.0 License.

Publisher

Association for Computing Machinery

New York, NY, United States

Publication History

Published: 18 June 2024

Check for updates

Author Tags

  1. Code comprehension
  2. Logical expression
  3. Negation

Qualifiers

  • Research-article
  • Research
  • Refereed limited

Conference

EASE 2024

Acceptance Rates

Overall Acceptance Rate 71 of 232 submissions, 31%

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • 0
    Total Citations
  • 164
    Total Downloads
  • Downloads (Last 12 months)164
  • Downloads (Last 6 weeks)35
Reflects downloads up to 28 Feb 2025

Other Metrics

Citations

View Options

View options

PDF

View or Download as a PDF file.

PDF

eReader

View online with eReader.

eReader

HTML Format

View this article in HTML Format.

HTML Format

Login options

Figures

Tables

Media

Share

Share

Share this Publication link

Share on social media