Created: 2015 April 27 19:06
Time to read: 4 minutes
The first day of Lone Star 2015 was devoted to training. The workshop track I took was geared towards unit testing.
One reason I took this workshop was so that I could become more familiar with mocks. I had a mental block when it comes to mocks and had a hard time seeing their value. After taking this workshop and talking about mocks with Matt, I can see and appreciate their value. Mock the things we don't directly test (ex. database connections, sql queries, filesystem i/o, etc) to speed up the individual unit tests. Mock the things we don't directly control (ex. 3rd-party API, access to another server on our network, etc) since we don't want to fail a test due to a temporary connection error.
What I loved about this workshop was the easy-going manner in which Matt got us to embrace unit testing and mocking. Matt even provided a git repo for us to clone in order to get started on the fun part of the workshop. Mocking was definitely covered in the interactive part of the workshop.
Unfortunately, our getting started on the interactive portion of the workshop was delayed due to poor wifi signal. By the time most of us were able to get the git repo cloned and run
composer install, we only had time to do one of the two mocking exercises. Yet, since I still have the repo cloned on my machine, there's no reason I shouldn't be able to finish the workshop at my leisure.
I have done kata before and am a proponent of using them to strengthen knowledge and skills, so this was a workshop I had mentally signed up for as soon as I heard it was being offered.
Rabbi Yitzchok Willroth (aka "CodeRabbi") leads his audience with gentle enthusiasm through an intellectual exercise replete with philosophy and references to psychological studies. During this workshop, Coderabbi had a few friends (luminaries of the PHP community, really) float around to offer guidance to the perplexed during each kata exercise. Their assistance was much appreciated.
The kata we worked on was Conway's Game of Life. We did not have the remainder of the workshop to work on this kata. Instead, we had 30 minutes (you read that right) to work on it. Since this is not something one can learn the rules to and code in a sitting, this seemed unfair -- like being told that the Couch-to-5K program we were going to follow is to get off the couch and then run 5 kilometers in 30 minutes. As you can imagine, the beginning runner will not complete 5K in 30 minutes, but eventually will with repeated practice. So, too, can one eventually completely code the Game of Life in 30 minutes with repeated practice. What seemed unfair initially, was really a challenge to us to improve, continuously.
One aspect of this workshop that I enjoyed was that at the end of every 30 minute sprint, we were to discard our previous work and start fresh, but with a new constraint to keep our minds sharp. So the second sprint's constraint was to pair up with someone else and see what we could do together. After 30 minutes, the constraint was to make the Cell or Organism (whatever we called it) class not maintain state.
There were times in these kata exercises in which I felt frustrated or angry. Good! For an intellectual exercise, this is the equivalent to feeling muscle strain and soreness in a weight-resistance exercise.
I enjoyed the intellectual exercise of making the Cell Class stateless in that it gave my pair-partner and me the opportunity to discuss what that meant and how to deal with that constraint. We didn't end up with more than an incomplete sketch (in the form of code), but it got our brain juices flowing.
I plan to play with this kata some more on my own and will add additional rules to perhaps mimic competing organisms in the same space. Or, what if one of these organisms has a completely foreign set of rules (like, perhaps cancer cells)?
We started with a Composer-based PHPUnit skeleton and a complicated kata. We ended up with a newfound respect for the squishy gray stuff between our ears.
This was the first year that Lone Star PHP had a day devoted to training. The problems we all shared with wifi were frustrating, but overcome personally by my attendee-coworker with a call to our IT department to turn on the ability to hotspot our phones (thanks, Darren!). A glance at all the Wifi access points at the conference center showed that we were not the only ones to do this. But really, for the workshops, wifi wasn't important except for at the beginning of each workshop so we could clone git repos and run
The night before the workshop, I had built a vagrant box exclusively for use at the conference. Juan Treminio's (a speaker at Lone Star PHP 2014!) Puphpet tool proved to be invaluable for this purpose. Had I been aware of the need to clone git repos and get the required components installed via composer, I would have done so ahead of time.
In short, the workshops were great, yet too much time was wasted by all in doing something that takes maybe a minute on the office or hotel wifi but takes for-frikkin-ever on a shared conference wifi. I would like to see more notice next time for required environments so we can hit the ground running. The topics were great, and I would have loved to have been able to attend them all!
This site is built using Gatsby, TailwindCSS, and a whole bunch of other fun stuff.
Corrections or curious to see how this was put together? Check out the latest version of this site at its github repo.