(Unit-)Testing State of Mind

My mind has been steeped deep in the quagmire of automated testing for the past few days. If ever there were an area of software development where I wished for a silver bullet that I could just load and fire…

I’ve gone from a job where testing was predominantly a lightly automated activity, to a job where large swaths of the testing effort are automated to a high degree. I definitely prefer the latter in principle, if only there were a definitive book of recipes and best-practices to follow.

I enjoyed watching the Pluralsight video on Code Testability; it has the best explanation of what makes testing code hard that I’ve ever seen. The side-by-side examples in which he shows how using dependency injection increased what he calls the “sphere of influence” (or the directly testable surface) of the code was an A-Ha moment for its sheer clarity.

And another video that has gotten lost in the blur in my memory made a great point regarding keeping tests descriptive and linear. Unit Tests are easy to write because they do not branch or loop. They test one thing well at a time, and as a result feel more reliable; being able to read and trivially understand a test is a major strength.

And yet… it bothers me when a lot of the hands-on examples in videos still show how to test an “ArgumentException” type gets thrown. I blogged about exceptions what feels like an eternity ago (Exceptions – 3 specifically), and ArgumentExceptions should not be caught; they aren’t for code to deal with, they are for code to try and avoid at all cost. So why test them? Like… ever?

There are plenty of proto-guides on (unit-)testing best practices, but few if any get beyond the obvious: isolate your test cases, pick structured names, be wary of mocking, test one thing only. But that still doesn’t really give any guidance on what is worth testing. Writing tests is easy enough, writing the right tests, and no more than necessary, is the hard part.

Are there resources out there I haven’t found yet?

pluralsight-logo-orange-500x155-v1

We All Should Learn a Thing or Two

I have been learning like a meth-crazed hamster.

It started about a month ago when I got a Pluralsight subscription at work; I had previously only been exposed to http://www.pluralsight.com in my capacity as manager with team-members that would like a subscription. It is the cheapest yet most valuable training budget you could ever spend on yourself or any subordinates.

Sure, there are bad courses as well. But overall my impression of the 30 I have done so far is that there’s more good than bad. And for the occasional slow speaker, there is an awesome speed control under the gear-wheel of their video player so you can go up to double-speed with anti-squirrel-compensation technology.

I like learning new tech topics by getting shown through an introduction. It’s not that I don’t like reading tech manuals and API documentation, but I have found that far too often when techies start writing it sprawls too broadly and leaves me completely clueless as to what is essential and what are the optional extras of a new technology. I think the written word especially is prone to a feeling that we must be comprehensive at all cost, when most of the time a new entrant just wants a gentle and limited introduction.

As a result I have found the “??? Fundamentals” courses on Pluralsight immensely helpful to broaden my horizons. But I would even go so far as to suggest that managers, whether technical or not, could probably benefit from these fundamentals courses. For the non-technical manager you may have to gloss over some of the techier bits, but courses like Jira Fundamentals or Agile Fundamentals are a great way to follow along with what your developers are talking about.

And another set of courses I have found especially helpful are the “??? Best Practices” ones. Even in technologies I am moderately familiar with a video on best-practices can be a great way to level-up to where the industry is already at. Javascript, Python and Angular, here I come!

So, I strongly suggest you go out there now, get a free 10-day trial, and give it a shot.

You might be as pleasantly surprised as I was.

Surprising use for OneNote

I am spending some time planning out a video to pull together my advice on how to use OneNote for effective meetings based on the fundamentals explained in the Manager Tools podcast.

In the process I have re-listend to most of the meeting related podcast episodes to get a good handle on what the nuances of their advice are, and which pieces of advice came from which episode. I was thinking of just cribbing notes as I played the audio and then leave it at that, but the nitpicker in the back of my brain wanted a better solution.

I love OneNote.
I love how it supports audio recordings.
(And I love it on a Surface Pro even more)

I was thinking I might be able to use the “audio recording” feature to record the podcast as I played it so that my typed notes would be an index into the relevant portions of the audio. If you don’t know what I am talking about here, bear with me, it will all be clear by the end of this post.

Sadly, this approach didn’t end up recording the system sound, so I only had my typing noises from the mic synchronised with the notes. Not much use.

I was almost ready to give up, but then I conceived a different approach that worked out quite nicely.

If you ever had audio/visual study materials that you want to annotate and be able to selectively review, you’re going to love this. And remember, OneNote is freely downloadable so you have no excuses: http://www.onenote.com/

Start with a new notebook, and ideally do not store it in the cloud (pick a “Computer” storage location, not a “OneDrive” one). Two reasons: you do not want to use your bandwidth to sync large media files into the cloud, and it doesn’t allow for files larger than 100MB to be annotated in the cloud.

Step one: Insert a media file into the page
Insert a File from the "Insert" ribbon
OneNote has limited support for file formats, so make sure your media is in a plain format – mp3 and avi work great.

Step two: Pick the Attach option for the file
Attach - I have no idea what Printout would look like
Note that this will embed a copy of the file into your notebook; this is unavoidable, but well worth it for what you gain.

Step three: Select the media and play it
Select the Media and Play it back
By selecting a media file in the page you can access the playback options; start the audio.

Step four: Take notes as you listen as liberally as you need to
Take notes as you listen
As the file is playing OneNote will time-code your writing to the playback position. It is recommended to start new lines for notes when possible to get a finer granularity index.

Once you are done listening to the file and have made all the notes you care for, hover over the lines of your notes. You might notice a little playback icon in the gutter (see last screenshot).

Whenever you press this button, it will start playback of the annotated file at about 10 seconds before you started typing the line. If a note upon review does not make any sense to you anymore, this will give you a very quick jump-point back into the audio at the time you decided to write the note. You can get back to the context in which your note originally made sense to you as the click of a button.

And it even works when you place multiple audio files in the same page. Written notes are attached not only to a timecode, but to the specific file instance that was playing at the time, no matter where it is on the page.

And when you play back the file, it will highlight the lines of your notes at the correct times they were written, so you can see a full-media replay of your note-taking.

And… this also works for video files (avi); playback will pop up a separate video window, but other than that the notetaking and time-coding works exactly the same as for audio.

All you students out there of all ages… you are welcome.

How to make Holidays Work

Being on “leave” between jobs has been an interesting experience. I don’t think I’m too bad at letting work go while I am on leave; I may promise myself to keep track of email or to get a report done, but that is typically wishful thinking.

By the time I am two days in, work “doesn’t exist” anymore.

Which is why I was so surprised that after finishing my last job it took less than three weeks for me to feel more relaxed than I had ever been during leave in the 11 years at the job.

I can only attribute this to the fact the little voice in the back of my head realised this time it really didn’t need to remember anything. And I realised; when I am on leave there is always that part of me that runs through a little mental list of things I need to remember because I am going to need them the day I return to work. Shutting that off makes more difference than I ever would have believed.

I’m not sure there is a concrete lesson in this. I don’t think forgetting everything about one’s job over leave is really an option, but maybe there are ways to get more mileage out of this effect in an ongoing job as well.

It occurs to me that perhaps during the transition of a promotion would be a perfect time to take a break, since that’s the closest to an opportunity to forget the job; just prior to picking up a new one. But still, I doubt I could convince the voice that I really do not need to stress about remembering everything else about the company.

Or maybe I should try the same trick that works for sleepless nights: writing down what I am worried about forgetting. When you write the thoughts milling through your head down, sleep has been shown to follow quickly. Maybe a special “holiday notebook”, note down everything to remember and then stop thinking about it? And don’t plan on doing anything work related at all of course!

Or as a last resort… maybe resigning and getting re-hired around every break is a way to get the same effect ultimately… bit of a leap of faith though.