Accidentally in Code

Archive for the ‘programming’ Category

I’m spending a lot more time teaching other people to code than I am actually coding at the moment.

Whilst I like teaching, this is not at all in line with how I want to be spending my time.

I TA a mandatory computer course in the management school, and I have a friend taking another mandatory programming course for Engineers. The course I TA teaches VB, and the Engineering course teaches C.

These students aren’t stupid, the students learning VB only have to ask you whether you use VB (of course not, does any self-respecting programmer?) and they know they aren’t learning anything that can’t be done using the built in functions in Excel. The students learning C notice that their TA’s (and the prof) keep accidentally giving them Java code. According to O’Reilly, Java has been overtaking C++ as a teaching language for over a decade. Why are these courses so behind?

I think this is a missed opportunity. Students taking Computer Science have signed up for a degree of torment-by-compiler. These students have not. Instead of a course that they hate why not take the opportunity to create a course that excites them about the potential of programming? Instead of alienating them about the whole concept you motivate them with the reasons and real world examples for why programming is a useful skill to have?

For instance: mashup creation, simple scripting, what an API is (and how to make calls to it), web apps.

Yes, it requires more creativity in course creation. Yes, it may require the people teaching these courses and the TAs to learn more skills. Maybe before it didn’t make a big difference to send a bunch of students into different fields with a hatred for programming. In the new reality though, an understanding of programming and why it is useful would potentially give them a big head start.

What do you think?

Tonight, I ran my first workshop in Wave. It was nice to have a space to discuss things, and unlike in a chat client it’s easy to indicate what you’re replying to. What I did was create a slide deck and make it available the day before. Then on the day, I was available to trouble shoot. The slide deck was fairly comprehensive (see it here) so I encouraged people to work through it at their own pace, whilst I clarified and helped with issues that arose.

Screenshot below shows mutiple threads of conversation happening simultaniously:

Multiple Conversations

Multiple Conversations

It’s also really easy to drag and drop screenshots, so that can help me see where people are at, and what could be going wrong.

Drag and Drop Screenshots

Drag and Drop Screenshots

Wave has nice indentations (kind of like we indent in Java!) that show a diversion:

Indentation shows the flow of the conversation

Indentation shows the flow of the conversation

Finally, trying to schedule when everyone can make the next session can be difficult – but Widgets sure make it easier!

Widgets help with scheduling

Widgets help with scheduling

So, all in all, wish Wave was faster but I think it was a success. Hopefully as people build up more knowledge they’ll discuss amongst themselves more. We will leave this wave going as people work their way through the rest of the slides (and I can help if necessary) and move to a new wave for the next session.

I’ll keep you posted about when that will be – and will put the slides up here soon!

Thanks to everyone who participated.

Tomorrow I’m running an introduction to Java via Wave. Because I’ve had a degree of interest from non-complete beginners in learning Processing, I’ve split the content so that one session will be Java: Building Blocks which will teach the very basics of Java but does not introduce Processing, and the other session will be An Introduction to Processing.

Java: Building Blocks covers the very very basics of Java – writing your first program, primitive types, conditions, and loops. At the end, we should be able to make a simple Hangman game using a framework I will provide.

An Introduction to Processing will cover getting started with Processing and be suitable for beginners who have gone through Java: Building Blocks but hopefully won’t be too dull for more advanced programmers. It will take you through creating your first little Java applet in Processing.

I’m taking suggestions for Topics, but things I’m contemplating are:

  • Java: Next Steps – covering arrays, multidimensional arrays, Objects, more on functions (passing arguments etc). Finishing with a TicTacToe or Pacman game (I have frameworks for both of these).
  • Test Driven Development and Exceptions – throwing and handling exceptions, writing code to pass test cases. Working on a Blackjack game.
  • Creating games in Processing – detecting key presses etc.
  • New Since Java 5 – Generics, enum, for each, etc.

Slides for Java: Building Blocks can be found below. As ever, I really welcome feedback!

After I gave my presentation the other week, someone asked a question. It was:

So, basically what you’re doing is data-mining?

And I said, no, well yes, but that’s not how I think about it. I see it as creating something that will help people understand their use of Twitter. The fact that I achieve this by data mining is by-the-by.

Maybe when we speak to other programmers it’s OK to say something like, “I’m data-mining social graphs in Twitter and visualizing them” but when we speak to our users, that may not mean very much to them. What’s more, I don’t think I would have come up the idea to do that if I’d gone to Twitter with the intention of data-mining. This didn’t come from me as a programmer with an interest in data-mining, or an interest in visualization (as an aside, I took a course in visualization at Edinburgh and hated it. Mostly because we were coding in Tcl). It came from me as a Twitter user, wanting a better way to measure engagement than followers/following.

Yesterday, I wrote a little bit about the journey that brought me to Ottawa. I think I’ve finally realized what I’m passionate about. It’s people. It’s users. This is why I’m so fascinated about what I’m working on right now – what’s more people than social networking? It’s also why I’m so interested in Usability. I’ve read every article on Don Norman’s website, I find usability so interesting, so important.

I’m passionate about giving users what they want – that’s usability, better ways to display data, etc. That’s creating the things they say they want.

Even more so, though, I’m passionate about giving user what they want, that they don’t realize they want yet. In small ways, that’s telling people who are emailing spreadsheets about Google Docs, or explaining to someone frustrated by their web designer about the simplicity and ease of use of WordPress. In bigger ways, it’s been taking a mess of spreadsheets and turning it into a database that can answer questions that users hadn’t even thought to ask. It’s been creating something that’s can make you really aware of your conversational network, and encourage you to talk to new people (the most rewarding feedback I got was from someone who told me they were now making an effort to speak to more people after seeing their graph). I hope these things are just the beginning.

So, what do I want to be when I grow up? I want to be a programmer who speaks fluent human. How about you?

Update: This will take place on Wednesday 18th and Friday 20th November, 7-9pm. Let me know if you’re interested.

I’m thinking to run a session on this tomorrow, with discussion going on via Wave. Will start at 10 or 11am EST and run for 2 hours, with another 2 hours in the afternoon.

Let me know if you’re interested. I know it’s short notice, so I may push back depending on when people want to do it, but this will happen in the next week or so.

What you’ll need:

  • a Google Wave account
  • Java SDK
  • Eclipse
  • Processing, free download – we won’t be using the IDE that comes with it, but try and locate core.jar

I’ll assume your computer savvy enough to install Java and Eclipse by yourself as this could take up a lot of time in the session.

What we’ll cover:

  • Your first program – “Hello World”
  • Simple types (building blocks)
  • What Object Oriented programming means
  • Getting started with processing, displaying stuff
  • Conditions
  • Loops
  • Global vs. Local variables

This is loosely based on the teaching I’ve done and I have a lot of resources that I’ve created that I’ll share. I have enough to do a whole series of these online workshops, if there’s demand. As it gets cold and nasty outside this could be a good opportunity to learn to code if you’re interested in doing so.

CA assignment 3 is now out, and in class today we were looking at the stuff we needed for question 2 (which is ex. 7.1 in the textbook). It’s to manually solve the isomorphism for the two graphs below:

Petersen Graph

Petersen Graph

So I start sketching this out, and then it occurs to me that – ooh, I could easily write some code to validate it for me after I’ve worked it out.

And then it occurs to me that all I’m doing is trying permutations of “abcdefghij” (where the position in the string is the number they’re trying to replace). And if I used Haskell and the handy “permutations” method I could just code it in a brute force manner, and it would solve it for me.

So of course that’s what I did. This is a programmer thing, I think. We work out how to automate things and then we automate them. Yes, it probably took me longer to write the code than it would have to solve the thing manually. I was quite shocked that it ended up being over 60 lines (including white-space, but still… this is Haskell) although I did include my data (the edges) and methods to validate them. I think it could be done with less code, my Haskell is a little rusty.

I find programming much more satisfying than drawing the graph countless times until you get the right answer. Also, my code is purring away now generating all the valid permutations.

In case you’re interested… here are the first 20:





















This week I’ve spent a lot of time debugging other people’s code, and we had some fun bugs in class too. This was my favorite bug (I refused to fix it, but she worked out how). I’ve helped people in C, VB, and Maple – none of which are my favorite languages (I didn’t know Maple at all), and don’t have the great debugging capabilities of Java in Eclipse. As a result, I’ve come up with some tips for beginner programmers as a result of the common errors I’ve seen.

  1. Don’t take your code not running personally. Your code (or your instructor) is not out to get you! Debugging requires calm and rational thinking, the more you get upset that your code isn’t working, the less able you’ll be to fix it.
  2. Google is your friend. Lots of people learning to code have had the exact same problems you’ve had, if you can search you’ll often find potential solutions (just be careful – they may not be good, or exactly what you’re looking for). Online is also where you may be able to find that function you need.
  3. Read error messages. I’m losing track of the number of times that someone calls me over to look at a program, shows me how a compilation error pops up and then hits enter before I can read it. Read the error messages! Even if you can’t fix them yet, once you’ve learned what they mean you’ll know what to look for and be better able to fix them in the future.
  4. What are you declaring and why? Think about your variables – what to you need? What do they do? The type of the variable (String/Integer/Boolean etc) is important.
  5. Frame your problem in terms of behavior. If someone frames their problem well, I know exactly what kind of bug I’m looking for. Explain it briefly, then let me look at the code.
  6. Print statements! So useful to see what’s going on inside in the code. Don’t be afraid to use them – you can always delete them later.
  7. Small things can cause big problems. My friend spent hours trying to fix something in her code yesterday – the problem? She was using assignment equals (=) rather than logical equals (==) in an if statement (you can do this in C). Small distinctions can be really important – pay attention to them.
  8. Turn the monitor off. A blank text-editor filling your screen can distract you from the problem itself. Writing code should be the last step in solving the problem – not the first. Turn off the monitor, think about the problem, and break it down into it’s component parts. Then code it in the parts (but don’t be afraid to break them down again if necessary).
  9. The computer will do exactly what you tell it to do, in exactly the order you tell it. A lot of people forget this, but it’s so important. When the computer is not behaving the way you want it to, reflect on this. It’s important to be clear on what you want to happen first, or what you want to repeat (or don’t want to repeat) in a loop, for example.
  10. If you’re lucky enough to have a TA or friend willing to help you – take advantage of that!

Anything I’ve missed? Let me know!

Sorry – I’m (very) atheist but mostly that remains off this blog. However earlier I saw an excellent debate featuring the awesome Christopher Hitchens and the wonderful Stephen Fry. It’s in 5 parts and it was annoying when the part finished at a climatic moment and I was trying to find the next one, so I thought I’d assemble it in one place before I linked to it.

I think this debate is worth watching, whichever side you’re on, as it is a focused question and they’re debating the same question. Often when atheist meets religious, they’re talking about different things. That is not the case here. They also polled the audience before and after, and there was a massive change in opinion.

Part 1: Archbishop and Christopher Hitchens

Part 2: Christopher Hitchens and Ann Widdecombe

Part 3: Ann Widdecombe and Stephen Fry

Part 4: Audience Questions

Part 5: Summary

I have a problem – I now have 4 computers. Yes, I realize this is a problem that many people wish they had, but still. I have:

  • MacBook Aircarry about at university and use out and about, use for notes, reading stuff, and small amounts of development and document editing.
  • 15″ MacBook Prouse mostly at home unless need to get a lot of work done. More development and document editing.
  • Mac MiniMostly used as a backup system and multimedia centre. Static, so useful for running long processes.
  • Windows PCin my office at university. Mostly used for things that require a Windows PC (marking). May want to run long processes involving a large amount of API calls.

Up until now I’ve managed by segregating the things I use each machine for. So I use the mini for web development (CS3 will not run on my Air!), the university machine for… pretty much nothing, and the Air for everything else. It’s not been a great system, but it’s been manageable. With the arrival of the Pro, that is no longer the case. I’m going to have to be able to work on the same document on my Pro and my Air, and I don’t want to be keeping track of what’s where.

So I’ve come up with a strategy, which I’ve outlined below. Nothing is fixed yet, though, so I’d welcome tips as to how you manage your data across multiple machines if you do. It’s obviously important to me that I come up with an effective way to do this – the point of the Pro was to increase my productivity as the Air just runs too slowly sometimes. I don’t want to spend the time I save on file management!

1. Move as much as possible to the cloud.

My email has been in the cloud for a long time now, of course. However I recently migrated my ToDo list (Remember the Milk) which is working out great as it also syncs to my iPod Touch. For references, I use Zotero, which also syncs to the cloud. I’m going to move my calendar to Google Calendar and work on small documents in Google Docs (all our stuff for WISE is in Docs).

2. Set up a SVN for code

Yes, I should have this already. But when I was only developing on one computer I never got around to it. Now I hope to develop on at least two, it’s crucial to get this sorted out. So I need to go through each of my workspaces, tidy them up, and put the stuff I need in a repository that will run on the Mini.

3. Mobile Me

This is a temporary solution. One year of this with a new machine was about $60-$70. This makes the need to set up a repository for my home director less pressing (a good article about the best system to use for this is here). SVN is less practical because of the overhead, so I’ll either use Mercurial or Git (whichever is easiest to set up on a Mac). Also, right now, it’s not practical to have all my documents in Google Docs as some of them are too large and there’s the need to edit offline. This time next year though, I’ve no doubt I will have way more options.

Monday was Democamp 12, I heard about it in the morning and managed to get a ticket (someone dropped out). It was really a great evening; I met some really cool people and won a model plane.

Events: Betidings and Twegather

First up presenting was Betidings. The concept is that you have a calendar of events that you’re interested in, and you can follow other people and events they add to their calendar will show up for you as well. So with very little effort I now have a schedule of events in Ottawa and I can see what days I’m free and what interest me. The downside – I was living in contented ignorance about the Girl Geek Dinner on Monday, and now I’m gutted that I’m missing it! I think it’s worth checking out, you can see what I’m interested in here.

This is still in the very early stages and is more of a proof of concept than a fully fledged application but I think it’s worth a go – the more data there the more useful it will be. And it’s a nice way to share stuff you’re interested in without forcing it on people. I guess it could potentially be for events what Twitter is for ideas and content. Not sure everyone got this though – one jerk said the user interface sucked. Not quite in the spirit of democamp! The UI isn’t fully there yet and I’m not a big fan of the colorscheme but they’re actively looking for feedback and welcome any comments to @betidings.

Twegather (not yet public) was created through TeamCamp – read about it here. It’s an event system using Twitter, you’ll be able to create an event using @WhoWantsToGo.

Crazy Planes

The planes were what I was talking about in this tweet. A full article on it is this one, by the lovely @loudandskittish. I thought these were awesome because to me they illustrate the programmer mindset applied to something not-programming. I’m definitely going to be taking mine (and hopefully a few more) to my Holiday Science Lecture in December!

Twitter Procrastination Tool: BattleTwip

This is kinda cute! Battleship on Twitter, played against everyone. Created by 76Design, you can follow @battletwip and play via Twitter when the next game starts. They also have a really awesome looking web interface which we saw a preview of, but as far as I can find it’s not up yet.

Advertising: Shiny Ads

Shiny ads is an alternative to Google Adsense. It allows you to attract your own advertisers, gives them the tools to make their ad or upload it and then you can approve it (or not) and earn a much better rate for click-through. Wasn’t so relevant to democamp – although most people had websites, they seem to use them to either promote their (non ad-based-web-) business or personal brand.


Great experience, great people, great opportunity to interact with the Ottawa tech community and it’s nice to see what’s up and coming. I love the vibrant tech scene here! Can’t wait for democamp 13 – wonder if I could present my graphs…?