Yesterday, the day before Thanksgiving break, was a really quiet morning. I could write about thanksgiving, something about the Spanish perspective, but we had a funny afternoon and I prefer to talk about it.
We had lunch around noon and we talked about our annual “Trivia Tournament”. The rules are simple: each of us writes at least five questions; a “referee” mixes the questions into a single PowerPoint and hides the answers. During the tournament, the referee presents the questions and scores the players: one positive if the answer is correct, one negative if the answer is incorrect. There are three winners: who has the most positive points, the most negative points, and the most total points (positive plus negative points).
In previous tournaments, we counted the scores using the whiteboard, the same where the presentation was projected. It was simple, but it did the job. Then, at lunchtime, we had a simple idea that change everything: “it would be great if we could use a smartphone to scores the players”.
I remembered “Back to the Future” and Marty McFly: “you’re a chicken”. Nobody called me “chicken” (“No tienes…” in Spanish). The challenge was on!
I started at 1 pm creating the MySQL database. It’s really simple, just a table where each row defines a player and their positive and negative scores.
The next step was to create the web application. I decided to use Java EE because we currently have a developer server running a Glassfish instance. The app reads the database using JPA, has the controller written in EJB, and provides the data through RESTful.
Because I wanted to prevent attacks to the server, I created a realm in the server, secure https, and signed certificate. We have potentially hackers in house with 'sudo’ powers, so we’re still having security problems, but, it this case, I can detect who is cheating the scores.
Once the server was running, and after a coffee, I started to program the iPhone application. I decided to use Swift for this part, and wrote the code using Xcode, awesome software. The programming part just flowed, and it was done in less than a couple hours.
After four hours we had the database, the server and the smartphone app running and communicating between them. The next step was to create the leaderboard. To do this, I created a simple web page using angularJS, which we can present in a monitor closer to the whiteboard.
Finally, I did it. We have the “Trivia Tournament” application ready to work. I will release the software after the tournament because I don’t want to expose the application security during the tournament.
The source code: