Abstract
This paper examines the impact of emotions on the quality of code for novice programmers while developing in an experimental setting using Python. A relaxation mechanism was additionally-used to explore the possible effect on emotion and programmer performance. Non-invasive EEG was recorded to assess activations in the left and right prefrontal cortex often related to emotions. The quality of code was obtained based on the Code-based Deep Knowledge Tracing method. Contrary to expectations, preliminary results show that positive emotions may contribute to novice programmers generating lower-quality code. Extension of this study may help solidify this relationship while reinforcing the corollary of how negative emotions contribute to code quality and recommendations for how to situate programmers in these varying mental states.
Access provided by Autonomous University of Puebla. Download conference paper PDF
Keywords
1 Introduction
Emotion is one of the most popular areas of focus for the neuroIS community where neurophysiological tools may be used for more objective measures than self-reports [1, 2]. Emotion is characterized in psychology as a multidimensional state where an individual experiences feelings that can be described as good or bad, energizing or draining. A growing body of literature is recognizing a two-dimensional framework, the circumplex model, for representing this phenomenon. This model describes an emotional state in a two-dimensional circular space with the arousal and valence dimensions, where the dimension of valence describes the extent to which an emotion is positive or negative, and the dimension of arousal describes its intensity [3,4,5]. These emotional experiences have been shown to be associated with activation of certain regions in the brain suggesting that physiological correlates of emotions can be measured using neurophysiological and neuroimaging tools [6, 7].
Electroencephalography (EEG), which measures electrical activity in the brain, is one of such neurophysiological measures that correlate with emotions [2, 8]. Changes in emotions can cause differences in EEG signals, which may reflect different emotional states. For instance, research shows that high frequencies sensed from electrodes positioned on the frontal, parietal, and occipital lobes have high correlation with emotional valence [9], and it is possible to discriminate between happiness and sadness by analyzing EEG signals in various situations [10]. In fact, EEG has been used to study how the brain functions in relation to job performance in software development and how programmers experience positive and negative emotions when coding.
Code quality is an important metric for evaluation of software as poorly written code can negatively impact the utility and the security of an application. The quality of code refers to how well-written and structured the code is, as well as how effectively it performs its intended function [11, 12]. High-quality code is easy to read and understand, well-documented, and efficient. There are many technical factors that affect the quality of code, such as clarity, maintainability, reliability, and security [13]. Other behavioral factors can impact the quality of code, such as motivation, communication, time management, and emotions [14].
Emotions can have a significant impact on people’s performance. Notably, positive and negative emotions can significantly impact the quality of code that developers produce [15,16,17,18]. Relaxation can have a positive impact on code quality, as well. When developers are relaxed, they are more likely to be focused, creative, and attentive to detail [19,20,21]. These characteristics can lead to better code quality and more efficient development.
In this paper, we present a work-in-progress study to understand the impact of emotions on the quality of programming code. To better understand this impact, we explore the possible effect of relaxation on emotions while novice programmers solve a case problem. We provide a discussion about these findings with appreciation that further investigation with a larger sample size will be most helpful for the continuation of this research to reinforce or alter current leanings.
2 Background
Despite growing evidence that most defects in code quality are a result of human cognitive issues [22,23,24,25], software development processes in practice do not consider the emotional state of programmers during coding. The ability to examine and understand how emotions affect code quality using neurophysiological measurements can provide guidance to managers and developers to take appropriate measures to minimize and prevent poor-quality code and promote a healthy environment for the programmer. Furthermore, scholars have suggested that the use of neurophysiological measures in software engineering could lead to the design and development of integrated, neuro-adaptive development environments and learning platforms [26,27,28,29]. Several studies in software engineering have employed a variety of neurophysiological tools to study the electrical activity of the brain [2, 8], the skin [28], and heart rate variability (HRV) [29]. Results from these studies indicate that measures captured with neurophysiological tools can be used to investigate the emotional states of programmers when performing various programming tasks [3]. However, most of this prior work has centered on the prediction of abilities. Only a limited number of studies focus on emotional processes using neurophysiological tools in the context of software engineering [30,31,32]. Our study builds on prior work by using neurophysiological tools to examine the impact of relaxation and emotions on the quality of code produced by novice programmers during a coding task.
3 Proposed Study
Electroencephalography has been used to extract and detect positive and negative emotions from brain signals and incorporated as feedback into neuro-adaptive interfaces [33, 34]. The proposed study aims to use non-invasively recorded EEG to measure developers’ emotions while programming a task to identify if positive and negative emotions have a correlation with high- or low-quality of the code. The EEG recording system we are using is the BioSemi ActiveTwo bioamplifier system [35].
The ActiveTwo system consists of a headbox, which connects to a set of electrodes placed on the scalp to measure EEG signals, and a bioamplifier unit, which magnifies and digitizes these signals. The ActiveTwo system is used to measure EEG activity in specific regions of the brain that are associated with emotional processing, such as the prefrontal cortex [36]. The prefrontal cortex is a brain region involved in many cognitive and emotional processes, including the regulation of positive and negative emotions [37]. It has been shown that the left prefrontal cortex (PFC) is associated with positive emotions, while the right PFC is associated with negative emotions [38,39,40].
The quality of code can be determined using Code-DKT [41]. Code-DKT stands for “Code-based Deep Knowledge Tracing.” It is a neural network-based approach to modeling student knowledge over time in the context of programming tasks. In this study, we use the categories of Code-DKT to manually analyze the code’s quality, specifically on the reason why participants make incorrect submissions. In the future, we plan to use Code-DKT in a more data-driven way to evaluate novices’ code quality. For example, Code-DKT uses the Code2vec model to predict students’ programming performance in an educational context based on their submissions when they practice programming in a course [42]. The approach incorporates the Code2vec model into the traditional DKT model for the performance prediction task [43]. This approach directly incorporates features from programming code into the model and achieves state-of-the-art performance in the prediction task for the computing education domain. While we currently leverage a limited set of test cases to evaluate the quality of programming code, as more data is available, we will switch to the data-driven method for a more accurate evaluation of the quality of student code quality.
4 Methodology
Seven (7) participants were recruited with ages between 18 and 40 years old and located in the southeast region of the United States. Participants belonged to different university departments with some fundamental coding experience with Python. Participants were randomly divided into two groups. The control group received a relaxation treatment via a biofeedback device called the Muse 2 [44] for ten minutes. The experimental group attempted the coding task without engaging in the relaxation activity.
The BioSemi ActiveTwo system was used to collect participants’ EEG signals as they completed a thirty-minute coding activity of writing Python code for a classical programming problem, the rainfall problem [45]. The placement of the BioSemi ActiveTwo sensors was performed by trained personnel to ensure that it was comfortably and accurately positioned on the participant’s head. The study ensured that the procedures for both, the experimental and control groups, were consistent and standardized to reduce any potential confounding factors that may affect the study results. Figure 1 shows one of the participants wearing an electrode cap fitted with active electrodes wired to the BioSemi bioamplifier during the experiment.
Independent variables consisted of individual characteristics, including age, sex, relaxation treatment, and EEG data from the brain that was collected during the time the participants attempted the coding task. We collected information from 16 channels of EEG using a Common Average Reference (CAR) across: frontal-polar (Fp1, Fp2), frontal-central (FC3, FCz, FC4), central (C3, Cz, C4), temporal-parietal (TP7, TP8), parietal (P3, Pz, P4), and occipital (O1, Oz, O2). After collection, we performed offline feature extractions of the EEG signals for emotion classification. We used the software EDFBrowser [46] to down sample the signals from 1024 Hz to a sampling rate of 256 Hz. Then, we used standardized low resolution brain electromagnetic tomography (sLORETA) software to determine the cross-spectra and visualize the brain activations in a topographic plot [47]. The topographies revealed the left and right prefrontal cortex asymmetry as often related to emotions.
Dependent variables consisted of the manual analysis of the code’s quality that consisted of parameters such as syntaxis errors, I/O incorrect prompt, and non-identifiable logic. Quality points were assigned from 0 to 4, where 0 is the lowest quality and 4 is the highest. Figure 2 shows a representation of the possible relationships between the variables of the study. Independent variables such as age, sex, and relaxation treatment may act as moderators or mediators on the quality of code, however a bigger sample size is needed to establish such effects.
5 Preliminary Results
Emotions and code quality were analyzed for the seven participants in the study of six males and one female with an average age of 21.6 (±3.7). The participants were racially-diverse, with two White, three Asian, one Hispanic, and one Black/African-American. After visual inspection of the EEG, we analyzed the brain activations from the sixteen channels of scalp electrodes using a previously-validated technique for brain localization with the same name of the accompanying software, sLORETA [48]. These activations were presented on a normalized scale such that brighter areas with yellow indicated the highest levels of activation. For each six-view grouping of topological plots, the image presented on the top row in the center is a back-end view of the brain whereas the image on the bottom row in the center is a front-on view of the brain. In a similar manner as used by Riley and Randolph [49], theory indicates that higher activation in the left hemisphere may indicate a stronger positive approach to the stimulus whereas higher activation in the right hemisphere may indicate a negative approach to the stimulus [49, 50].
As “work-in-progress,” we start seeing a tendency in the results that need to be confirmed with more data. Table 1 shows the results of each participant after completing the study. The Muse 2 provided an assessment of percent calm which we report for all four participants who received the relaxation treatment except for participant C0110 whose percentage was not captured.
Surprisingly, the majority of the participants that experienced positive emotions (evidenced from highest activation levels in left prefrontal cortex), developed low quality code. There are inconclusive results from participants that exhibited negative emotions (evidenced from highest activation levels in right prefrontal cortex) and their quality of code where there is an even split between high and low quality of code generated.
Figure 3 shows exemplar topography of brain activation for participant C0300. As can be seen in Fig. 3, the yellow color represents highest levels of brain activation that were observed in the right prefrontal cortex and has been related to negative emotions. Additionally, the high activity was in the Brodmann Area 45 [51], which has been associated with semantic tasks, such as semantic decision tasks (determining whether a word represents an abstract or a concrete entity) and generation tasks. This participant ranked three out of four in the analysis of code quality, which means that overall, the code produced the expected result with minimal error of a division by zero. In contrast as seen in Fig. 4, participant A200 exhibited positive emotions while the quality of the code was low. Relaxation seemed to have a contrary effect where participants who received the relaxation treatment seemed to exhibit negative motions.
6 Discussion
Emotions are not the only factor that influences the quality of code. Other important factors also have impact, such as developer’s skill, confidence, and motivation. In this preliminary study, we showed that positive emotions seem to favor the lower quality of code. This statement seems to be alienated with general literature indicating that stronger positive emotions are correlated with higher confidence in successful task completion and complicated with how high-performance goal orientation is related to stronger negative and weaker positive emotions [52]. While surprising, these preliminary results encourage more discussion and further investigation.
A deep discussion about the preliminary results led to potential research questions that can be explored in future work. For example, looking at the initial results, we can see that everyone who obtained the relaxation treatment had negative emotions, but some of them had good-quality code. This requires more investigation, keeping in mind the ones developing the code are humans that get affected by their emotional load. Some practitioners have found that happiness, a positive emotion, could lead to more code (quantity) while sadness, a negative emotion, leads to better and cleaner code (fewer mistakes) [53]. Some others have found that stress, anger, arrogance, and negative emotions lead to more code errors and in contrast motivation and confidence, positive emotions, lead to better code or code that is easy to read and maintain [54]. Therefore, the results we are getting so far might not be entirely contradictory with literature.
Our results do, however, indicate the need to perform a more in-depth analysis about the specific positive and negative emotions experienced by the participants to understand the relationship between emotions and quality of code. Likewise, due to the highly diverse nature of the participants, it is also possible that the effects were due to differences in expertise rather than the affective state. For this reason, we propose in future work to have a self-reporting evaluation of the level of expertise of the participants. Other potential confounds need to also be considered.
7 Future Work
As next steps, we propose a research roadmap to explore more emotional factors on the quality of code. First, we will design a separate study with around forty participants and one more complex programming code task with a prior self-report of expertise in the programming language to help avoid confounding factors affecting the results. We will analyze participants in different relaxation scenarios to measure the impact of relaxation. We will compute results to verify the correlation between emotions and code quality and reduce inconclusive results. Finally, we will introduce and evaluate the impact of HRV on emotions and code quality, as other literature has shown that this is a significant measure [55, 56]. In this roadmap, it is also essential to highlight that for the preliminary results, the relaxation device (Muse2) is not considered a research-grade tool. Due to the weighted discussion of the use of research-grade devices [57, 58], we may find a substitute for measuring the relaxed state for individuals.
8 Conclusion
In this paper, we show an experimental work-in-progress for determining the impact of emotions on the quality of code of novice programmers. We designed a study that non-invasively obtained EEG signals from seven participants while they worked on developing a programming task. According to the preliminary results, positive emotions may lead to lower-quality code. Further investigation with a larger sample size is needed to validate this direction.
References
Riedl, R., Fischer, T., Léger, P. M., & Davis, F. D. (2020). A decade of NeuroIS research: Progress, challenges, and future directions. ACM SIGMIS Database: The DATABASE for Advances in Information Systems, 51(3), 13–54.
Walla, P. (2017). Affective Processing Guides Behavior and Emotions Communicate Feelings: Towards a Guideline for the NeuroIS Community. In F. D. Davis, R. Riedl, J. Vom Brocke, P.-M. Léger, & A. B. Randolph (Eds.), Lecture Notes in Information Systems and Organisation: Vol. 25. Information Systems and Neuroscience: Gmunden Retreat on NeuroIS 2017 (pp. 141–150). Springer Berlin Heidelberg.
Girardi, D., Novielli, N., Fucci, D., & Lanubile, F. (2020, June). Recognizing developers’ emotions while programming. In Proceedings of the ACM/IEEE 42nd International Conference on Software Engineering (pp. 666–677).
Lang, P. J., Bradley, M. M., & Cuthbert, B. N. (1997). Motivated attention: Affect, activation, and action. Attention and Orienting: Sensory and Motivational Processes, 97, 135.
Russell, J. A. (2003). Core affect and the psychological construction of emotion. Psychological Review, 110(1), 145.
Russell, J. A., Ward, L. M., & Pratt, G. (1981). Affective quality attributed to environments: A factor analytic study. Environment and Behavior, 13(3), 259–288.
Mauss, I. B., & Robinson, M. D. (2009). Measures of emotion: A review. Cognition and Emotion, 23(2), 209–237.
Rubin, D. C., & Talarico, J. M. (2009). A comparison of dimensional models of emotion: Evidence from emotions, prototypical events, autobiographical memories, and words. Memory, 17(8), 802–808.
Soleymani, M., Asghari-Esfeden, S., Fu, Y., & Pantic, M. (2015). Analysis of EEG signals and facial expressions for continuous emotion detection. IEEE Transactions on Affective Computing, 7(1), 17–28.
Li, M., & Lu, B. L. (2009, September). Emotion classification based on gamma-band EEG. In 2009 Annual International Conference of the IEEE Engineering in Medicine and Biology Society (pp. 1223–1226). IEEE.
Kim, M. K., Kim, M., Oh, E., & Kim, S. P. (2013). A review on the computational methods for emotional state estimation from the human EEG. Computational and Mathematical Methods in Medicine.
Fitzpatrick, R. (1996). Software quality: Definitions and strategic issues. Staffordshire University.
Kononenko, O., Baysal, O., & Godfrey, M. W. (2016, May). Code review quality: How developers see it. In Proceedings of the 38th international conference on software engineering (pp. 1028–1038).
Günsel, A. (2014). The effects of emotional labor on software quality: The moderating role of project complexity. Journal Of Global Strategic Management, 8(2), 101–115.
Dahlberg, D. (2020). Developer experience of a low-code platform: An exploratory study.
McCarthy, P. J. (2011). Positive emotion in sport performance: Current status and future directions. International Review of Sport and Exercise Psychology, 4(1), 50–69.
Graziotin, D., Fagerholm, F., Wang, X., & Abrahamsson, P. (2018). What happens when software developers are (un) happy. Journal of Systems and Software, 140, 32–47.
Girardi, D., Lanubile, F., Novielli, N., & Serebrenik, A. (2021). Emotions and perceived productivity of software developers at the workplace. IEEE Transactions on Software Engineering, 48(9), 3326–3341.
Moster, M., Chandra, A., Chu, C., Liu, W., & Rodeghero, P. (2022, September). In the zone: An analysis of the music practices of remote software developers. In Proceedings of the 16th ACM/IEEE International Symposium on Empirical Software Engineering and Measurement (pp. 313–318).
Affaldano, G., Steinmacher, I., Calefato, F., Gerosa, M., & Lanubile, F. (2019). Why do developers take breaks from contributing to OSS projects? A preliminary analysis. arXiv preprintarXiv:1903.09528.
Volobuev, V., Turischeva, P., Gainutdinov, A., Sahibgareev, R., Mazzara, M., & Farina, M. (2021, August). Effects of Mindfulness meditation on software developers’ performance. In 2021 International Conference “Nonlinearity, Information and Robotics” (NIR) (pp. 1–6). IEEE.
Basile, V., Novielli, N., Croce, D., Barbieri, F., Nissim, M., & Patti, V. (2018). Sentiment polarity classification at evalita: Lessons learned and open challenges. IEEE Transactions on Affective Computing, 12(2), 466–478.
Bradley, M. M., Bradley, M. M., & Lang, P. J. (1994). Measuring emotion: The self-assessment manikin and the semantic differential. Journal of Behavioral Therapy and Experimental Psychiatry, 25, 49–59.
Graziotin, D., Wang, X., & Abrahamsson, P. (2014). Software developers, moods, emotions, and performance. arXiv preprintarXiv:1405.4422.
Müller, S. C., & Fritz, T. (2015, May). Stuck and frustrated or in flow and happy: Sensing developers’ emotions and progress. In 2015 IEEE/ACM 37th IEEE International Conference on Software Engineering (Vol. 1, pp. 688–699). IEEE.
Weber, B., Fischer, T., & Riedl, R. (2021). Brain and autonomic nervous system activity measurement in software engineering: A systematic literature review. Journal of Systems and Software, 178, 110946.
Adam, M. T., Gimpel, H., Maedche, A., & Riedl, R. (2017). Design blueprint for stress-sensitive adaptive enterprise systems. Business & Information Systems Engineering, 59, 277–291.
Burleson, W., & Picard, R. W. (2004, August). Affective agents: Sustaining motivation to learn through failure and a state of stuck. In Workshop on Social and Emotional Intelligence in Learning Environments.
Canento, F., Fred, A., Silva, H., Gamboa, H., & Lourenço, A. (2011, October). Multimodal biosignal sensor data handling for emotion recognition. In SENSORS, 2011 IEEE (pp. 647–650). IEEE.
Müller, S. C., & Fritz, T. (2016, May). Using (bio) metrics to predict code quality online. In Proceedings of the 38th International Conference on Software Engineering (pp. 452–463).
Vrzakova, H., Amon, M. J., Stewart, A., Duran, N. D., & D'Mello, S. K. (2020, March). Focused or stuck together: multimodal patterns reveal triads’ performance in collaborative problem solving. In Proceedings of the Tenth International Conference On Learning Analytics & Knowledge (pp. 295–304).
Sánchez-Gordón, M., & Colomo-Palacios, R. (2019). Taking the emotional pulse of software engineering—A systematic literature review of empirical studies. Information and Software Technology, 115, 23–43.
Kaur, B., Singh, D., & Roy, P. P. (2018). EEG based emotion classification mechanism in BCI. Procedia Computer Science, 132, 752–758.
Constant, I., & Sabourdin, N. (2012). The EEG signal: A window on the cortical brain activity. Pediatric Anesthesia, 22(6), 539–552.
BioSemi ActiveTwo system website: https://www.biosemi.com/products.htm.
Dalgleish, T. (2004). The emotional brain. Nature Reviews Neuroscience, 5(7), 583–589.
Carlén, M. (2017). What constitutes the prefrontal cortex? Science, 358(6362), 478–482.
Etkin, A., Egner, T., & Kalisch, R. (2011). Emotional processing in anterior cingulate and medial prefrontal cortex. Trends in Cognitive Sciences, 15(2), 85–93.
Davidson, R. J. (2004). What does the prefrontal cortex “do” in affect: Perspectives on frontal EEG asymmetry research. Biological Psychology, 67(1–2), 219–234.
Gotlib, I. H. (1998). EEG alpha asymmetry, depression, and cognitive functioning. Cognition & Emotion, 12(3), 449–478.
Shi, Y., Chi, M., Barnes, T., & Price, T. (2022). Code-DKT: A Code-based Knowledge Tracing Model for Programming Tasks. In Proceedings of the 15th International Conference on Educational Data Mining (p. 50).
Alon, U., Zilberstein, M., Levy, O., & Yahav, E. (2019). code2vec: Learning distributed representations of code. In Proceedings of the ACM on Programming Languages, 3(POPL) (pp. 1–29).
Piech, C., Bassen, J., Huang, J., Ganguli, S., Sahami, M., Guibas, L. J., & Sohl-Dickstein, J. (2015). Deep knowledge tracing. Advances in Neural Information Processing Systems, 28.
Muse 2. The brain sensing headband. https://choosemuse.com/muse-2/.
Seppälä, Otto, et al. (2015). Do we know how difficult the rainfall problem is? Proceedings of the 15th Koli Calling Conference on Computing Education Research. https://dl.acm.org/, https://doi.org/10.1145/2828959.2828963.
EDFBrowser. https://www.teuniz.net/edfbrowser/.
SLoreta: Low Resolution Brain Electromagnetic Tomography. https://www.uzh.ch/keyinst/loretaOldy.htm.
Pascual-Marqui, R. D. (2002). Standardized low-resolution brain electromagnetic tomography (sLORETA): Technical details. Methods and Findings in Experimental and Clinical Pharmacology, 24(Suppl D), 5–12.
Riley, J., & Randolph, A. B. (2021). Leveraging NeuroIS Tools to Understand Consumer Interactions with Social Media Content. In Information Systems and Neuroscience: NeuroIS Retreat 2021 (pp. 56–62). Springer International Publishing.
Davidson, R. J. (1992). Anterior Cerebral Asymmetry and the Nature of Emotion. Brain and Cognition, 20, 125–151.
Strotzer, M. (2009). One century of brain mapping using Brodmann areas. Clinical Neuroradiology, 19(3), 179.
Fisher, C. D., Minbashian, A., Beckmann, N., & Wood, R. E. (2013). Task appraisals, emotions, and performance goal orientation. Journal of Applied Psychology, 98(2), 364.
Ziegler, A. (November 2018). Decoding programmers: How emotions can change code. Information Week. https://www.informationweek.com/devops/decoding-programmers-how-emotions-can-change-code.
Gregory, K. (Nov-Dec 2019). Emotional code. Code Magazine. https://www.codemag.com/article/1911081/emotional-code.
Hermes, A., & Riedl, R. (2021). Exploring the influence of personality traits on affective customer experiences in retailing: combination of heart rate variability (HRV) and self-report measures. In Information Systems and Neuroscience: NeuroIS Retreat 2021 (pp. 20–29). Springer International Publishing.
Park, S. S., & Lee, K. C. (2019). Implementing an adaptive neuro-fuzzy model for emotion prediction based on heart rate variability (HRV). Journal of Digital Convergence, 17(1), 239–247.
Müller-Putz, G. R., Tunkowitsch, U., Minas, R. K., Dennis, A. R., & Riedl, R. (2021). On electrode layout in EEG studies: A limitation of consumer-grade EEG instruments. In Information Systems and Neuroscience: NeuroIS Retreat 2021 (pp. 90–95). Springer International Publishing.
Riedl, R., Minas, R. K., Dennis, A. R., & Müller-Putz, G. R. (2020). Consumer-grade EEG instruments: Insights on the measurement quality based on a literature review and implications for NeuroIS research. Information Systems and Neuroscience: NeuroIS Retreat, 2020, 350–361.
Author information
Authors and Affiliations
Corresponding author
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2024 The Author(s), under exclusive license to Springer Nature Switzerland AG
About this paper
Cite this paper
Mugula, L., Tufon, R., Shi, Y., Valero, M., Randolph, A.B., Nino, V. (2024). Investigating the Impact of Emotions on the Quality of Novice Programmers’ Code. In: Davis, F.D., Riedl, R., Brocke, J.v., Léger, PM., Randolph, A.B., Müller-Putz, G.R. (eds) Information Systems and Neuroscience. NeuroIS 2023. Lecture Notes in Information Systems and Organisation, vol 68. Springer, Cham. https://doi.org/10.1007/978-3-031-58396-4_7
Download citation
DOI: https://doi.org/10.1007/978-3-031-58396-4_7
Published:
Publisher Name: Springer, Cham
Print ISBN: 978-3-031-58395-7
Online ISBN: 978-3-031-58396-4
eBook Packages: Business and ManagementBusiness and Management (R0)