The program that I'm most proud of
Once I thought that to be a successful programmer I have to make complex programs. At the time examples of such programs for me were things like game engines. Those are typically pieces of software which run close to the metal, which need to be highly optimised, which use quite sophisticated algorithms and in the end they produce cool games. Of course, making one of these is not a simple task at all, but I was very keen on eventually doing it. And I had a few attempts of writing a game engine in C++, but neither of them were anywhere near being a complete products. However, I learnt quite a lot in the process and they are still on my GitHub, so you can even check them out if you want. Here, here, and here.
But since I haven’t actually completed any of these, it frustrated me sometimes. Am I not good enough? Will I ever become a good programmer if I cannot make these complicated programs?
And then something happened, which made me change my point of view. Let me explain some background first. My wife is a physics teacher in a high school. When making assingments for her students, she defines the maximum amount of points that a student can collect for this assignment. Then when checking the assignment, she counts how many points a student has actually obtained, calculates the percentage, and this percentage gets converted to a mark. Here in Poland marks go from 1 to 6, with intermediate values like 1+, 2-, 2+, 3- and so on. And when I saw how much time she spends on doing all of these calculations, I realised that I can automate that pretty easily and save her a great deal of time and effort.
So I got to work. The first solution that I thought about was to use Google Sheets. First I needed to create a table with marks and assign percentage ranges for each of them. Next I can calculate actual points for each mark. And finally, write a simple function that given a number of points, would return a final mark. The final result looked like this:
And here is the code for the “program”
function MARK(points, ranges, marks)
{
if (ranges.length != marks.length)
{
throw "Invalid ranges. Marks should have the same number of rows as point ranges";
}
var maxPoints = ranges[ranges.length - 1][1];
points = Math.max(0, points);
points = Math.min(maxPoints, points);
var percentage = (points / maxPoints) * 100;
for(var i = 0; i < ranges.length; i++)
{
var minValue = ranges[i][0];
var maxValue = ranges[i][1];
if (points >= minValue && points <= maxValue)
{
return marks[i];
}
else if (points < minValue)
{
var fraction = percentage - Math.floor(percentage);
return fraction >= 0.5 ? marks[i] : marks[i - 1];
}
}
throw "No valid mark found";
}
As you can see, it’s totally trivial. But when my wife started using it, for her it made a difference. It became much easier and less time consuming to calculate the marks. And her gratitude for this made me extremely happy. This was the first time, when I actually saw a person using my program and being happy about it. And the fact that this person is my beloved wife made this feeling even stronger. From that moment on, I don’t feel that I have to make something super-complex anymore. This joy of knowing that my program solves real problem of real people is what I’m looking for now.
Since that time I’ve already made two iterations on this spreadsheet to fit it more to the workflow of my wife. Continuing the topic of small but useful programs, I’ve made one for Raspberry PI, which is meant to provide access to its camera module via local network. My wife and I then used it to watch our pet rabbit from a different room. It’s also available on GitHub here. And right now I’m working on a project that is bigger, but also should provide a considerable value. It’s an application that will allow to work with pull requests on GitHub repositories from the terminal. It’s not finished yet, but I try to work on it regularly and actually finish it soon enough.
So if someone asks me today, which program I’m the most proud of, I’ll tell them about that spreadsheet script. And even though at this point I’ve actually done some hardcore coding, mostly at my job, I’m still most satisfied with these small programs that make somebody’s life easier.