Why coaches should learn to code.

Alan Couzens, M.S. (Sports Science)

July 5th, 2016

A little while back, I remember seeing a twitter poll that made my ears prick up. I wish I could remember who posted it (maybe if you’re reading this, you’ll give me a nudge), but the question of the poll was directed to coaches and it was something along the following lines…

What new skills are you going to learn this year?

  • Data Analysis
  • Communication/Sports Psychology
  • Biomechanics
  • A computer programming language

2 of the skills were data/computer related (incidentally, data analysis won by a landslide) – a good indication of where things are heading! No matter your domain, no matter your ‘job’, chances are data and computers are a part of it & if they’re not now, they soon will be to an ever increasing degree!

The poll caught my attention for a couple of reasons…

  1. Because learning to ‘code’ computers is my own current obsession
  2. I kind of figured that my weird interest was unique to me, at least among my coaching peers.

In a previous post on data analysis for coaches, I threw out the ‘off the cuff’ comment “While it may be too much to expect coaches to learn a programming language…”

Well, that tweet got me thinking, maybe it’s not!

'Coding' is no longer the exclusive domain of programmers and app developers. Today, we all face a common challenge of making sense of the mass of data that comes at us on a daily basis. Because everything is computerized, there are stats and data available on ALL interactions & transactions. If you have the skill to understand and make use of that data, you have a distinct advantage in the modern world -- something that is explored on the general level in this great post on "why are you learning to code?"

"The best reason why you and the rest of the world should, or rather, needs, to learn how to code is not for building websites or mobile apps, but for the purposes of understanding and making use of all the data surrounding us. It’s in data analysis, and more recently, in data science, where the need for coding goes beyond the normal scope of an engineer and into a marketer, a sales professional, or a manager..."

...or coach! In this world of big (& ever growing) athletic data, even coaches need new skills. I have been amazed by the world of questions and answers that opened up by being able to ‘chat’ first hand with a computer containing my athlete’s data. If there is a particular metric that I want to look at that’s not covered by the big coaching software, rather than begging them for the feature, I just code up a little script, go to my database & bingo-bango, the information is in front of me in whatever form I want… tables, charts, you name it.

As the tweet says, building the thing that you wish existed sure beats the alternative of spending your time whining about all of the things you wish that the current software included on the internet forums. You can put your time to better use...

For instance, let’s say we want to answer a simple, very practically applicable question…

What TSB was our athlete, John Smith at each time he got injured?

Coding up a simple script to answer this question is as simple as…

$query = “SELECT * FROM athletedata WHERE name=’John Smith’ AND tag=’Injured’”
$result = mysql_query($query)
$rows = mysql_num_rows($result)
For $i=0; $I < count($rows); $i++ {
echo “TSB: “.(mysql_result($result, $i, ‘TSB’)).” <br/> ”;
}

In 5 lines of code, I get my question answered and can use that information proactively when planning John’s next season.

If I wanted to answer the same question for my whole group of athletes, I’d just leave out the name=’John Smith’ bit.

The above is only one example. On a daily basis, questions will pop into my head that can easily be answered by 'having a chat with' my database...

  • What is the average annual volume & intensity of all Kona Qualifiers? What’s the standard deviation in those 2 variables for the group?
  • What is the relationship between HRV & frequency of illness in my training group?
  • How does swim performance change with changes in stroke length/rate for a given individual?

Literally, anything that the athlete’s ‘wearables’ record (these days – A LOT of data!) is fair game. In this day and age, it's no exaggeration to say that the only limits to the queries we ‘ask’ our data are our curiosity & our imagination!

In the modern era, the answers that we seek aren't going to be found in the '12 week, n=10 college-aged male' journal studies (although, with a bit of code, we can scrape them too!). Much better answers are going to be found in the masses of real world data that we now have from 'real life' athletes. Data just waiting to be 'mined' & all it takes is learning a few new skills.

While playing with & learning from ‘big data’ is cool, computers can also help A LOT with the less exciting daily grind. Many of the less fun aspects of coaching (or any job, for that matter!) comes down to boring tasks that, frankly, aren’t making the most of your coaching chops. Tasks that can be done really well by a computer e.g….

While crafting an individual program is a critical ‘custom process’, the task of actually typing that plan into workout ‘boxes’ is a huge time suck for coaches who use web based delivery. Trust me, I've seen coaches give up on the game entirely because they became so fed up with the amount of time spent in mindless data entry and 'box dragging' in front of a computer screen. Actually, the same could be said for the ‘old school’ coaches who write those plans in a note book. How many times do we manually write/type the word “Warm Up:” or “Main Set:” or even the phrase “Do x reps at y watts with z recovery”? The x, y, z are the critical bits, the rest is filler that can be ‘delegated’ to a program so that you can focus more of your time on the best x,y,z for that athlete.

Putting this in (php) coding terms…

echo “Do “. $Reps.” at “.$Power.” Watts with “.$Rest.” Recovery between reps”;

Here, the program automatically writes all the filler words and leaves you to focus on determining the variables (the words preceded with a $ sign) It really can be that simple! In one line of code all of a sudden you’ve cut your typing time in half! That’s the power of code!

And, you don't even have to manually enter the variables! A lot of coaches will program generic assignments in the interests of saving time that put the onus on the athlete to remember a bunch of zones, e.g. 'Do a 2hr ride in Zone 1-2'. Well, with zones changing on a regular basis, keeping track of all current swim, bike and run zones for power, pace and heart rate is a lot for an athlete to juggle! There's a better way that won't put a lot of undue stress on you or your athlete...

Assuming for example, that our athlete's current zone 1 & 2 numbers are 200 & 220W, wouldn't it be easier if we left it to the computer (rather than the athlete) to store this information in it's memory and then just called it in the text any time we want to reference it? e.g....

$Zone1=200;
$Zone2=220;

echo "Do a 2hr ride at ".$Zone1." to ".$Zone2." watts";

This will produce "Do a 2hr ride at 200 to 220 watts"

Much better than the generic 'zone 1 to zone 2' that puts a burden on your athlete to remember every single zone. And much more efficient than manually looking up & typing in the actual numbers every time we build a workout for that athlete!

The above represent very basic examples that illustrate the ‘real world’ benefit of learning to code: Teaching a computer to filter large amounts of data and to automate your more mundane tasks frees up a lot of time that can be devoted to the very best of human skills – learning, creativity & understanding your athletes as individuals!

So, why don’t more coaches do it?

Well, I think the perception is that it’s hard &, I think we all have a bit of a tendency to fall into the ‘can’t teach an old dog new tricks’ mind set. But, speaking as an old dog that learned a completely new trick, I can tell you that in this day and age, with the resources available, it’s really not that hard and it’s actually kind of fun!

Actually, I lied above about the ‘completely new trick’ part. I remember 'a few' years back, as an excited 10 year old at Christmas, getting my hands on a state of the art Dick Smith VZ-300 PC (pictured left)– a beast with a 3.5 mHz processor (vs ~3000mHz of my current unit!), 16KB of memory (vs ~1,000,000 KB of my current laptop!) & an old black and white TV as a monitor! :-) I spent many hours in front of that writing (& debugging!) Microsoft BASIC code. Building things like a Tic Tac Toe game, a Las Vegas slot machine & my first foray into A.I. – a simulated psychologist named Eliza. As a ‘different’ child, she was very helpful :-) Incidentally, I’d save all of these creations, not on a floppy disk, but on a regular cassette tape! Yeah, let’s just say it was a bit of a lag between there and where I picked up programming 3 decades later & things had changed a bit!

So, assuming I’ve whet your appetite & convinced you of the value of picking up this skill, both in terms of the information it will give you access to & the time (& boredom) it will save you. And, furthermore, that, with the tools available nowadays, learning to code really isn't that hard, we're left with only one question: How do we get started?

1. Start by getting a good handle on html & CSS

HTML (hyper text markup language) & CSS (cascading style sheets) are the language of your webpages. Your browser interprets the html markup to determine how things are displayed on a web page. Why start here? Because the world (literally) lives on the web! If you’re a coach wanting to get data or communication from your athletes (or to your athletes), it will likely be entered on a web page. Understanding how it is entered and being able to code pages to enable this information to be entered is a high priority.

Resources to start with:

  • Codecademy – www.codecademy.com offers free interactive tutorials in a number of languages & they’re great, extensive & addictive! Check them out.
  • HTML5 – The missing manual. My fave book on HTML5. The missing manual series dives into each topic in a lot of depth but with a really easy going, conversational tone that is easy to understand and a pleasure to digest. Highly recommended.
  • CSS - The missing manual - another great read from the missing manual series

2. Rent yourself a cheap hosted server for ~$5 a month from any number of web hosting companies (e.g. Hostgator, A2, Bluehost etc) and start playing around with a server side language like PHP.

HTML, CSS (& the web scripting language of Javascript) are primarily ‘client side’ meaning, for the most part they code information to be displayed in your athlete’s browser. If you want to get information (or training files) from your athlete and view and store them on your side, you need a ‘server side’ language like Python or PHP.

A lot of the data analysis benefits of learning to code come down to ‘getting your hands on’ lots of raw data. This is where server side languages come in.

I tried both PHP & Python on ‘for size’ in the beginning but went with PHP because, well, it was considerably easier for me to understand. This might be a personal thing, but PHP just spoke much clearer to me & I found some great books (below) where this was especially true. Very easy to follow & clearly written for beginners. I personally found this to be less the case for Python, at least at the time. I don’t regret that decision. PHP is a great language for teaching you about how to get information from a webpage to your database, where you can then pull from it and look at it in any way you want. This, as I said in the intro is what makes it so cool and so useful to us as coaches. Whatever data you want, with PHP, you can write a script to access it.

Best resources for learning PHP..

  • Codecademy -- yeah, I'm addicted! :-)
  • The Joy of PHP -- Great, easy to read starter book
  • Learning PHP, MYSQL, JavaScript -- Still easy to follow, but a bit more in depth. My 'goto' reference
  • W3Schools.com -- fantastic, easy to understand website with simple tutorials on everything (HTML, CSS, PHP etc)

#####

Recently, I’ve started to revisit Python for a couple of reasons. Probably, the largest of which is that I just love learning new stuff :-) but Python does have a couple of niches where it really excels. Not the least of which is the number of academic institutions making use of it – top level universities, Google, NASA(!) etc. so you’re getting a lot of really smart people building code in and around python- building modules that specialize in math, statistical analysis & modeling data (extending to machine learning). This means you don’t have to re-invent the wheel. You can just import them & ‘plug & play’.

That said, IME, Python is not (currently) as ‘web friendly’ as PHP (less hosting companies fully support it & web-programming tends to center around somewhat complicated frameworks like Django). Given the importance of being able to quickly and easily read and write to the web, I’d still stick with the path I outlined above.

Until the next language (probably something a little closer to the composer like Java or C). Before too long, I’ll be blogging in 1’s and 0’s :-) Take up the challenge and…

Coach smart,

AC

  

Don't miss a post! Sign up for my mailing list to get notified of all new content....

  

Have no fear - I won't spam you or sell your info.