Over the last few months, I’ve become distracted. As anybody who’s ever committed to one project can probably tell you: it stops being exciting. What was once your pride and joy becomes the daily grind. Things get stale. As was the case with me, I suspect that this happens for most people when development of new features ends and the focus shifts to bug fixes.
I became distracted. My mind began to wander to the next thing, which in my case ended up being Haskell. I began learning Haskell, and it was definitely educational. I learned a lot with Haskell, and I plan to stick with it so that when I list it on my resume, I don’t get destroyed on a whiteboard test. Then came The Great Matrix Affair of 2014; I got overwhelmed at school. I spent so much time studying and doing homework that I couldn’t muster up the motivation to program. Things fell by the wayside, as you can see in my blog post output for February. Luckily for me, that is done, and I have the next two months free to program!
What Remains To Be Done?
It’s been a good 6 – 8 weeks since I’ve really focused on DMP Photo Booth, so the first order of business is the figure out what needs to get done. After doing some brainstorming I’ve settled on a list:
Finish The Trigger
I’ve mostly completed the trigger, but it doesn’t work. The button is soldered wrong, and while it was magically working for a while, it has since stopped. I need to fix the wiring issue, and then drill a hole in the box to put it through. After that and maybe a quick coat of paint it will be complete.
This particular task is due by Friday. I have a series of VIP demos coming up, the first of which is Saturday morning. A few of my cousins are coming in from out of town on Saturday to do wedding stuff, and I want to show it off then. While my cousin Allen is an engineer, and can appreciate a breadboard mockup of what will Totally Become A Real Thing, it certainly won’t be impressive. My cousin Laraine will likely be less amused, but I’m sure I’ll get a pat on the head for my “hard work”. Due to this, it’s important that the trigger be done before then.
Facebook Printer Module
The reference suite of modules was planned to be: a Trigger Module using my Arduino implementation, a Printer Module using CUPS, a Camera Module using LibGPhoto2, and a Lua module for each so that modules can be created using Lua. Of these, only the Lua Printer Module remains to be done. Since creating a Lua module is a trivial task (and not terribly important to be honest), this is a very low priority item.
However, the current Printer Module requires a physical printer. This might not always be ideal, since printers are big and heavy. What if you just want to bring a laptop and a camera and have a photo booth? My fiancée is having just this sort of situation; she wants to use the photo booth at her bachelorette party, but who wants to lug a huge printer to a hotel room? To solve this, I’ve promised her a Facebook Printer Module.
The idea is that when
dmp_pm_print() is called, the photo strip will be uploaded to facebook. While I know this sort of thing can be done, I haven’t really researched it much. If it turns out that you have to pay facebook money to get this sort of access, I will find a hosting service that is free. Maybe Photobucket, or Dropbox, or whatever. The important thing is that the photo strips will end up in some central location on the internet so that anybody at the party can download the strip later. Ideally, this central location would be a facebook gallery so people can tag themselvs and be all Web 2.0.
My fiancée’s bachelorette party is in May, so this project isn’t a burning priority. However, this represents the most substantial addition of new functionality remaining to be done, so I plan to work it sooner rather than later. Code will be posted on my Github as it evolves, and like DMP Photo Booth will be available under the GPLv3.
To this point, all my development has been done in Linux. First using Ubuntu, and now using Debian. However, most people don’t use Linux. While Linux is the main target platform for DMP Photo Booth, I have been coding as portably as possible, so it should be little effort to port the application to Mac. Over the next few months, I’ll be making sure it compiles and runs correctly my old Macbook. My Macbook is vintage 2010, as such it is only running Snow Leopard. Therefore if anybody in the audience is a Mac user, and has a current version of OSX, feel free to give it a shot as well and let me know how it goes.
Ideally, my fiancée will bringing the Macbook to her bachelorette party and not my development laptop, therefore this project is due at the same time as the Facebook Printer Module, in May.
Finally, bugs. I need to identify them. I need to squash them. And I need unit tests.
After making a big show about being a good person and doing unit tests, I promptly lost the faith. Soon after implementing those first tests, I made a major change to how I handled errors in my code. Suddenly, all my tests were broken, and I was faced with the choice: rewrite them all, or delete them. After some thought I decided that my tests weren’t that great and that I’d probably change something again and break them all again. So I deleted them.
I’ve got to say, I miss those tests. There has been more than a few times where I’d refactored something and wasn’t sure if it still worked. Sure, it seems to work, but does it really? If I had unit tests in place, I could say with a greater degree of certainty that they do. Plus, “it sounds like a lot of work” is not a good reason not to do something, so it won’t be one for me.
On top of that, I’ll be identifying and squashing bugs the old fashioned way: by trying stuff. I’ve already found a few doozies, and I’m sure I’ll find more. As I find them I’m going to post them on the bug tracker for DMP Photo Booth on Github. I do this for a few reasons: 1) it will provide a public centralized repository of open issues so that I don’t lose or forget about them. 2) I would like others to post bugs here. If I post them here and show that I am fixing them, I feel it will establish confidence that it is looked at and acted upon.
This is due when DMP Photo Booth goes to version 1.0. That is planned to be on June 21, the day of my wedding. DMP Photo Booth will get a good solid night of work as the 80 or so people attending put it through its paces. Assuming all goes to plan with minimal issues, DMP Photo Booth will be declared to be out of Beta. That said, to be truly version 1.0, unit tests must be in place and “all bugs must be fixed”.
Currently, DMP Photo Booth is available in source form only. No end-user ever had to compile Microsoft Office; I don’t feel they should have to compile DMP Photo Booth.
To that end, binary distributions will be available for Linux and Mac when DMP Photo Booth goes to version 1.0.
Got My Work Cut Out For Me
It’s a long list to be sure, but I have 4 months to focus on it. However, I’ve decided that I should spend some time focusing on other things too, so that I don’t burn out. To that end, I plan to spend 1 day per week focusing on learning new technologies, and 1 day per week keeping my old skills sharp.
For new technologies, this means things like learning more Haskell, and other languages or frameworks. Whatever strikes my fancy. For old skills this means practicing with Lua and Java, and maybe even C++ if I’m feeling particularly masochistic that day. This will likely take the form of blog posts on topics relating to these, so stay tuned!
As we all know, real software developers use Unit Tests to help sanity check their code. Like all things, Unit Tests have their pros and cons.
Pro: Good unit tests will help you detect when a code change has broken the build in some obscure way
Pro: Writing them will help you better understand how your code works together
Pro: They will simplify testing to just the click of a button
Pro: You will be one step closer to becoming a Priest of the Temple of TDD
Con: It just sounds like so much work
It is true, unit tests can be tedious to create, and it seems easier to just not do it. After all, while everybody isn’t perfect, I sure am, amirite?
Or, you could just be a good person and do your due diligence in making unit tests. You’ll thank yourself later. I know my very first unit test in DMP Photo Booth uncovered a typo that would have gone undetected for a long time, and likely given me a few gray hairs.
The good news, is that it’s really not that hard. With NetBeans, much of the boilerplate is automated. The even better news is that you don’t even have to come up with some fancy framework to make decent tests. I’ll tell you how!
Creating a Unit Test
First, in NetBeans, in the projects pane, right click the source file you’d like to create tests for. Click
Create Test > New C Simple Test ...
Select the functions you’d like to create tests for, and click
In the next step, there are two fields you need to be concerned with: Test Name, and Test File Name. Test Name is the name of your test package. You can think of this as a folder that holds your tests. I like to call mine [PROJECT_NAME]_tests. Test File Name is the actual unit test source code file. I like to call mine [FILE_TO_BE_TESTED_NAME]_tests. However you configure these fields, you should consider clicking Finish when you’re done.
When you click Finish, a new test file will be created. As it stands, if you run your test, it will always fail. You need to do some configuration.
First things first; each function has a corresponding test function with a signature of:
void test[FUNCTION_NAME] ();
Each test function requires some customization to work correctly. Each test function sets up for, and calls the function it is testing. Your job is to tell it how to do all of this. Give it some test data, and in the
if block, tell it what should be returned. The idea is that if the result check resolves as false, the test has failed.
After you have set up the failure check, you should customize the failure message. You can do this by modifying the end of the printf within the failure message. At the end of the message, you should see a section that says
message=error message sample. This is what is displayed by NetBeans upon a test failure. You should customize this bit to say something useful. Since this is printf, you can use token replacing to customize this. You could probably go with something to the effect of
... message=Test failed, returned: %d\n", result); and be in good shape.
Either way, when you’re done save and close your test file.
Running Your Test
Now the easy part: running your tests. This is as simple as right clicking your project in the Projects pane, and clicking Test. Your tests will run, and if all is well, they will all pass. If not, then you’ve caught an error early.
Either way: mission accomplished!