Testing Categories in Objective-C

Yesterday was katas day: the plan was to start the day with a simple one and then move to another a little more difficult. That was a good plan.
So I decided to do the Stack: a very simple kata, I just had to simulate a stack and have the following methods:

And for rules just this one: “stack should throw an exception if popped when empty.”

Simple right? I thought so too. And it was really easy to solve it: just create a NSMutableArray category and add the methods to NSMutableArray.

So I create I first test :

So I create my class and my code and everything builds! Great, just run the tests and that’s it! No it isn’t!!! Here’s the result of my test:

What? So the code builds and then I have this error:”unrecognized selector sent to instance”. Well let’s ask google….
In reality it took me all morning to figure it out! I must improve my search techniques!!! After googling a lot and a lot of frustration, I find a blog post that saved my day: So if you want to test a category you must add -all_load flag to your test project. Go to: YourTestTarget > Build Settings > Linking > Other Linker Flags.

Problem solved!
You can find my final solution here.

Starting your TDD journey

The old story always comes around when talking about tests: it takes too long to do them and we loose a lot of time. Well, everything is hard to do if you are learning it. You need to practice and practice and practice to become proficient in any new skill.

Let’s imagine you want to start playing tennis.  What can you do to achieve your goal? You register in the tennis club near you and you start training. You go every week days. 4 days you practice with the machine that throws balls at you, and the other day you practice with a coach that shows you the technical skills you must develop to become a good tennis player.

So why not do the same when talking about developing a new skill as a developer? Why not start your day with a kata to enhance your TDD skills. Nowadays there is a lot of sites that provide small katas in several languages. There are a lot of then that have the solution so you can see how others have approached the same problem.

Going back to tennis, do you think that after a week you would be able to play against Rafa Nadal or Andy Murray?  And after 6 months? Probably only after 5 or 6 years you would be able to be at there level.  So why think that after a week of trying TDD you should be super efficient and be the best of it? Do you think that Uncle Bob or Sandro Mancuso were proficients in TDD after a week? After 6 months? If you want to be good at something you must practice. What better place that at work were you can beneficiate from having good tests that will improve your code and reduce your bugs?

So now  you can start your journey into TDD knowing what you should expect from yourself: hard work! If you google “kata” you will find a million links to kata sites, Github repositories, there’s a lot of examples in the net, so just put your hands on it.

There’s really no excuse to not do TDD. Well then you’ve got the skeptical one’s that don’t believe  that “wasting your time doing tests” will improve in any way your code or your way of thinking about your code.

If you really want to embrace TDD, and you feel you have a lot of resistance from your colleagues and manger, the best is look for a job in a company that looks at TDD as a fundamental tool for their developers to be great at their job. They are around. Not so many as you expected but the number is growing.

New professional experience

Hi all!Watch movie online The Transporter Refueled (2015)

In the pass 2 to 3 weeks I’ve been living a new experience, and I just feel like I should somehow put it down and share my new journey as an apprentice that aspires to become a software craftsman at Codurance.

I already have a lot to talk about, but today I would like to talk about my recent experience in SocratesUk conference. This is my first conference for a long time, I don’t even remember the last one I attended. There were lots of reasons that kept me away from conferences and now I just come to this one and really had a lot of fun. And that’s for me what really changed from what I remember of what is a conference: the fact that I had fun, didn’t get bored with some infinite lecture that I could not leave. I could talk with everybody and even propose a session if I wanted. SocratesUk is a no conference, and has a very loose format that I loved.  You could suggest topics that you’re interested in and just announce it in the board, and people with the same interest would just appear the informal spaces available and talked about that.

I must confess that I’m a little shy, and the first day was a little difficult for me to approach others, introduce myself and join a group of people, but in the second day as with had been in the talks you know some people and it’s easier to break that initial ice.Watch Full Movie Online Streaming Online and Download

I think I can say that I’ve made some friends, and I that I really met some amazing people that I want to at least try to maintain in my professional and personal network.

See you around!