RSpec XHTML Validation of Views

A great way to learn is to read other people’s code. And in that vein, Chris Lowe has a great post on suggested OSS Rails apps to look into.

One technique I picked up from simply_agile is to validate the HTML output by your views. That way, bad HTML isn’t introduced.

To start with, you need to install the assert_valid_xhtml plugin and the libxml-ruby gem.

In your spec/spec_helper.rb file, add the following inside the config block:

config.include ValidateXhtml

And at the end of the file, outside the config block, include the following:

describe "a standard view", :shared => true do
  it "should be successful" do
    response.should be_success
  end

  it "should be valid" do
    response.should be_valid_xhtml
  end
end

Now in your view specs, include the following line:

it_should_behave_like "a standard view"

And that’s it. Now each view will be tested for valid xhtml when you run your specs.

There are a lot of other great techniques scattered through the projects mentioned in the original post. And if you want more details on good practices for RSpec, check out the RSpec Book.

Learning Chinese - continued

Since my last post, I’ve spent a fair bit more time on improving my Chinese. Some recent changes to my routine have improved the speed at which I’ve been learning.

Great Wall at Badaling, China

Lingt

I already use flash cards, but am now spending more time using Lingt.com. They run an online language learning program, that includes audio and writing. My accuracy is improving on words I swore I already knew, but turns out I didn’t know that well.

The site also includes badges and incentives to keep you coming back each day. They remember what you’ve been studying and only allow you to study a certain amount each day, keeping your memory fresh. This is a key part to their success. They’ll replay words at the point where you forget them, increasing the effectiveness of your time.

Reading

This was so simple I couldn’t believe it. To get good at reading Chinese, start reading Chinese.

It has always been my goal to be able to read Chinese content on the web. However, I had also believed that my Chinese wasn’t yet good enough.

Reading Kató Lomb’s book was enlightening. She taught herself more than 16 languages. In her book, she outlines her techniques.

The one that stood out for me was her dedication to reading material in the desired language, well before you can fully understand it. Instead, aim for getting the gist of it on the first read. Don’t look up every word in a dictionary, rather look up those that re-occur lots. Then re-read the book.

For the past few months, I’ve been trying to read two books in Chinese. I find both interesting and I’m learning a lot of Chinese as I go. It doesn’t (yet) feel like reading, but more like attempting a crossword puzzle.

When I started, it would take me around half an hour to muddle through a paragraph. Now, I can often get through between a half and a full page.

One caveat, you do need to allocate time to it. I aim for half an hour a day. Kató suggests that you should be spending at least 12 hours a week on learning a new language.

Shopping, Chinatown, Singapore

Talking

I read a great article recently on learning Chinese. The interesting part for me was to look at finding Chinese speakers who’s English is worse than my Chinese. This makes sense once you think about it; I just hadn’t thought about it.

I still have yet to action this particular plan, and am keeping it on my todo list for now.

Clojure with TextMate on the Mac

Clojure has been getting a bit of press recently, such as prominence on the ThoughtWorks Technology Radar. Having spent some time learning Lisp in the past, I thought it could be a good holiday project to play with.

This post pulls together some of the resources I found for getting started. I’m not going to try and sell you on a Lisp dialect that integrates into the JVM, it should be self evident.

TextMate Setup

TextMate has a bundle that makes it very simple to get started. It includes the clojure runtime, and so you can run clojure code after installation. To install (assuming you have git):


cd ~/Library/Application Support/TextMate/Bundles
git clone git://github.com/nullstyle/clojure-tmbundle.git Clojure.tmbundle
osascript -e 'tell app "TextMate" to reload bundles'

Then create a folder, open it in TextMate, create a file (ie. test.clj) and put some sample code into it:


(+ 1 2 3)
(println "Hello from the console")
(. javax.swing.JOptionPane (showMessageDialog nil "Hello World"))

Put the cursor into one of the expressions and press Apple-R. TextMate will figure the rest out and show the result. Apple-Shift-R will run all the expressions.

(The Vim setup looks really good, but I’m committed to learning TextMate at the moment)

Tutorials

I’m not going to be exhaustive on this, but thought I’d include a few pointers (see also Alexandre’s summary). There is a video series available on YouTube, and also on BlipTV.

This is an overview in a cheatsheet, and there is a fairly complete language reference here and a longer list of references as well.

Given that Clojure is Lisp based, it would make sense to understand Lisp. The best option is a book called Practical Common Lisp. This is available on the web for free, or can be purchased from Amazon.

Update: Apparently I was off a bit on the utility of the Common Lisp book.

From @cemerick: @gmwils FYI, Clojure is a lisp, but has little to do with Common Lisp. For books, try http://bit.ly/ccSw2Z or http://joyofclojure.com/

Quantitative Trading

Quantitative trading is something I know almost nothing about, but is a topic that I find interesting. Mixing computers, math and some luck to automate trading strategies just sounds fun.

When a friend recommended Quantitative Trading by Ernie Chan, I quickly added to my reading list. What surprised me, was that I finished the book within 24 hours!

There are a few things to like about this book. Ernie’s writing style is very no-nonsense. Every chapter has a logical flow to it, and he is crystal clear about the material he is introducing.

The other part I really like is the practical examples. Theory is introduced only as a way of getting to a measurable outcome. Examples are provided in both Excel and Matlab, and could easily be extended to other automation approaches.

Ernie also covers a the wider business aspects of getting setup as an independent quant, such as the trade-offs between retail and proprietary accounts, risk management, finding, tuning and backtesting trading strategies.

At each point, references are made to further material on each topic, such as books, research papers, online articles and implementations. I certainly felt that I had enough knowledge to go about setting up a simple quantitative trading business.

Even though I do not intend to actually set up as a trader, I found it very informative to understand the industry better. It is something I may come back to in a few years.

Agile projects – From Concept to Product Backlog

Agile is something that I’ve previously found to work very well with in-house R&D projects, and rather more challenging when negotiating projects with customers.

The challenge is getting from the sales cycle through to the agile development iterations, be they sprints or otherwise.

By using an agile process, the advantage is that many smart people have been here before. Some of the knowledge is locked up in consultancy houses, while some of it is shared.

Gerard Meszaros has a good presentation highlighting some of the challenges and what often gets missed. The slides are available here.

For me, this is the key slide:

slide-agile.png

The section on adding more time into the Product Planning phase fits well with how customers often see projects. By providing scope at the feature level, it allows boundaries to be placed around time and money.

This is certainly an area of agile that I would like to understand more.