Algorithms on a Napkin

When I have trouble figuring out an algorithm I usually opt for a diagram in a program like Dia or on paper. A few days ago I was having a difficult time getting room saving to work properly in Constellation so I decided to draw it out. This time I didn’t use a flow chart or a diagramming program, I just used a napkin. In a few minutes I had sketched out the entire algorithm as it was going to be used in the program instead of building a set of flow charts I would only use once.

I didn’t need a big flow chart and a detailed plan of the algorithm, I just needed to see it. The sketch helped me visualize the steps. It let me refine the idea as I was working through it and spotting design flaws. Sometimes that’s all you need – A pen and paper to be your (very useful) rubber duck.


Fun With Ruby

A few days ago I decided to work on a project just for fun. I called it Constellation because it sounded cool. I had no big plans or expectations for the code, I just wanted to have some fun with it for a few hours. I decided to use Ruby and try to see real results in one night. Usually these little projects don’t turn into anything and I toss the code into an “archive” to reference a couple of times a year, but this one’s different.

Writing my own text-based game engine is something I have wanted to do for a long time. I’ve played MUD‘s off and on for years and there’s something I like about text adventures. It’s like comparing reading a book to watching a movie; it’s a different experience. There is no lag, no glitchy physics, flickering textures or any of the other problems that graphical games can have to break the player’s immersion. Imagination can create more moving visuals than the most advanced rendering technology. Continue reading

Why Should You Use Getters and Setters?

Some people aren’t very fond of accessors and mutators. On the surface they seem like needless functions, a waste of code when a simple class.variable would suffice. Some variables really are better off being set with variable = foo than with a mutator. On the other hand, other data types have such complex initialization procedures it’s easier to pass values into a mutator. C++’s maps are a good example of this kind of situation. Which is easier, std::map.insert(std::pair<Foo, Bar>(var1, var2)); or SetMap(var1, var2);?

Continue reading

Use a Library or DIY?

This question comes up a lot when planning (and working on) programming projects. Should I use a library for this feature or just write the code myself? It can be applied to almost every section of a project. There are so many libraries and frameworks out there that you can probably get a prototype working just by gluing together third party code. There are a few factors to consider while making the decision.

Continue reading

A Brief Introduction to Type Systems

Types provide a way to abstract data. 1 isn’t a collection of bytes in memory, it’s an Integer. Without types programmers would still be shuffling bits in memory. Types bundle up those bits and bytes and give a specific kind of collection of bytes a name. As with every system, no one can agree on a single way of working with types.

Continue reading

Why I Overhauled My Rails App’s Tests

When I started the application I was very new to both Ruby and Rails. The tests I wrote were OK. They worked, they tested the code, but they weren’t very good. All of the tests ended up being request specs using RSpec and Capybara. They were very slow; fifty tests ran at around 200 seconds. In the last few months I have learned a lot about Rails. The application itself has been updated incrementally to reflect what I have learned, but the tests were neglected. It was time for a change.

Continue reading


TaskWarrior is a fantastic cli todo-list manager. I usually tend to use minimalistic tools, but sometimes the best option is one that has every feature you could possibly need. Setting due dates, priorities, adding notes and a ton of other task-related things are simple once you know the syntax.

You probably won’t use every feature in the tool every day, but it’s easy enough to type “task help” and find what you need. There are a lot of ways to filter the commands and get exactly what you want from each command. Analyzing your progress on different projects or just your progress in general is easy with TaskWarrior’s analytical options.

Continue reading