Learning by teaching means you understand a topic more deeply when you explain it to someone else. Explaining forces you to pull ideas out of memory, and it shows you the gaps you didn't know you had. For developers, the payoff is clearer code and faster debugging, and you don't need a classroom to get it.
People are often surprised that I'm both a teacher and a developer. To me they are the same job. You take something complicated and make it simple enough for someone else to use with confidence. I've taught computer science for more than ten years, and I also build production software, including the OnePlace marketplace and the PSTA learning platform.
This page grew out of a short essay I wrote about why teaching made me a better developer. I've rebuilt it around the research, so every claim points to a study or an official source you can check.
Here's what you'll take away:
- What learning by teaching is, and what the protégé effect adds to it.
- Why explaining code exposes gaps that rereading hides.
- Seven habits that turn explaining into better code, from rubber duck debugging to short workshops.
- A realistic path for anyone moving from teacher to developer.
- A four-week plan you can start on Monday.
What Is Learning by Teaching?
Learning by teaching is the finding that preparing to explain something, and then explaining it, helps the explainer learn. The student benefits, of course. The surprise is how much the person doing the explaining gains.
One part of it has a well-known name. In a 2009 paper, researchers Catherine Chase, Doris Chin, Marily Oppezzo and Daniel Schwartz described the protégé effect. People put more effort into learning when they feel responsible for someone else's learning. In their two studies, students taught a computer character, called a Teachable Agent, inside a program named Betty's Brain.
Eighth graders studying biology who believed they were teaching the agent spent more time on learning activities, like reading. They also learned more than classmates who studied for themselves, and lower-achieving students gained the most. In the second study, fifth graders treated the agent socially and were more willing to admit mistakes. The authors suggest that teaching creates a sense of responsibility, and it also cushions your ego when something goes wrong.
You've probably felt this at work. You read the docs more carefully when a teammate is waiting on your answer than when you're only curious. That extra care is the protégé effect, and you can trigger it on purpose.
What the Research Actually Shows
The protégé effect explains the motivation. Four other findings explain the mechanics, and each one turns into a habit you can use at your keyboard.
Recall beats rereading
In a 2006 experiment, researchers Roediger and Karpicke had students learn prose passages in three ways. One group read a passage four times. Another read it three times and then wrote down everything they remembered. A third read it once and practiced recall three times. Their paper in Psychological Science reports what happened next.
- Five minutes later, the rereaders were ahead. They recalled 83% of the ideas, against 78% and 71% for the other two groups.
- One week later, the order flipped. The rereaders recalled 40%, the single-test group 56% and the three-test group 61%.
- The rereaders predicted they would remember the most. They remembered the least.
Pulling information out of memory is called retrieval practice, and it's the engine inside most teaching. When you explain without notes, every sentence is a small recall test.
Teaching without notes is the active ingredient
A 2018 study in Applied Cognitive Psychology, summarized by the British Psychological Society, tested this directly. Aloysius Koh and colleagues gave 124 students 10 minutes to study a text on the Doppler effect. Then each student spent 5 minutes on one of four tasks:
- Teach the topic to a camera without notes.
- Teach it by reading a prepared script.
- Solve arithmetic problems.
- Write down everything they could remember.
A week later, a surprise test showed that the no-notes teachers beat both the script readers and the arithmetic group. Students who simply wrote down what they remembered did about as well as the no-notes teachers. The researchers concluded that teaching helps because it forces retrieval. One caveat: nobody had a live audience, so the study can't show what real questions from learners add.
Expecting to teach changes how you study
Even the plan to teach helps. In a 2014 study in Memory & Cognition, John Nestojko and colleagues told some participants they would teach a passage to another student. Others were told they'd be tested. In the end, everyone took the test and nobody taught.
As Washington University in St. Louis reported, the would-be teachers recalled more of the passage and organized it better, especially the main points. The lead author's explanation is useful for developers. Teachers preparing a lesson, he noted, hunt for the key points and arrange them into a clear structure, and the would-be teachers seemed to do the same. That's the mental move you make when you design a module before you write it.
Explaining exposes what you don't know
In 12 studies published in Cognitive Science in 2002, Rozenblit and Keil showed that people overrate how well they understand how things work. They called it the illusion of explanatory depth. Confidence dropped once people tried to write out an explanation. The illusion was far stronger for explanatory knowledge, meaning how a system works, than for other kinds of knowledge such as facts or procedures.
Code is almost pure explanatory knowledge. It's a chain of causes and effects. That's why you can feel sure you understand async code or a framework's rendering cycle until a colleague asks what happens first.
| Study | What people did | Key result | Habit to copy |
|---|---|---|---|
| Chase et al., 2009 | Taught a computer agent. | More time spent learning, most of all by lower achievers. | Learn with a real learner in mind. |
| Roediger and Karpicke, 2006 | Reread or recalled a passage. | Recall won after a week, 61% vs. 40%. | Close the docs and recall. |
| Koh et al., 2018 | Taught with or without notes. | No-notes teaching beat script reading a week later. | Explain from memory, then check. |
| Nestojko et al., 2014 | Expected to teach or expected a test. | Fuller, better organized recall of main points. | Study as if you'll teach it tomorrow. |
| Rozenblit and Keil, 2002 | Rated, then explained, how things work. | Confidence fell once they had to explain. | Explain before you claim you know it. |
Why Does Explaining Make You a Better Programmer?
Put those findings together and you get a clear picture of what explaining does for a developer. Each effect maps to a skill you use every day.
- Memory you can reach under pressure. Explaining an API or a pattern from memory is retrieval practice. The next time you need it during an outage, it's there.
- Structure before syntax. Preparing to teach pushes you to find the main idea and put the parts in order. Good software design asks for exactly that.
- Honest gap detection. Software is explanatory knowledge, so the illusion of explanatory depth is a real risk for developers. Explaining is the cheapest way to find the hole before production does.
- Care for the reader. Your code's next reader is always a learner, even if it's you in six months. Teaching trains you to write for that person.
This matters more as developers lean on AI tools. The 2025 Stack Overflow Developer Survey asked developers how they learned to code in the past year. Of those who answered, 44% named AI code tools or AI-enabled apps. That's useful, but it also makes it easy to ship code you can't explain.
A good rule: if you can't explain a line to a teammate, you don't own it yet. For ways to use these tools without skipping the thinking, see my guide to AI tools for teachers and students.
What the Classroom Taught Me About Writing Code
The research matches what teaching has shown me about software. Three lessons from my original essay still hold.
Clarity beats cleverness
A lesson that only the teacher understands has failed. Code works the same way. I write software so that the next developer, or a student, can read it and follow it on the first pass. Clear names and small functions in a predictable structure save more time than any clever trick.
Every user is a student
In class, you learn to notice the moment a student gets lost. In a product, that moment is a confusing button or a form that asks for too much. Designing with a teacher's eye means finding those moments and removing them one at a time.
Feedback loops make everything better
Good teaching is a loop: explain, check, adjust. Good software follows the same loop. You ship a small version and improve it based on how people actually use it. That's how I approached OnePlace, a marketplace and e-commerce SaaS for sellers in Pakistan.
If you can teach it, you understand it. If you can build it, you can teach it better.
What Engineering Teams Know About Teaching
In software, teaching isn't a side activity. Developer surveys and large engineering organizations point the same way.
Documentation is how developers learn
In the same Stack Overflow survey, technical documentation was the most common way respondents learned to code in the past year. It was picked by 67.8% of those who answered, while blogs or podcasts came in at 34.8%. When you write docs or a post, you're writing the material other developers actually learn from.
Good docs multiply good engineering
The DORA research program ties documentation quality to organizational performance. In its 2022 data, above-average docs amplified the payoff of every technical practice studied. Continuous integration, for example, lifted performance by 34% for teams with below-average documentation. For teams with above-average documentation, the lift was 750%.
Teaching is part of the job at scale
The book Software Engineering at Google gives a full chapter to knowledge sharing. Its message is that you don't have to be an expert to teach, since expertise isn't an on-off switch. Google's readability process works as mentorship through code review. Around 20% of its engineers take part at any given time. Changes from engineers who hold readability take significantly less time to review and submit.
Seven Ways to Use Learning by Teaching as a Developer
You don't need a classroom or a job title. Pick one or two of these habits and run them for a month.
1. Rubber duck debugging
When you're stuck, explain the code line by line to a rubber duck or a patient colleague. Say what each line is supposed to do. The bug often hides where your words and the code stop matching. Rubber duck debugging works because it breaks the illusion of explanatory depth on demand, and it costs nothing.
2. The Feynman technique for code
The Feynman technique is a popular study method built on plain-language explanation. Here's a version adapted for programming:
- Pick one concept you use but couldn't teach, such as database indexes or JavaScript closures.
- Close every tab. Explain it in writing or out loud, in plain words, as if to a new student.
- Mark every spot where you stalled or leaned on jargon you can't define.
- Go back to the official docs or the source code and fill those gaps. Prove each one with a tiny code example.
- Explain it again, shorter, with one example. Repeat until a beginner could follow you.
Tip: The no-notes rule is the step people skip, and it's the step the Koh study points to. Teaching from a script didn't match teaching from memory. Check your notes after you explain, never during.
3. Write the docs you wish you'd had
Pick something in your project that confused you recently and write the explanation you needed then. A "Getting started" section in a README is a perfect first target. Test it by asking a newcomer to follow it without help. Then fix every place they get stuck.
4. Review code like a teacher
In code review, explain the reason behind each comment as well as the change you want. Ask a question before you give a verdict: "What happens here if the list is empty?" Questions make the author retrieve and reason. They also make you put your own understanding into words.
5. Mentor one person
Offer an hour a week to a junior developer or a student. According to the same book, Google gives each new hire a volunteer mentor from outside their team. Mentors have been at the company for more than a year, so newcomers get someone experienced and safe to ask. You can copy the model in any team or community, and the protégé effect means you'll prepare more carefully than you would for yourself.
6. Teach a 30-minute session
A short internal talk or community workshop adds something the other habits lack: live questions. Software Engineering at Google lists four conditions for when a class works best. The topic is often misunderstood and fairly stable, it benefits from live help, and there's enough demand to run it regularly. For a first session, keep it small:
- Explain one concept in about ten minutes, with very little text on your slides.
- Run one live demo where you write the code in front of people.
- Give one short exercise they try while you watch and help.
- Take questions. Write down every one you couldn't answer, and send the answers afterward.
7. Write a blog post about what you just learned
Write up something you learned this week while it's still fresh. Someone who has just learned a topic still remembers what was confusing, and experts often forget that. Publish it on your own site or your team wiki. Readers' questions become your next round of retrieval practice.
Which Mistakes Cancel Out the Benefit?
Learning by teaching can slide into performing if you're not careful. Watch for these traps:
- Reading from notes. A script skips retrieval. Explain first and check second.
- Trusting the warm feeling of rereading. In the Roediger and Karpicke study, the students who reread the most felt the most confident and remembered the least.
- Only teaching what you know cold. Choose topics at the edge of your knowledge. That's where the gaps live.
- Bluffing through questions. Saying "I don't know, let me check" is part of the method. Software Engineering at Google cites the company's research finding that psychological safety is the most important part of an effective team.
- Stopping after one pass. Your first explanation is a draft. The real gain comes from the second, sharper one.
From Teacher to Developer: What Carries Over
If you're a teacher curious about code, your classroom skills are an advantage. The U.S. Bureau of Labor Statistics lists communication skills among the important qualities of software developers. In its words, developers need to give clear instructions and explain problems as they come up. The same page puts U.S. median pay at $135,980 in May 2025 and projects 10% job growth from 2025 to 2035.
Here's how the skills you already use map onto software work:
- Planning a lesson becomes breaking a feature into small tasks.
- Explaining a hard idea becomes writing docs and READMEs.
- Checking for understanding becomes testing with real users.
- Giving useful feedback becomes reviewing code kindly.
- Spotting a lost student becomes finding the confusing screen.
Be honest with yourself about the gap, though. Teaching skills don't replace programming practice. What makes the switch realistic is steady coding time plus a portfolio of projects you can explain. A practical order:
- Pick one path. Follow a single roadmap, such as my web development roadmap or a 30-day Python plan, instead of sampling ten tutorials.
- Build tools for problems you know. A quiz app or an attendance tracker shows coding skill and classroom knowledge at once.
- Teach as you learn. Publish a short explainer for each concept. It proves you understand it and builds a public record of your progress.
- Improve docs in an open-source project. Documentation fixes are a friendly first contribution, and they show you can write clearly.
- Target roles where teaching counts. Education technology, developer education, technical writing and junior web roles all value people who explain well.
In Pakistan: Teach Online, Build for Schools You Know
Pakistan offers a big audience for anyone who can explain technology clearly. When the Pakistan Telecommunication Authority marked 200 million telecom subscribers in June 2025, it also counted 150 million broadband users, as Profit reported. A teacher who explains code well in Urdu or English can reach learners far beyond one classroom.
Local schools and academies also need software that fits how they work. I built the PSTA platform for the Professional Skills & Tech Academy in Abbottabad, with a course catalogue, online admissions, student logins and verifiable certificates. Problems like these make good first projects for a teacher who codes, because you already understand the users. If you want to earn while you learn, my guide to freelancing in Pakistan covers the practical side.
A Four-Week Plan to Learn by Teaching
Each week below adds one way of explaining. Each also has a simple test, so you know the habit is working.
| Week | What to explain | Format | How you know it worked |
|---|---|---|---|
| 1 | One bug a day. | Rubber duck, out loud. | You catch a bug mid-sentence at least once. |
| 2 | One concept you use daily. | One-page Feynman write-up. | A friend can follow it without asking you. |
| 3 | Your project's setup. | README "Getting started" section. | A newcomer runs the project without help. |
| 4 | Something you learned this month. | 30-minute session or blog post. | You answer every open question in a follow-up. |
Try This Before Friday
Choose one concept from your current project that you use but couldn't explain to a new hire. Close your notes and explain it out loud in five minutes, or write it in 300 words. Mark the gaps and fix them with the docs. Then explain it once more. That single exercise is learning by teaching in its smallest form. It works whether you're a senior engineer or a teacher writing your first lines of code.
If you'd like help bringing these habits into a team, or you're a teacher planning a move into software, you're welcome to get in touch.



