Code Katas: The Secret Practice That Turns Good Developers Into Great Ones
Nov 30, 2024Musicians practice scales to captivate audiences.
Basketball players sharpen their shots with drills.
Chess players master tactics to outthink their opponents.
Actors rehearse to deliver unforgettable performances.
But how do Salesforce developers level up?
The answer might surprise you.
In The Pragmatic Programmer by Andy Hunt and Dave Thomas, the authors take the concept of a "kata" from karate and apply it to writing code.
In martial arts like karate or kendo, katas are sequences of movements practiced repeatedly to perfect form, discipline, and technique.
The idea is not just to memorize the sequence but to internalize the principles behind the movements.
This concept of deliberate, repetitive practice aligns well with the iterative and skill-based nature of coding.
And so, the code kata was born.
Code Kata: A few lines of code that are practiced repeatedly to perfect form, discipline, and technique.
Below is an example I've been working on this week:
This Apex class is a mere 18 lines of code, and only 14 if you take away the line breaks.
Now, look how many concepts are present:
- Class Declaration
- Method Declaration
- Collections (Set, List, Map)
- Control Structures (For loop, Ternary Operator)
- String handling
- Counting Logic
- Duplicate Detection
- Debugging and logging
- Type Initialization
Nine distinct coding concepts by my count. That's a lot!
By simply rewriting this Apex code once a day, you gain repeated exposure to the building blocks of writing Apex.
Why Code Katas Work
- Muscle Memory for the Mind: Just as physical katas build muscle memory, code katas train the brain to recognize patterns, solutions, and pitfalls in programming.
- Safe Environment for Experimentation: By solving the same problem repeatedly, developers can experiment with different approaches, frameworks, or optimizations without fear of failure.
- Focus on Fundamentals: Code katas emphasize core principles like loops, recursion, testing, and algorithm design, which are critical for all programmers.
Now that you understand the power of code katas, it’s time to take action. Pick a code kata to practice—whether it’s the example shared here (available to copy paste from this Github repo) or another small, focused exercise.
Commit to rewriting it daily for a week and notice how your skills sharpen with each iteration. Repetition is the path to mastery.
And if you don’t write code but work with Salesforce flows, the principle still applies: find a repetitive practice to internalize flow-building fundamentals.
For instance, take a common automation scenario—like updating related records or sending notifications—and recreate it from scratch daily.
Over time, you’ll develop the intuition and skill to tackle even the most complex flows effortlessly.
Practice doesn’t just make perfect—it makes you better every day. So, start your kata, and let’s see where deliberate practice takes you.
Best,
Nick
SalesforceĀ Saturdays
Join the Salesforce Saturday newsletter. Every Saturday, you'll get 1 actionable tip on Salesforce technology or career growthĀ related to the Salesforce Industry.
We hate SPAM. We will never sell your information, for any reason.