Thursday, April 25, 2013

the good book

It's been a while since I posted for the last time.

I was watching the rails workshop like crazy and trying to extract every last bit of knowledge of it. Now I'm done, and it's time do start coding again, so I'll be posting more.

I still have to finish Kent Beck's TDD book, I've read only the first part, but today I felt the impact it had. Kent, I salute you!

I was coding something to a friend, and I was really able to think in a TDD-way, it was awesome, there's no going back now.

But the best part was refactoring the code. Kent says "Eliminate duplication", and I think I'll tattoo this on the back of my hands. Refactoring is AWESOME! Identify the duplication, eliminate it, "cool, my code looks cleaner!", run tests, all green, FUCK YEAH! It's almost like magic, you code shrinks before you eyes, becomes cleaner, and you have full confidence that you code still works.

If you wanna take a look at my code, see how it evolved, it's all here.

I wonder how much more cool stuff there is to learn in books like the classics Refactoring and Code Complete. I wish I had 48 hours in a day. =)

Tuesday, April 9, 2013

domain specific languages

The very first time I've hear about DSLs was after the Thoughtworks Boot Camp in March/2012.

I've read some articles after that, but I just really understood it after I started using Capybara.

Capybara is a framework for testing user interaction in rails applications.

A Capybara test will have statements like these:

visit "/"
click_link "My account"

fill_in "Your email", with: "john@example.org"

fill_in "Your password", with: "test"
click_button "Login"

Those statements are part of the Capybara framework. They are part of a language that was created specifically for the purpose of testing web applications. This is the Capybara DSL. A small language created for this specific purpose, or domain.

I've read that DSLs are not a new topic, but with the popularity of dynamic languages like Ruby, they are easy to create and incredibly useful. I'll try to create my own in the near future.

all in

Last friday I quit my job to study Rails full time.

And I must say I'm quite happy. The first day was a bit overwhelming, the workshop I'm currently attending has A LOT of information, and it will take some time to soak it all up, but the teacher is really good, and it's better to learn from a master than try to learn everything by myself.

It will take a lot of time and effort, but I'm feeling great about it, and I'm 100% motivated.

Let's do this! =)