Mob Programming in the Classroom

I’ve been teaching Python to a high school class over a video link as a volunteer for about 2 months. We were stuck in a rut, so I decided to shake it up a little and introduce mob programming. I didn’t tell them it was mob programming, but instead described how we were doing to complete an assignment as a group.

Read More

Unix Users Pay Taxes Too

For some reason, TurboTax online rejects browsers from FreeBSD. It tells you that your browser is out of date, not that you are using an unsupported OS. To do my taxes, I had to fool TurboTax into thinking I was browsing from a Windows machine.

Read More

Connecting Android to FreeBSD 11

I wanted to connect my Nexus 5 to my laptop running FreeBSD 11. My goal was to be able to move files from the phone to the laptop. I did not find clear instructions on how to make that work, so I will share what I did.

Read More

The Visitor Design Pattern

If you come across an instance of the Visitor pattern in somebody’s code and you aren’t familiar with it, you might find it hard to decipher. You might even question the sanity of the implementer. What I want to do here is present the problem the Visitor pattern is designed to solve, and then invent the pattern from scratch in order to solve it. Hopefully this will help you understand why the pattern exists as well as how it works and how to use it in your own code.

Read More

Using Disjoint-Sets

In a previous article, Data Structure, Disjoint-Sets, I described the data structure known as Disjoint Sets and discussed an implementation. In this article I will discuss using this data structure to construct a maze. Then I will explain how this is similar to using Kruskal’s algorithm to find a minimal spanning tree.

Read More

Data Structure, Disjoint-Sets

The most common use I have found for the Disjoint Sets data structure is to determine if adding a specific edge to a graph would form a cycle. In Kruskal’s algorithm, it is used in this way to build a minimal spanning tree. Building a maze is similar to applying Kruskal’s algorithm except we use random edges instead of shortest edges. I’ll discuss how to build a maze this way in the future. This article will discuss the data structure. For previous articles using mazes to discuss programming topics, see Choosing a Data Structure and A Strategy for Initializing Immutable Objects.

Read More

The Impact of an Electric Car on My Electricity Bill

This post isn’t meant to be a cost analysis of driving an electric car. It’s to point out that charging a Nissan Leaf at home has a surprisingly small effect on my electricity bill. The two question people ask my family about our electric car is, 1) how far does it go on a single charge and 2) how much has your electricity bill gone up. This post is about the second question.

Read More

A Strategy for Initializing Immutable Objects

In my last article, Choosing a Data Structure, I created an immutable class. I stated that client code must be able to initialize instances of this class. That initialization is harder than passing in a few variables–some non-trivial logic is involved. In this article we will discuss several ways to approach initialization, with one being better than the rest. A design emerges as it might in real life.

Read More

Choosing a Data Structure

A few years ago my friend Arnold told me that whenever he learns a new programming language, he writes code in that language to solve the same specific problem. Sort of like an extended Hello World. That problem can be stated as follows:

Write a program to generate and print a maze, where each room is connected to every other without cycles.

Read More

An Introduction to C++/CX

C++/CX is a set of language extensions to C++ that was created to make it easier to consume Microsoft’s most recent form of the Window’s API. This API is exposed as a set WinRT classes. These classes can be used from within a variety of languages. While there are some C++/CX features to support consuming WinRT classes, it turns out that consuming them in C++ can be handled mostly the same way as consuming other COM classes. But creating new C++ classes that can be consumed by other languages is harder. These classes are COM classes under the covers, so all the reasons that make implementing regular COM implementations hard still apply: writing IDL, requiring MIDL, implementing IUknown, class factories, and registration. Plus, there are new restrictions on interface definitions, three new methods that every class has to implement (IInspectable), and new activation requirements. C++/CX hides all the COM complexity from the class implementer. The developer can write a WinRT class almost as easily as writing a regular C++ class and, just by designating it as a ref class, the compiler generates everything necessary to consume the class in any other supported language.

Read More

Concurrency in C++ using Parallel Patterns Library

In this article, I present two variations of an algorithm to find the overall average color of an image using C++. First I show a serial approach that uses a basic for loop. Then I refactor the code in several steps to a multithreaded version that will take advantage of all available processors.

Read More

Getting Ready for a Massively Parallel World

In this article, I start with a problem, show a single-threaded solution, and evolve the solution into one that will take advantage of as many processor cores as are available. I use C# and the .NET Task Parallel Library (TPL) for sample code.

Read More

Flickr and AWS

When Flickr announced that they were giving everyone a terabyte of space for their photos, I decided to copy mine to the service. Since I have almost 60GB of 32,000 photos, uploading them from my PC would have taken a long time. Since I already had a backup of my photos on AWS S3, I decided to write a distributed app to run on AWS EC2 to copy the photos from S3 to Flickr. Beyond S3 and EC2, this app also makes use of Amazon’s queuing services: SQS. In addition to parallelizing the work, the app takes advantage of the high bandwidth available to EC2 instances. By using this technique, the time it took to upload the files was reduced from days to hours, with the potential for further reduction by running more worker instances.

Read More