During the work I’ve previously done around OpenID Connect and Federation, I ran into the need to be able to mutate Entities.

Every Entity in Known has a type, and internally this corresponds to a PHP Class when loaded from data storage. Each Class has its own abilities and methods, and in general you’re not going to want to turn one into another.

However, I did.

This occurred when a User (which corresponds to a User) object logs in to a site after they’ve already used the federated API (which would create a RemoteUser object internally).

When that occurs, we want to convert the RemoteUser account into a full fat User. We can’t simply delete and recreate the user as that would lose all their history, and remove any posts they have made, etc.

So, we need a mechanism to mutate them.

This should be safe, since RemoteUser is a child of User, so they’re not vastly different things.

So, as of recent builds of Known, RemoteUser implements the interface Mutable, which defines a method mutate that accepts a class name to mutate to. On success it’ll return the newly mutated object. This object will have the same ID and data.

For convenience, there’s also a Trait Mutate that you can mix in, which provides a reference implementation of this interface. That implementation will check to see that the class you’re wanting to mutate and the class you’re wanting to mutate to are both related, and if so will perform the necessary incantations on the database.

Useful tool, but “with great power…” etc.

During one of the intervals at the recent TEDx Oxford conference, after Peter Millican’s session in which he used simple computer programs to gain insights of the world around him, I was approached by a very good friend of mine. She was keen, as are a number of my friends, male and female alike, to learn how to code, but she was struggling with how to get started.

The issue she was having with the currently available classes were too formal, often very demanding on time, and she often found them to be very competitive. This didn’t produce a very supportive or effective learning environment. Online courses on the other hand were often were very simplistic, and were hard to stick to, possibly because they were often worked at in isolation.

As a teacher, she is keen to try and get something short, with a large practical element, which would fit in the few weeks every year that all teachers have free at the same time – the summer break.

How did you learn?

The conversation turned to how I learned to code…

While I had some formal education it is true, which was good to address gaps in my theoretical knowledge, I had learnt the bulk of my coding skills long before I sat in my first Computer Science class at 15. Despite having not been formally “taught” how to code, I had managed to absorb a comprehensive understanding of the subject, so how did this come about?

Through our conversation, I realised that it seemed I had largely learnt through self directed play (aka, pissing about trying to do cool shit), combined by having a couple of more experienced friends, who helped guide me when I got completely stuck. Another aspect that helped was the weekly computer club I attended, together with Ben Werdmuller and a few other friends, where (as well as playing Monkey Island for hours) we demoed our latest code, and exchanged tips hand tricks we had learnt.

This provided a supportive environment in which to sharpen my tools, and the aura of good natured competition the weekly informal show and tell generated didn’t hurt.

What could this look like as a course?

So, could this experience be replicated? Could we put together a course, which would be fun, nurturing, fit in with people’s limited time and allow people to drop in and out without falling behind? I’m assuming this is going to be for adults here, but I can’t imagine it being a significantly different problem for children.

I imagine this working more like a club or craft group, rather than a course, where students play with various bits of kit and work on their own projects. Where they’re encouraged to learn off other students, and where more experienced people are largely there as mentors rather than to set agendas. For complete beginners, perhaps an orientation session covering some of the basic basics would be useful to bring people up to speed, but I think lectures and theory should be minimised – this should be hands on!

What are your thoughts?

I am really pleased to welcome the Oxford code dojo as the latest addition to the Oxford tech scene.

At a Code Dojo, you are presented with an algorithmic problem and are encouraged to solve it in the most efficient way possible – stretching possibly atrophied puzzle solving muscles in the mean time.

It is also a good excuse to do a bit of networking with the other techs in your local area.

Thanks to Matty and Oleg for arranging such a stimulating event, looking forward to the next one!

Image “Dojo” by Fighter-arts