iOS Con

Yesterday finished iOSCon, and I just wanted to let you know how good it was. Yes, that’s right, It was really good to see so many iOS developers want to learn different things a and share their knowledge.
First of all the organization has my +1 because everything went so smooth. And for getting such a good panel of speakers. The only thing to point out is that the second day was far better than the first one, and having two tracks with impossible choices to make.

From the first day, I’ll recommend you to watch this talks:

And then the Lightning talks session special the one presented by Abizer Nasir, on how you can burnout in this job.

The second day started with Daniel Steinberg talked to us about Understanding your Toddler given us some insights of how Swift has evolved and what’s coming with Swift 3.0.
And then it was really a big struggle to choose the next one … Fortunately, you can just watch everything here. I would like to recommend you to not miss these ones:

What was really enlightening was to see that all speakers in a way were talking about the same thing: separation of concerns, clean code, clean architecture. It seems that Software Craftsmanship finally hit the iOS world. Good to know!

How katas can help you learn

Baton_long by Alain Delmas

In the last couple of weeks I have spent my time doing katas to improve my Objective-C. As you may remember, I had an issue, that you can revisit here.

I’ve learned a lot from other katas too: for instance the RomanNumerals kata… You’d may think it’s a simple task, that you wan’t learn much from. It’s a simple algorithm, a good exercise for your red -> green -> refactoring cycle. So nothing new will come from here… Wasn’t I wrong!!!!!

First I created some tests. Next I implemented the kata and refactored. Whilst I was refactoring, I decided to use NSDictionary to map from a decimal to a roman number. Here is an example:

That’s when I discovered that the NSDictionary does not guarantee insertion order. What???? So my keys were all mixed up… And I needed them to maintain their order!!!! That’s ok! I decided to create a class to map between decimals and romans. That’s cool! Done! In the converter I just added a private property of type NSMutableArray. In it’s constructor I added the class to the array for all elements I needed. But now I have to do:

for every entry in the mapper. God!!!! So much work! Maybe that’s why developers solve problems. They definitely don’t like to do things by hand so they automate everything.
So I decided that I could create a factory method. I really didn’t know how to create this factory method, so I just looked in Apple docs. Here is another thing i learned. Even thought I knew that it existed, I never used it because I never needed to. But as I was in learning mode, I think I was more interested in finding a different way to do it. When you are at a client, you don’t always have the opportunity to experiment with new things. Having this time to learn new ways of doing things is really rewarding. So here is my class:

It’s even more readable then the initialiser. And here is how I initialised it in my converter:

So my class was looking pretty but then I look at my test class…it wasn’t good:

So many tests. They remind me of the DRY principle. I really don’t like to repeat myself. It’s like a broken CD that doesn’t move from the same music track… I’ve done the same kata in C# and my test class was all parameterised and I really liked it. After all this is a simple kata, right? ;).

Well wouldn’t it be nice if I could have that in Objective-C? Well, after some help from Franzi I found a little library that does it. You install the pod, you inherit from it and you create an array of inputs and expected values like this:

And then you just have to use the properties input and expected. So my test class looks like this:

Here is my final solution: RomanNumerals.

So please don’t underestimate what you can learn from a kata. They are a good opportunity to stretch your knowledge and add some more to it!
image: Baton_long by Alain Delmas