The Subjective Cost of Writing Reusable Code: The Case of Functions

Conference paper
Part of the Lecture Notes in Business Information Processing book series (LNBIP, volume 349)


Functions provide substantial benefits for software development, simplifying programming through decomposition, reusability and abstraction. In a previous study, our group identified a tendency of high-school students to not use functions, even in programming tasks where functions can be a good solution strategy. The current research extends this observation to university students and aims to provide an explanation for the factors underlying this tendency. We focus on the subjective cost of the cognitive effort required for writing functions. Our experiment examined how information systems students solved a set of programming tasks, which varied by the number of repetitive questions. The results showed that most of the students avoided using functions altogether. We further found that in the subgroup of students who used functions at least once, the likelihood of using functions was positively associated with (a) the number of repetitive questions in each task, and (b) the task order, i.e., the progress of the experiment. These results indicate that the subjective cost of writing functions is taken into account when making a decision on how to solve a task at hand and is compared with the cost of repetitive work without using function, and that the former cost is updated with experience.


Programming Functions Code-reuse Abstraction Cognition Dual-process theory Subjective cost 


  1. 1.
    Brown, M.: Comfort Zone: model or metaphor? Aust. J. Outdoor Educ. 12, 3–12 (2008)CrossRefGoogle Scholar
  2. 2.
    Chen, W.J., Krajbich, I.: Computational modeling of epiphany learning. Proc. Natl. Acad. Sci. 114, 4637–4642 (2017). Scholar
  3. 3.
    Green, L., Myerson, J.: A discounting framework for choice with delayed and probabilistic rewards. Psychol. Bull. 130, 769–792 (2004). Scholar
  4. 4.
    Hadar, I.: When intuition and logic clash: the case of the object-oriented paradigm. Sci. Comput. Program. 78, 1407–1426 (2013). Scholar
  5. 5.
    Hashim, K., Key, E.: A software maintainability attributes model. Malays. J. Comput. Sci. 9, 92–97 (1996)Google Scholar
  6. 6.
    Kable, J.W., Glimcher, P.W.: The neural correlates of subjective value during intertemporal choice. Nat. Neurosci. 10, 1625–1633 (2007). Scholar
  7. 7.
    Kahneman, D.: Maps of bounded rationality: a perspective on intuitive judgment and choice. Sveriges Riksbank Prize Econ. Sci. Mem. Alfred Nobel, 449–489 (2002). Scholar
  8. 8.
    Kool, W., McGuire, J.T., Rosen, Z.B., Botvinick, M.M.: Decision making and the avoidance of cognitive demand. J. Exp. Psychol. Gen. 139, 665–682 (2010). Scholar
  9. 9.
    Kramer, J.: Is abstraction the key to computing? Commun. ACM 50, 36–42 (2007). Scholar
  10. 10.
    Maddala, G.S.: Limited-Dependent and Qualitative Variables in Econometrics. Cambridge University Press, Cambridge (1986)zbMATHGoogle Scholar
  11. 11.
    Manlove, K.: Introduction to Statistical Analysis using R commander, pp. 1–23 (2014)Google Scholar
  12. 12.
    Omar, A., Hadar, I., Leron, U.: Investigating the under-usage of code decomposition and reuse among high school students: the case of functions. In: Metzger, A., Persson, A. (eds.) CAiSE 2017. LNBIP, vol. 286, pp. 92–98. Springer, Cham (2017). Scholar
  13. 13.
    Patzelt, E.H., Kool, W., Millner, A.J., Gershman, S.J., Note, A., Patzelt, E.H.: Building N In press at Scientific Reports 4729Google Scholar
  14. 14.
    Simon, H.A.: Administrative behaviour. Aust. J. Public Adm. (1947). Scholar
  15. 15.
    Stanovich, K.E.: What Intelligence Tests Miss: The Psychology of Rational Thought. Yale University Press, New Haven (2009)Google Scholar
  16. 16.
    Westbrook, A., Braver, T.S.: Cognitive effort: a neuroeconomic approach. Cogn. Affect Behav. Neurosci. 15, 395–415 (2015). Scholar
  17. 17.
    Westbrook, A., Kester, D., Braver, T.S.: What is the subjective cost of cognitive effort? Load, trait, and aging effects revealed by economic preference. PLoS One 8, 1–8 (2013). Scholar
  18. 18.
    Zipf, G.K.: Human Behaviour and the Principle of Least Effort: An Introduction to Human Ecology, 588 pages. Addison-Wesley Press, Cambridge (1949)Google Scholar

Copyright information

© Springer Nature Switzerland AG 2019

Authors and Affiliations

  1. 1.Department of Information SystemsUniversity of HaifaHaifaIsrael
  2. 2.Department of Cognitive SciencesUniversity of HaifaHaifaIsrael

Personalised recommendations