aimee's avatar

Presentation of my apprenticeship task

by: aimee

Here is a presentation i made to some of my colleagues on friday explaining my first apprenticeship task, my wiki, how i went about it, the problems i encountered and what i learnt from the whole experience.

See my Apprenticeship task presentation on youtube.

aimee's avatar

Licky wiki news

by: aimee

Just a quick update on licky, my little wiki apprenticeship task i’m doing. I realise that time has gone on and i haven’t talked about it as much as i might, plus i actually have some quite encouraging news to report now!

Last time i wrote, i was just starting to work on Pages and a PageFactory to find them or create them as necessary. Since then i’ve added a persistence strategy which saves wiki pages to the filesystem. I pass the desired directory to the strategy so that test pages can be kept separate from real pages. This was necessary as i wanted to clear out the test directory every time after use and i didn’t want to accidentally delete real pages.

After that little burst of progress i stalled for a long time as i knew i needed to start writing the web interface and i didn’t know where to begin. James gave me a good idea which was to set up a simple Webserver class that would wrap around the web server of my choice. I have chosen WEBrick for the time being, but it shouldn’t be too difficult to swap in another one later, probably with another strategy pattern. James suggested i start by visiting a page and looking for the text ‘Hello world’. I thought this was a good idea and so i started finding out about WEBrick servlets.

With that start i was suddenly able to leap ahead, testing and implementing everything i need so that my wiki is now able to create, show and edit pages through the web interface. I feel as if i am very close now. Possibly the only thing left to do is add a way to link between pages and then i can truly call it a wiki.

Test driving the development of this whole project has been extremely educational. I know i started off getting too involved in writing a test framework, so Enrique pulled me back and made me think of the simplest thing that could possibly work. I began with one method: assert_equal. That was enough in the beginning. As time went on i added two more methods: assert_true and assert_contains. When necessary i added useful debugging information to report failures. At the appropriate time i refactored the testing framework into a module that could be included into multiple test classes.

I know i also started thinking about the web server too early. I started off trying to work with ERB and templates, as i am familiar with Rails, and in the end all i needed was a few servlets. As Enrique made me realise, the most important part of a wiki is not that it runs on a web server. The most important thing is content. Pages, with content, saved to a file system. Having focussed on that and got a real solid, well tested mechanism for saving and retrieving pages, i knew that the WEBrick servlets could rely on the underlying framework, and when the time came, it did not let me down.

aimee's avatar

Design Patterns study group

by: aimee

A new thing at Eden is we have started a study group and we are currently studying the Gang of Four Design Patterns book. I’ve read this before but i’ve not studied it. I guess i got an overview and thought to myself, “Well, i know where to look if i ever want to look up a pattern …” – Have i ever looked up a pattern since? No! ;)

So i’m really glad to be studying it this time and really getting to know the patterns properly so that i can use them readily whenever appropriate. It’s good to have the opportunity to discuss one pattern at a time in a group. Here’s a photo from the first study group last week:

Design Patterns Study Group

As part of my studying, i am implementing examples of the patterns in Ruby. Last week i coded the Factory Method example. It’s funny how i can skim over the code in the book and convince myself that i understand it, but coming to implement it for myself in a different language was a challenge. One that i thoroughly enjoyed, i have to say! :) I’m happy to say that i now fully understand the factory method!

I’ve also been writing tests to ensure the code works as i expect. This has been useful because i’ve learned about Test::Unit which was previously unknown to me. When i joined Eden i learned RSpec and Cucumber (or story_runner or whatever it was called back then). Other than that i’d never tested Ruby before.

This week i have been implementing sorting algorithms as strategies. I wasn’t too impressed with the code examples in the book for the Strategy pattern, largely because they left out all the code that actually differs between the strategies! So i decided to make up my own example. It has been good to refresh my memory on sorting algorithms at the same time as clarifying how the Strategy pattern works.

You can follow along with my workings on sermoa/ruby_design_patterns.

aimee's avatar

Remote trio programming

by: aimee

If pair programming is good, trio programming must be great, right?

Well, normally no, probably not, but today i had a trio programming experience that worked really well. Two of us were new to the codebase and together we learnt a lot from the person who knows the code well.

Of course, we all did not crowd around a single computer. That would not be comfortable at all. Due to the snowfall, most of the edenites were working from home today, so it gave us a great opportunity to find an effective way to pair remotely.

Initially we tried iChat screen sharing, but the screen updates are too slow to be satisfying. Steve had the idea of using GNU Screen so that we could all access the same terminal window via SSH.

Using a VPN to the office network, we were able to tunnel to Steve’s laptop and access the screen. In fact we found it useful to have two screens running: one for editing code in Vim and another screen for running Cucumber features. The exciting thing is, we don’t all have to look at the same screen at the same time: each person is free to switch screens on their own machine without affecting the others.

A Skype conference call completed the experience so that we could talk through our thought processes and learn the details of the codebase.

It was altogether a very profitable day. The snow, instead of being a hindrance today, helped us to find a very effective way of allowing three people to collaborate on a codebase.

aimee's avatar

Update on my wiki

by: aimee

Since i last wrote, i have gone in a few directions trying to get started with my apprenticeship wiki task, got a bit stuck, talked to Enrique a lot, thought a lot, and i think i’m on track now.

My first mistake was to focus on the test framework. I was pretty pleased with my given/when/expect framework, and it actually sort of worked, but it wasn’t really necessary for what i needed. In the spirit of “the simplest thing that could possibly work”, this is the bare minimum you need for a testing framework:

def assert_equal(actual, expected)
  puts actual == expected
end

My second mistake was to get carried away with making a web interface. I learnt a bit about WEBrick and how to embed ERB into a web page. That will become useful later, but it was the wrong place to start. After i had done all that experimenting, i still didn’t have anything remotely like a wiki framework!

Enrique asked me, “what is the most important part of the wiki?” – the answer is: content. If i have no content i have no wiki. So i am making it as basic as possible: creating a Page object and assigning it some content. Then i am moving on to a PageFactory that has the responsibility of finding pages. The pages may be stored in a database, filesystem, or even just in memory. It doesn’t matter for the moment. Whatever i decide to use, the PageFactory will deal with it.

My progress is now on github so you can follow along with my progress if you wish. The repository is sermoa/licky – licky meaning ‘little wiki’! :)

aimee's avatar

A testing framework

by: aimee

Enrique has amended my task so that i cannot use any existing testing framework, not even Ruby’s built-in Test::Unit. However, i must practice test-driven development! Ha ha ha!

So here i am trying to ponder how to write a unit testing framework. Which is actually really nice because i get to decide the syntax i would like to use, and maybe – just maybe – i’ll come up with something that suits me really well and i’ll use again.

Enrique pointed me to the Given specification framework which i like because it uses the BDD ‘given/when/then’ approach for unit-level specifications. I’m already used to this kind of format for Cucumber features. Effectively, we use ‘given/then/when’ for Rspec, but it’s not made explicitly obvious. My comments in this trivial example should make it obvious:

describe "example" do
  before do
    @counter = 1             #(given)
  end

  it "increments the counter" do
    @counter += 2            #(when)
    @counter.should == 3     #(then)
  end
end

Now i think i could make the ‘given/when/then’ more obvious, and i can also simplify it. I might actually change ‘then’ to ‘expect’, meaning i can do away with the ’should’ method. Effectively i’m saying that whatever is in the ‘expect’ block should return true, otherwise the spec fails. Here’s what i’m thinking of:

spec do
  given { @counter = 1 }
  when { @counter += 2 }
  expect { @counter == 3 }
end

I suppose this is what people call a DSL – a domain-specific language. That is the kind of language i’d like to use to write my specs. I’ve never written a DSL before, but i’m excited by the idea of being able to write specs like this, so i’m looking forward to giving it a go!

A little voice in the back of my head is telling me i’m going to have to finally understand ‘lambda’ properly. Lambda is one of those things that never sticks in my head. I can look it up when i need to and blunder my way to making it work, but i never really understand what it’s doing or how or why. I have a suspicion that i’ll be making extensive use of ‘lambda’ in my testing framework! :)

aimee's avatar

Apprenticeship

by: aimee

I am pleased to say that today i have been offered an apprenticeship under Enrique Comba Riepenhausen and i have accepted! From this moment on we have entered into a formal mentor-apprentice relationship where i will learn as much as possible from Enrique, and Enrique will mentor me to become a better software crafter. I expect it to be hard work but very rewarding.

I am proud and honoured to have been given this opportunity. I am glad that it has become official because i need my learning to be accountable to somebody. I am great at starting new things but really bad at following them through. To be answerable to Enrique will be very good for me, and i know that there is a lot that i can learn from Enrique.

My first task is to write a wiki engine in pure Ruby, with no libraries other than a testing framework. So no Rails, no Sinatra, no Mongrel, no plugins. This is to teach me the real core of Ruby as a language, without relying on other people’s code for shortcuts.

I guess the first thing i need to figure out is how to make the application listen for HTTP requests. Which i can honestly say right now i don’t have the faintest clue! Let the learning begin!

aimee's avatar

Eden hack day

by: aimee

Friday 13th November 2009 was Eden’s first hack day! Following on from the previous success of “Code something cool in 2 hours” we decided to devote a day to each doing whatever we wanted to do. It could be anything at all; the only requirement was that we had to demo something at the end of the day.

* * *

Tris and Richard did a multi-user dungeon game using Rails, Javascript and Juggernaut. The Fall. It was impressive and extensible. It was cool that it would respond to multiple players by around about lunch time! They did a great job on the user interface.

Chris worked on an integration system between multiple contact lists. Big city. The demo example was between Highrise and Google Contacts. The synchronisation didn’t quite work, but we could see its potential.

Enrique and Steve made an ambitious framework for customers to put features into git with scenarios and steps. Gourd. It will link up with projects and iterations, storing the features as dangling commits in git until it is time for them to be automatically inserted into the filesystem for the appropriate iterations.

Todd spent the day learning how to make iPhone applications, and successfully followed a demo app known as “Whoops, i broke my iPhone!” which made us all laugh … at least 3 times! ;)

Spencer did a useful Sinatra app to help people send HTML-formatted emails. Easymail. I think the idea is to write an HTML template, and then use the tool to add in content. It handles inline CSS and multipart correctly without any fuss.

I wrote my first Adobe Air application today! Pomo. It is something like the OSX pomodoro application. Not having found a suitable Linux equivalent, i thought i’d write my own in Air to make it cross-platform.

* * *

I think we all had a great day, learnt a lot of new things, and enjoyed seeing what we’d all managed to produce at the end of the day. It’s a shame that James and Elliot were away today, but i’m sure there will be more hackdays!

A big thank you to Todd and Juliet for the hackday lunch! :)

aimee's avatar

Practice makes perfect

by: aimee

I have recently been struck with the idea of practising coding skills. It makes so much sense. In this video, Corey Haines talks about the necessity of practice, and likens it to learning a guitar. You don’t just play a song right through first time, and then move on to another. You need to spend time practising the chords, and changing between them.

Road Thoughts – Practice from Corey Haines on Vimeo

In the same way, as programmers we need to sharpen our skills by doing little practices (sometimes called katas from the Japanese word 型 meaning ‘form’) and repeating them over and over until we get them just right. The skills we learn during practice will be ready to use when we need them in a real project.

The atmosphere at Eden has changed recently as people are taking it upon themselves to learn new skills and practise katas. Suddenly we’re all looking at each other and thinking “I don’t want to be left behind!”. Just as Uncle Bob said yesterday:

You raise the level of professionalism in your company by raising yourself. Refuse to stay where everyone else is.

- @unclebobmartin

That said, i still find it very hard to motivate myself into actually doing some practising! There’s always so much ELSE to do, right?! I love the idea, but i need a bit of a push getting started. I need a mentor to guide me.

I have forked coreyhaines / practice_game_of_life on github and got as far as running the cucumber specs. At the moment i’m not really sure what to do next but i’m mulling it over and will hopefully make a start on coding something this week. I’ll probably completely mess it up a few times and have to start again, but hey, i’ll learn a lot from it! That’s the whole point of practising, isn’t it!

I will update here to let you know how i get on! :)