Do Not Copy and Paste Code!

If my coworkers read the title they’d think my blog got hacked. I can almost be called a proponent for copying and pasting code. I don’t encourage it but I do do it quite often. My philosophy is: copy and paste code, pay attention, and fix whatever problems you introduce later That is until now. So far, the worst thing copying and pasting code has done is introduce bugs. Today, copying an pasting code caused data loss.

I wanted to take the logic I have in the task classes and use it for contexts. I decided to create corresponding context classes and copy functions from the the task classes to the new context classes. It worked. However, I missed replacing one occurrence of task with context. Probably the most important and impactful one. When persisting data in an iOS app you specify the file path where you want the data to reside. I forgot to replace the word “Task” with “Context” which caused the list of contexts to be written where tasks are. Good thing I have my tasks saved somewhere else. This mistake has taught me a valuable lesson. Fortunately it happened in a personal project and not a work one.

Will I stop copying and pasting code? Probably not entirely, no. I will, however, be more careful, do it more sparingly, and probably not do it at all in critical areas.

Goals for tomorrow are: Add the ability to link tasks to contexts, and finally get around to storing urgency, importance, and effort.

UX and Dogfooding

I woke up this morning thinking “I need to focus the task text box when opening the new task screen”. It’s minor, it’s not significant, and I’m not sure it would annoy many users if that feature wasn’t there. The reason why it matters though is that part of Getting Things Done® (GTD®) is called a brain dump where you are encouraged to dump everything on your mind into your system to be reviewed later. Brain dumps involve adding multiple items in a row; saving users a click per item could make the whole experience a lot smoother.

I didn’t sit down and think “OK, how can the UX be improved?”, it simply popped in my mind. The reason I think is that I use the app a lot while developing it. If you do something over and over again, eventually the little annoyances start bugging you which makes them surface to your consciousness.

This feature took me less than 5 minutes to implement but I believe it will have a significant impact to users. In addition to that, I managed to meet my goals for today: Outside Tasks now allows you to add, edit, and swipe to delete tasks. Additionally, the tasks are now persisted across sessions! I didn’t get around to implementing urgency, importance, and effort editing though.

My goals for tomorrow are: implement urgency, importance, and effort; allow users to swipe right to mark tasks as completed; and allow users to add, edit, and swipe to delete contexts.

I don’t know if the app will have every feature I want it to have by Friday but it will be in a state that allows me to move my tasks to Outside Tasks before my OmniFocus trial expires. I will of course keep a back up somewhere in case I mess something up.

For some reason, Apple’s Start Developing iOS Apps (Swift) guide seems to be wrong. This answer on Stack Overflow provided me with the correct way to implement the cancel button.

GTD and the Eisenhower Matrix

Woohoo! First project to get a post other than the initial post introducing it!

After a day’s worth of work I am able to add tasks to a list of tasks in the Inbox tab. Doing a bit of research about what attributes I should have for each attribute I decided on urgency, importance, and effort. I am contemplating suggesting priority based on these 3 attributes but I can’t find any sources that provide a deterministic way of calculating priority. The Eisenhower Matrix determines what to do about each task based on its urgency and importance which seems to fit the Getting Things Done® (GTD®) model.

  • High importance and high urgency: Do now. These become the next actions.
  • High importance and low urgency: Schedule. These can be scheduled in the calendar.
  • Low importance and high urgency: Delegate. These are delegated and then move to the Waiting For section.
  • Low importance and low urgency: Do later. These go in the Someday/Maybe section.

This system is great but there are two flaws in it:

  1. It only supports low or high urgency/importance. I would like to have the ability to leave tasks on medium urgency/importance if they really are neutral.
  2. It does not take effort into account.

I will think about this some more but it is going to be one of the last things I do.

My focus for tomorrow will be: storing the urgency, importance and effort for each task along with its name; editing and deleting tasks after they’ve been created; and possibly data persistence.

This tutorial was very helpful: Storyboards Tutorial in iOS 9.

Project: Outside Tasks

When I was an undergrad at Trent University I used Google Tasks to organize my to dos including my assignments, quizzes, and exams. Since then, I read Getting Things Done (non-referral) by David Allen which I really liked and I started following the philosophy in organizing my to dos. I also followed the official Evernote for Mac Setup Guide and used Evernote for my to do for years.

Recently, I started looking for a more sophisticated solution for my to dos. In particular, one that is compatible with the Getting Things Done® (GTD®) system, one that has task dependencies, and one that allows me to check tasks off through a Today widget on my iPhone.

I explored multiple options including OmniFocus, Nirvana, and Asana. Sadly, each one had something missing from my requirements list. Either they don’t support task dependencies, or they don’t have a Today widget, or they had everything but they looked terrible and had a really bad UX. That is why I set out to build my own simple to do iOS app!

Before discussing what the app does, here’s a simple introduction to the GTD system. It’s very simple, at least how I use it.

Getting Things Done® (GTD®)

To start with GTD, try to think of everything you have in the back of your mind, if it is something you can act on and it’s something that you can do in less than 2 minutes, then do it right now. If it would take longer than 2 minutes, then either delegate it to someone else and it goes in a Waiting For list, or you defer it. If you defer it then it’s either something you schedule for later (just use your calendar), or you put it in a Next Actions list that can be organized by context (phone call, computer, home, office, etc…) so that whenever you have time to get some things done you go to the context that applies to you now and perform some of the actions that are under that context. You can also stash things in a Someday/Maybe list for things that you want to do someday but are not immediately relevant. Finally, you can store things in the Reference list for things that you simply want to store for later.

You can also organize actions into projects. Projects are outcomes that require multiple actions to complete. GTD recommends reviewing things periodically and updating projects with the next applicable action. I would like to avoid having to do that by planning a project ahead and enqueuing tasks by deferring them until a prerequisite task is done.

Outside Tasks

Here’s my vision for Outside Tasks for now:

  • Data should persist across sessions (duh!).
  • Tasks will be used for actions..
  • Projects will simply be tasks that have been marked as projects and/or tasks that have subtasks in them.
  • Contexts will be tags on tasks.
  • Tasks can be deferred until a certain date.
  • Dependent tasks will be implemented by allowing for tasks to be deferred until another task is complete.
  • The Today widget will show all tasks that are currently actionable.
  • Tasks can be checked off through the Today widget.

Bonus feature:

  • Tasks can be linked to Evernote notes.

Here’s the kicker: I’ve already put all my to dos in OmniFocus before realizing it doesn’t support task dependencies and my free trial expires in 7 days which means that I have 7 days to get this app to a usable state!

Next steps: I have to finish reading Start Developing iOS Apps (Swift). Right now I’m on Implement a Custom Control.

Project: Motorized Blinds

Introduction

My current apartment’s blinds have a ball chain to raise and lower them. There’s a gear at the top that the chain turns which in turn turns the rod on which the blinds roll. If I put another gear at the bottom and turn that with a motor, that would open and close the blinds.

Motivation

I like to sleep in total darkness but since I have to wake up early, it is nice to have the blinds open so sunlight can get in in the morning and help wake me up. Until now I have been leaving the blinds open all night which lets light in. Having motorized blinds would allow me to leave the blinds closed all night and have them open automatically in the morning. Additionally, I open the rest of my blinds in the morning and I close them when it gets dark, I plan on automating this so I don’t have to do it manually.

Implementation

The plan is to use a Raspberry Pi to act as a hub where I will install Homebridge so I can control it using the Home app on my iPhone. The individual blinds will be controlled using an Arduino which the Raspberry Pi will communicate with using Wi-Fi. The Arduino controls a stepper motor through a motor controller. The motor will in turn move the ball chain using a 3D printed ball chain gear.

Materials

Here is a list of all the parts that I plan on using in this project:

Current Status

I have all the parts except the Arduino and the motor shield. This is pending the Arduino UNO WiFi to become available on RobotShop.

I installed Homebridge on the Raspberry Pi but I still need to install a plugin that allows me to communicate with the Arduino. I am waiting for the Arduino to arrive so I can test my configurations.

In the meantime, I am designing the ball chain gear. I plan to 3D print this at the Kitchener Public Library.

Project: Catan

I first saw Settlers of Catan during a games night inDecember 2014. My lab mate who explained the game to me told me to create an account on PlayCatan because he and my other lab mate play it there during lunch. Whenever I was in the lab during lunch I would join them for a game.

About a year later, PlayCatan which was free, was shutdown and replaced with Catan Universe which, at the time, seemed like it would eventually require a subscription. While we don’t mind paying for things we enjoy, two of us had an issue with recurring payments. Additionally, the game had a much slower gameplay that was frustrating and made games last longer than the time it took us to eat our lunches. Finally, since it was in early access there were a lot of bugs that made it annoying to use.

When I learn a new technology I read a bit about it first then I work on a project that uses that technology. At the time I was learning Node.js, I had read a few tutorials and was ready to practice building website with Node.js but I couldn’t think of anything to work on. Until we tried Catan Universe for the first time and were frustrated by it that is. That’s when I decided to create an online Settlers of Catan game.

I used this as a starting template, this and this to draw the hexagon grid, and this to inspire the general look of the board. My lab mate helped me create the game setup since I mostly played online and never had to set up a Catan game.

You can find the Catan source code on my Github.

Project: Blog

I was scrolling through my list of podcasts to find something interesting to listen to on my walk to university when I found SE Radio Episode 245: John Sonmez on Marketing Yourself and Managing Your Career which seemed particularly applicable to me considering I am finishing my Master’s soon and could use some advice on the subject. In it John Sonmez, author of Simple Programmer, talked about starting a blog and its benefits to your career. He mentioned an email course he offers that talks about starting a blog with the goal of promoting yourself. I don’t usually sign up for email courses because they feel like scams but this felt more reputable. I always wanted to create a blog that I contribute to regularly, could this be the push I needed to get started? It was.

I chose to use WordPress for my blog since I’d used it before and it was very flexible and customizable. I wanted to host my own installation of WordPress but it’d been a while since I last used a hosting company. After doing some research I settled on SiteGround (non-referral).

Then came deciding what the theme of my blog will be. Sonmez offers a few suggestions in his course and one seemed particularly fun. I decided to make my blog about the projects I’m working on, the hurdles I encounter, and the lessons I learn, and the technologies I use in those projects.

There will be an introduction post for every project I hope to work on semi-regularly similar to this post to give you a little background it and then, hopefully, there will be regular updates on the projects.

Let’s see how this goes.