Computational Thinking and pAIr Programming with XIPU AI
At XJTLU, students from various majors across the School of Advanced Technology, International Business School Suzhou, School of Films and TV Arts, School of Science, and School of Mathematics and Physics have the opportunity to learn programming. This education not only equips them with coding skills but also fosters their ability to apply computational thinking in solving domain-specific problems within their respective fields of study. This encompasses several essential skills:
 
  • Decomposition: The art of breaking down complex problems into smaller, more manageable tasks.
  • Pattern Recognition: The skill of identifying common patterns and similarities.
  • Algorithmic Thinking: The practice of developing step-by-step procedures for solving problems.
  • Debugging: The ability to identify and rectify errors in their solutions.
 
One effective method for cultivating computational thinking skills while learning programming in computer labs is through Pair Programming. In this approach, two students collaborate on solving the same problem. One student assumes the role of the Driver, responsible for writing the code and translating design concepts into actual code implementation. Meanwhile, the other student, known as the Observer, reviews the code, identifies errors, and provides design suggestions and improvements. The roles of the driver and observer are continuously switched throughout the session.
 
 
Pair programming, when not executed effectively, can face various challenges that hinder its success. Differences in working styles or personalities may lead to conflicts and decreased productivity. When one student significantly outperforms or underperforms the other, it can result in frustration or a sense of not contributing equally. In certain pairs, one student may take the lead while the other becomes less active. Distractions or off-topic conversations during pairing sessions can reduce overall productivity.
 
 
In this article, we explore ways to utilize XIPU AI, by supporting the Driver's or the Observer's role in Pair Programming, to overcome these challenges. We give some sample prompts. For a running example, let us use the following actual coding problem in our course:
 
 
"An Armstrong number is defined as an n-digit number that equals the sum of the nth power of its individual digits. For instance, 153 is a three-digit number where the sum of the cubes of its digits equals 153.
 
 
Write a Java program that, given a positive integer a as input, prints the first Armstrong number that is greater than or equal to a."
 
 
Ask simpler explanation with more examples
 
The problem is typically succinctly stated with few examples. Now, Students can ask XIPU AI for further explanations in different case scenarios and additional examples. The Observer can then use these new examples as test cases to evaluate the Driver's code. When the code passes a sufficient number of test cases, we can be more confident that it is right. Below is an example scenario where an undergraduate student asking XIPU AI to explain an Armstrong number.
 
 
 
Assigning roles and defining desired output characteristics can help students obtain a more easily understandable description. In response to various requests, XIPU AI provides customized answers; the example of a high school student asking XIPU AI to explain an Armstrong number is seen below.
 
 
 
 
Come up with ideas to start with
 
At times, finding the initial idea to start solving the problem can be challenging. To overcome this mental block, the Driver can turn to XIPU AI to give an algorithm that can break down the problem and provide some steps to begin. They may choose to adopt certain parts of the algorithm rather than the entire sequence. After a careful review of the suggestions, they can even discard the proposed ideas completely and formulate their own approaches.
 
 
 
 
Simplify the code
 
The Observer can consult XIPU AI for ideas to simplify the initial code written by the Driver. In the example below, the AI removed two unused variables and statements to achieve the goal of counting the digits. However, it is important for the Observer to exercise their judgment when considering the AI's suggestions, as there may be instances where the code becomes overly simplified.
 
 
 
 
Test and debug the code
 
The Observer frequently has trouble immediately comprehending the Driver's code for testing purposes. In such instances, they can seek assistance from XIPU AI to identify and suggest ways to debug potential issues. Additionally, as previously mentioned, XIPU AI can be utilized to generate test cases for testing the code's correctness with specific input-output pairs, rather than creating them manually.
 
In the example below, XIPU AI successfully identified the bug, provided an explanation of the issue, and suggested a corrected code.
 
 
 
 
Improve the solution code
 
Finally, although the code may be correct, there is still room for improvement to enhance its readability and efficiency. Students can learn good programming practices and design patterns from XIPU AI by requesting details about the enhancements it has made. It is important to keep in mind that while this presents a valuable opportunity to learn new algorithms or coding styles, it is crucial to go back and test the suggested code again for correctness! Always remember that what the AI does is just completing your prompts, which may include computer codes.
 
 
 
 
In conclusion, instead of solely relying on AI to provide solution code and potentially depriving students of the learning process, students can harness the power of AI to improve their learning experiences. By practicing pair programming with AI assistance (pAIr programming), students can utilize XIPU AI as a valuable tool to expedite their learning journey and become more efficient study partners and productive programmers. While students still need to provide sufficient context and verify the correctness of the suggested code and explanation, both the Driver and the Observer can benefit from XIPU AI to generate initial ideas, resolve disagreements, reduce social pressure and increase focus. When used appropriately, XIPU AI has the potential to accelerate these students' computational thinking and problem-solving abilities.

AUTHOR
Dr. Erick Purwanto,
School of Advanced Technology, Dr. Qing Zhang,
Academy of Future Education
XJTLU

DATE
25 October 2023

Related Articles