AI agent as a teaching assistant – an experiment
I have always been experimenting with how LLMs can help me learn fundamental programming concepts. As agents become more powerful, the fundamentals only increase in relevance. However, a recent study has shown how using coding agents impairs learning. The study goes on to show that the manner in which agents are used can either contribute to or impair learning. I see agents as both the problem and the antidote, and I want to learn to use them the right way.
About a year back, I learnt some fundamentals of Java programming (including object oriented design) from the book Head First Java (I recommend the 2023 edition). I still use books as my primary learning source, given how the authors are true experts that offer a curated learning path. I complement the book with an LLM, which serves as a teaching assistant. I use it to clarify doubts and sometimes follow my curiosity beyond the book’s syllabus.
When I took a look at some Java code recently, I realized that my learning from last year was slowly evaporating. It was time to revise these fundamentals. This time, I decided to use the book in combination with an AI agent. I provided the agent a PDF copy of the book and asked it to quiz me on the first 10 chapters. The agent used was Sonnet 4.6.
I started with this prompt:
Based on the book Head_First_Java, I want you to quiz me on concepts within the book so that I can test my knowledge.
The agent asked me some follow-up questions and we aligned on the following:
- The quiz will be based on Chapters 1-10
- The format will be a mix of multiple choice, short free text answers, code puzzles, spot-the-bug etc.
- The difficulty will be set to ‘intermediate’
Going through the quiz helped me recognize weak spots. The agent gave me the following summary:
| Topic | Result | |
|---|---|---|
| 1 | Ch. 1 – Loops | ✅ Nearly perfect (missed done) |
| 2 | Ch. 2 – Class vs Object | ✅ Correct |
| 3 | Ch. 3 – Primitives vs References | ✅ Correct |
| 4 | Ch. 4 – Variable Shadowing | ❌ Missed (tricky one!) |
| 5 | Ch. 5 – Method Overloading | — (skipped) |
| 6 | Ch. 7 – Inheritance / IS-A | ❌ Reversed the rule |
| 7 | Ch. 8 – Abstract Classes | Partial (only B was correct) |
| 8 | Ch. 9 – Constructor Chaining | ✅ Correct |
| 9 | Ch. 10 – Static Variables | ✅ Correct |
| 10 | Ch. 6 – ArrayList / Exceptions | — (skipped) |
I closed my knowledge gaps based on the results. With concepts like Variable Shadowing and Method Overloading, this was easily done. With Inheritance, I felt like I needed some further drilling. I further drilled these weak points until I was scoring higher on quizzes:
Weak Spots Drill — Final Score:
| Topic | Result | |
|---|---|---|
| 1 | HAS-A identification | ✅ Correct |
| 2 | IS-A vs HAS-A design | ✅ Perfect — 4/4 |
| 3 | Comparable / compareTo() | Partial (right interface, parameter type wrong) |
| 4 | Field shadowing | ✅ Correct |
| 5 | Compile-time vs runtime casting | ✅ Correct |
| 6 | Safe casting with instanceof | Partial (right logic, wrong syntax + missed cast) |
| 7 | default interface methods | ✅ Correct |
| 8 | Abstract class + interface combo | ✅ Perfect — 3/3 |
I reached a point where I felt like I needed a coding exercise. I was aware of patterns that trade-off between inheritance and composition. However, this was something I hadn’t really wrapped my head around. I decided to have the agent give me an exercise to help me dig deeper. The prompt I used:
Give me an exercise where I can solve a problem with both Inheritance and Composition.
The agent provided the following exercise in response:
The Exercise — Music Player System
You’re building a simple music app. Here are the requirements:
You have three types of media that can be played:
- Song — has a title and artist. Can play() and pause().
- Podcast — has a title and host. Can play(), pause(), and rewind().
- Audiobook — has a title and author. Can play(), pause(), rewind(), and setChapter(int chapter).
Shared behaviour:
- play() prints: “Playing: [title]”
- pause() prints: “Paused: [title]”
- rewind() prints: “Rewinding: [title]”
Your Task Part 1 — Inheritance approach: Design the class hierarchy using inheritance. Decide:
- What is the parent class and what goes in it?
- Which classes extend which?
- What does each subclass add?
- Write out the class declarations and method implementations.
Part 2 — Composition approach: Now redesign it using composition instead. Decide:
- What behaviour can be extracted into separate “capability” classes?
- How do Song, Podcast, and Audiobook use those classes?
- Write out the redesigned classes.
Part 3 — Reflection (short answer) After writing both:
- Which approach felt more natural for this problem, and why?
- Is there anything one approach handles better than the other here?
At this point, I switched off autocomplete and solved the exercise by hand. I found this exercise to be just the right level. Those quizzes had given the agent feedback on my proficiency level. When I provided the agent with my solution, it came back with helpful feedback.
After some iteration, I hit upon three solutions:
- The inheritance based approach
- The composition based approach
- An interface based composition approach (which I thought was the best among the three)
You can see the exercise and my solutions here.
Takeaway
Having done this exercise, I am excited about using the agent to further revise and deepen my object oriented programming knowledge. What I enjoyed about working with the agent was how I could follow a self-guided learning path that was tailored to my interest and proficiency level. I have a hunch that education in the future will increasingly adopt this approach in favour of the factory-model schooling that most of us grew up with.
The killer feature for me was the coding exercise. As a learner, I always struggled to come up with such exercises for myself. I am excited that my first such experiment worked so well. I am keen on trying this out more.
I am sharing this experience for two reasons. Firstly, if you see something that can be improved, either in my learning approach or my solution to the coding exercise, I would greatly appreciate your feedback. Secondly, I hope this sparks new ideas on how you can use agents to further your own learning.