Skip to main content
Log in

Understanding the “this” reference in object oriented programming: Misconceptions, conceptions, and teaching recommendations

  • Published:
Education and Information Technologies Aims and scope Submit manuscript

Abstract

The paper presents research that aims to expose students’ understanding of the this reference in object-oriented programming. The study was conducted with high school students (N = 86) and college engineering students (N = 77). Conceptualization of this reflects an understanding of objects in general and involves aspects of programming variants and programmers’ preferences as well. To examine students’ conceptions, perceptions, and misconceptions we developed a diagnostic tool that uses this in various contexts, such as in constructors, as a visible parameter, for calling an overloaded constructor in class, or while transiting a non-static method using this to a static one. The detailed analysis revealed difficulties, in both groups of participants, in conceptualizing the meaning of this as the current object and in its various uses in the code. The discussion presents students’ conceptions of “what is this”, nine misconceptions that we characterized, and answers to our research questions. The conclusion offers recommendations for teaching and learning processes in light of the results obtained.

This is a preview of subscription content, log in via an institution to check access.

Access this article

Price excludes VAT (USA)
Tax calculation will be finalised during checkout.

Instant access to the full article PDF.

Fig. 1
Fig. 2

Similar content being viewed by others

References

  • Bloom, B. S. (1956). Taxonomy of educational objectives. Handbook 1: Cognitive domain. McKay.

  • BlueJ (n.d.). BlueJ: About BlueJ. https://www.bluej.org/about.html

  • Byrnes, J. P., & Wasik, B. A. (1991). Role of conceptual knowledge in mathematical procedural learning. Developmental Psychology, 27(5), 777–786.

    Article  Google Scholar 

  • Chen, C.-L., Cheng, S.-Y., & Lin, J. M.-C. (2012). A study of misconceptions and missing conceptions of novice Java programmers. In Proceedings of the International Conference on Frontiers in Education: Computer Science and Computer Engineering (FECS ‘12) (p. 84–89). Steering Committee of the World Congress in Computer Science, Computer Engineering and Applied Computing (WorldComp).

  • Creswell, J. W., & Creswell, J. D. (2018). Research design: Qualitative, quantitative, and mixed methods approaches (5th ed.). SAGE Publications.

  • Du Boulay, B. (1986). Some difficulties of learning to program. Journal of Educational Computing Research, 2(1), 57–73.

    Article  Google Scholar 

  • Fleury, A. E. (2000). Programming in Java: Student-constructed rules. ACM SIGCSE Bulletin, 32(1), 197–201.

    Article  Google Scholar 

  • Goldberg, A., & Robson, D. (1983). Smalltalk-80: The language and its implementation. Addison-Wesley Longman.

  • Haberman, B., & Muller, O. (2008). Teaching abstraction to novices: Pattern-based and ADT-based problem-solving processes. In 38th Annual Frontiers in Education Conference, FIE 2008 (p. F1C-7). ASEE/IEEE.

  • Hazzan, O., Ragonis, N., & Lapidot, T. (2020). Learners’ alternative conceptions. In Guide to teaching computer science: An activity-based approach (3rd ed., ch. 9). Berlin: Springer science+business media.

  • Holland, S., Griffiths, R., & Woodman, M. (1997). Avoiding object misconceptions. ACM SIGCSE Bulletin, 29(1), 131–134.

    Article  Google Scholar 

  • JavaTpoint (n.d.). Java training: this keyword in Java. https://www.javatpoint.com/this-keyword

  • Jeliot (n.d.). Jeliot 3: Home. http://cs.joensuu.fi/jeliot/index.php

  • Kaczmarczyk, L. C., Petrick, E. R., East, J. P., & Herman, G. L. (2010). Identifying student misconceptions of programming. In Proceedings of the 41st ACM Technical Symposium on Computer Science Education (pp. 107–111). ACM.

  • Kanaki, K., & Kalogiannakis, M. (2018). Introducing fundamental object-oriented programming concepts in preschool education within the context of physical science courses. Education and Information Technologies, 23, 2673–2698.

    Article  Google Scholar 

  • Lewis, J., & Loftus, W. (2009). Java software solutions: Foundations of program design (8th ed.). Pearson/Addison-Wesley.

  • Luxton-Reilly, A., Albluwi, I., Becker, B. A., Giannakos, M., Kumar, A. N., Ott, L., ... Szabo, C. (2018). Introductory programming: a systematic literature review. In Proceedings Companion of the 23rd Annual ACM Conference on Innovation and Technology in Computer Science Education (pp. 55–106).

  • Miller, C. S., & Settle, A. (2016). Some trouble with transparency: An analysis of student errors with object-oriented python. In Proceedings of the 2016 ACM Conference on International Computing Education Research (pp. 133–141). ACM.

  • Milne, I., & Rowe, G. (2002). Difficulties in learning and teaching programming—Views of students and tutors. Education and Information Technologies, 7(1), 55–66.

    Article  Google Scholar 

  • Oracle (n.d.). Oracle Java documentation—The Java tutorials: Using the this keyword. https://docs.oracle.com/javase/tutorial/java/javaOO/thiskey.html

  • Qian, Y., & Lehman, J. (2017). Students’ misconceptions and other difficulties in introductory programming: A literature review. ACM Transactions on Computing Education (TOCE), 18(1), 1–24.

    Article  Google Scholar 

  • Qian, Y., Hambrusch, S., Yadav, A., Gretter, S., & Li, Y. (2019). Teachers’ perceptions of student misconceptions in introductory programming. Journal of Educational Computing Research, 58(2), 364–397.

    Article  Google Scholar 

  • Ragonis, N., & Ben-Ari, M. (2005). A long-term investigation of the comprehension of OOP concepts by novices. Computer Science Education, 15(3), 203–221.

    Article  Google Scholar 

  • Ragonis, N., & Shmallo, R. (2017). On the (Mis) Understanding of the "this" reference. In Proceedings of the 2017 ACM SIGCSE Technical Symposium on Computer Science Education (SIGCSE '17). ACM, New York, NY, USA, 489–494.

  • Ragonis, N., & Shmallo, R. (2018). A Diagnostic Tool for Assessing Students’ Perceptions and Misconceptions Regards the Current Object “this”. In: Pozdniakov S., Dagienė V. (eds) Informatics in Schools. Fundamentals of Computer Science and Software Engineering. ISSEP 2018. Lecture Notes in Computer Science (vol 11169, pp. 84–100). Springer, Cham.

  • Roberts, E. S. (2007). The art and science of Java. Pearson/Addison-Wesley.

  • Rosson, M. B., & Alpert, S. R. (1990). The cognitive consequences of object-oriented design. Human Computer Interaction, 5(4), 345–379.

    Article  Google Scholar 

  • Sajaniemi, J., Kuittinen, M., & Tikansalo, T. (2008). A study of the development of students’ visualizations of program state during an elementary object-oriented programming course. Journal on Educational Resources in Computing (JERIC), 7(4), article 3.

    Google Scholar 

  • Sanders, K., Boustedt, J., Eckerdal, A., McCartney, R., Moström, J. E., Thomas, L., & Zander, C. (2008). Student understanding of object-oriented programming as expressed in concept maps. ACM SIGCSE Bulletin, 40(1), 332–336.

    Article  Google Scholar 

  • Shmallo, R., Ragonis, N., & Ginat, D. (2012). Fuzzy OOP: Expanded and reduced term interpretations. In Proceedings of the 17th ACM Annual Conference on Innovation and Technology in Computer Science Education (pp. 309–314). ACM.

  • Sorva, J. (2007). Students’ understandings of storing objects. In Proceedings of the Seventh Baltic Sea Conference on Computing Education Research (vol. 88, pp. 127–135). Australian Computer Society, Inc.

  • Sorva, J. (2008). The same but different students’ understandings of primitive and object variables. In Proceedings of the 8th International Conference on Computing Education Research (pp. 5–15). ACM.

  • Sorva, J. (2013). Notional machines and introductory programming education. ACM Transactions on Computing Education (TOCE), 13(2), article 8.

    Google Scholar 

  • Xinogalos, S. (2015). Object-Oriented Design and Programming: an investigation of novices’ conceptions on objects and classes. ACM Transactions on Computing Education, 15(3), 1–21.

  • Xinogalos, S. (2016). Designing and deploying programming courses: Strategies, tools, difficulties and pedagogy. Education and Information Technologies, 21, 559–588.

    Article  Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Ronit Shmallo.

Ethics declarations

Conflict of interest

Not applicable.

Additional information

Publisher’s note

Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.

Appendices

Appendix 1: The questionnaire

Question 1: Where Is this Needed.

The following is a project that includes a simple class Date, a composed class Flight, and a main class Program.

figure afigure a
  1. (a)

    In relation to the rows marked with numbers 1–4 (// line #n) determine where this is required to be used and where it is superfluous. Explain the reason for each of your choices.

  2. (b)

    When executing instruction #5 in the main method, to what does the this appearing in the equals method in class Flight refer?

  3. (c)

    Develop a static method replacing the instance method equals in class Date.

  4. (d)

    Can this be used in the code of the main method? Explain your answer.

Question 2: Personal Preferences on Using this in Code.

Each of the following methods relates to the class Point described by two coordinates (x,y). Some of the methods use this and some do not. The methods of each clause execute the same task, and they are all syntactically correct. Please rank in each line marked by (a)–(d) your personal preferences codes by assigning numbers from 1 to 3, where 1 is your first priority. Explain your choices.

figure b

Question 3: Using this as a Parameter.

The following is a project that includes a simple class Circle and a main class Test. Some of the methods of the class Circle include only the method signature without the method’s full body. The method drawX(…) accepts a circle as a parameter and draws it, the method drawFlower(…) accepts a circle as a parameter and draws a flower consisting of circles, and the method chooseWhatToDraw(…) accepts a circle and a character and determines what to draw.

figure c

In relation to the main method and the execution of the instruction.

circle1.chooseWhatToDraw('F', circle2);

to what does the this that appears in the method chooseWhatToDraw(…) in the instruction drawFlower(this); refer?

Question 4: Using this to Invoke a Current Class Overloaded Constructor.

The following is a project that includes the classes AA and Program. Review the classes and answer the questions that follow.

figure d

Follow the execution of the main method and

  1. (a)

    Use a trace table and display the program output.

  2. (b)

    In relation to the rows marked with numbers 1–2 (// line #n), determine what the this refers to when executing the next instruction:

AA a=new AA();

Question 5: Using this—an Open Comprehension Question.

Please briefly answer the following questions:

  1. (a)

    When must this be used?

  2. (b)

    When should this be used?

  3. (c)

    When shouldn’t this be used?

  4. (d)

    What is this?

Appendix 2: Mapping the research questions and outcomes

Table 10 Mapping between Identified Misconceptions, Diagnostic Tool Questions, Research Questions, and the Different Usages of this

Rights and permissions

Reprints and permissions

About this article

Check for updates. Verify currency and authenticity via CrossMark

Cite this article

Shmallo, R., Ragonis, N. Understanding the “this” reference in object oriented programming: Misconceptions, conceptions, and teaching recommendations. Educ Inf Technol 26, 733–762 (2021). https://doi.org/10.1007/s10639-020-10265-6

Download citation

  • Received:

  • Accepted:

  • Published:

  • Issue Date:

  • DOI: https://doi.org/10.1007/s10639-020-10265-6

Keywords

Navigation