Øredev 2012 – Thursday Afternoon


I had a fantastic morning and the afternoon was equally as good. Here we go.

Katrina Owen – Therapeutic Refactoring

I had to leave a bag at the hotel and ended up having to jog a bit to make this session after lunch and got there just before they closed the door. Lucky for me! The topic of refactoring legacy code is one that lies close to my heart and I totally fell in love with this presentation. I’ve done a presentation of my own at Techdays earlier this year so I know how hard it is to find a good (I mean bad) code sample and then refactor it into readable, maintainable code without losing your audience.

Katrina takes a gnarly method and refactors it into beautiful code in about 30 minutes or so. The code sample is ruby code for creating a filename but the techniques she uses are just as applicable to any statically typed language. Katrina put the code up on Github along with all the steps. Here is the original file and here is what it looks like in the end with tests of course.

What makes this session amazing is just how many techniques she crams into those 30 minutes but still does it in a very relaxed way. She almost makes it look too easy. If you can learn to refactor like this then you’ll be able to take on any legacy codebase. Lovely art on the slides as well. So what are you waiting for, starting watching here.

Sandi Metz – Less, The Path To Better Design

Sandi is another Ruby programmer and someone who knows OO really well. She is the author of Practical Object Oriented Design in Ruby which I haven’t read (yet). Sandi starts by defining design as the art of arranging code. And that when writing code there is always tension between code that has to work today and change in the future. So the purpose of design is to reduce the cost of change. She goes through some possible ways to guide your code design: patterns and principles like SOLID or the Law of Demeter but concludes these are great but too broad to be of practical help at the code level.

So Sandi came up with her own way of diagnosing code which she calls TRUE:

  • Transparent (easy to see consequences of changing it)
  • Reasonable (cost should be proportional to the size of the change)
  • Usable (should be able to reuse it)
  • Exemplary (leads other to change it in the right way)

She then proceeds to go through some code samples and shows different ways to design the code and all the time applying TRUE diagnostics to check how good the solution is. Sandy gets to the core of OO programming as opposed to procedural programming. I think that I know a lot of this but mostly implicitly (I would have hard time explaining it clearly). For example, that the direction of a dependency is a choice and you should choose the direction that will cause the least changes in the future. But that you can’t know this at the start so decouple. I really liked how Sandi could analyse code and judge if it was good enough or if she needed to refactor more. That’s a skill I’d like to be better at.

Here is just some of the advice that I picked up from this session.

  • Classes are more stable when they know less.
  • You cannot avoid dependencies. Depend on things that are more stable than you.
  • You cannot know what is unstable, guard against it, don’t guess. Decouple.
  • Abstractions are more stable

It should be obvious by now that I really liked this session and that another book just got added to my reading list. You can watch the session here.

Mads Torgersen – TypeScript: JavaScript At Scale

Mads started his session with an extremely controversial statement.

“Application scale JavaScript development is hard”

I noticed on Twitter that this statement got absolutely hammered by a bunch of JS developers at the CascadiaJS conference. For me personally I’ve never built a large application in JavaScript so I can’t really judge the validity of this but the concept of converting a dynamic language into a static language seems strange.

However, Mads gave a really solid introduction to TypeScript and shows the advantages of being able to add extra tooling to aid in writing JavaScript. I’m still not totally sold but I have to admit it would be nice to be able to rename a class across several files.

I’d already taken a peek at TypeScript before but I learnt a lot at this session. For starters, TypeScript is not provably type safe. The reason for making JS static typed is for the tooling. All errors are actually warnings that are generated in Visual Studio but you can ignore them and the code will run anyway. For example, if I define a variable as a string but set it to be a number then Visual Studio will flag it as an error but won’t stop me from running the code.

To get this tooling for existing JS libraries a TS definition file has to be created that declares the mapping between JS and TS. And these will have to be hand-rolled as far as I can see. A quick googling produced these examples – AngularJS and AngularJS again. I’m seeing this as a potential problem, which version is the best version? Will these be kept up to date? Or will Microsoft take over this job?

TypeScript will work with Node. There is already a node.d.ts definition file and TypeScript has support for AMD for including other files. TypeScript is open source and on Codeplex so I will be having a look at the source code. The fact that it the typing is optional and that I can have mostly JavaScript and then just sprinkle in some TypeScript where I feel I need it was definitely a plus for me. And even if I did have some quibbles about the generated code (the whole classic class with constructor thing), for the most part it looked very clean. And I don’t think it would be too hard to debug it.

If you want to know more about TypeScript then check out the Playground which is a nice REPL that shows the automatic conversion to JavaScript. And the session is already up if you want to watch it.

Alexander Bard – The Rebels Come Out Online – What if the Internet is something much bigger than we think?

I’m not going to write too much about this and I didn’t take any notes. I just allowed myself to sit back and be entertained. This keynote generated the most discussion afterwards and a ton of memorable quotes. Highly recommended and it would be equally entertaining for non-programmers. This made me think about Twitter and my smart phone in a whole new way.

Summary of Thursday

Me and Daniel got invited to Magnus’ annual meatball dinner along with people he has got to know over the years at Øredev. Gorgeous meatballs and great fun to be able meet some of the speakers in such a relaxed setting. And then after that we went to the evening keynote with Alexander Bard and had some cracking discussions with friends. A day to remember.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s