Functional Programming in Ruby
Blocks
fruits.each {|fruit| eat fruit } # delicious!
Procs
def do_something_with_fruit(fruit, &fruit_related_activity)
fruit_related_activity.call(fruit)
end
do_something_with_fruit(banana) {|fruit| eat fruit} # => the banana is eaten!
Lambdas
blend = lambda {|fruit| blender.blend(fruit)}
freeze = lambda {|fruit| freezer << fruit}
basketOfFruit.each &blend # => a smoothie
basketOfFruit.each &freeze # => now icecream
canOfWorms.each &freeze # => um ...
Utility
What A Modern Rails Application Looks Like In Production
Yellow Lab is a Rails application. When we first started up we chose Ruby on Rails (Sensis generally uses Java) to see how using a dynamic platform would change our delivery patterns. Now that we’ve been running for a while, we wanted to share what our high level architecture looks like and the various components that make it up. We hope it is interesting to see what a live, enterprise, Rails application looks like when deployed, and if you have some ideas to share with us, we are always happy to hear them.
We find that simple systems are easier to build and understand, which make them easier to change, so with that in mind we are always striving to make things as simple as they can be, without being simplistic. Our setup is a fairly standard in modern web applications with a web server that receives client’s requests then passes those requests back to either the file-system (if static assets are requested) or to the application server which in turn pulls data from a database, a search engine or the file system.

The Bits And Pieces
- The Web Server (Nginx) – (pronounced as “engine X”) is a light weight, high performance web server/reverse proxy. We chose Nginx for it’s light footprint and easy configuration. It has served us very well and hasn’t got in the way of anything we’ve needed to do. If you are looking for a web server and you’d like to try something beside Apache’s httpd then Nginx is a great alternative.
- The App Server (A Bunch Of Mongrels) – Mongrel is our application server. If you are from a Java world you can think of it as Apache’s Tomcat for Ruby. We use Mongrel to host our Rails application and it does a fine job. Mongrel was the default deployment option for Rails until the original author, Zed Shaw, decided he didn’t want to support it any more and a competing technology, Phusion’s Passenger, came along. Passenger is the “preferred deployment setup for Rails” – it is under active development but doesn’t really offer us enough to switch from Mongrel. We’ll probably swap over to it, but we’re in no rush.
- The Meat And Bones (Ruby On Rails) – We are using the Ruby on Rails framework to build the business logic for the site. So, has it changed our delivery patterns? Yes, it’s made us faster. Some of it is probably due to the fact that we are a lab/test bed group, but RoR has certainly been a major contributing factor to allow us to get features into ‘production’ more quickly (there are some stories and learnings here, but we can explore that some other time). Ruby is a fantastic language to build web applications with and Rails leverages Ruby’s language features pretty well.
- The Database (PostgreSQL) – PostgreSql is a mature, open source database with clear licensing. If you haven’t looked at it, then you should. We use PostgreSql to store business listing data and user generated content (we are sooo web 2.0). Fairly straight forwards stuff. We also use a PostgreSql GIS extension, PostGIS, to generate reference data for suburbs that we use during our search.
- How We Find Stuff (FAST ESP) – All Sensis properties use FAST ESP (bought by Microsoft last year) for their search requirements. Being a test bed for new functionality (of which search is a major component), we use it too. In the open source world Solr (build on Lucene), Sphinx or Xapian may fill the same requirements. We make heavy use of FAST and many of it’s feature and there is much we can say about it as well as all the things we have learned about search from using it, but we’re trying to keep this short and sweet, so moving right along.
That’s our logical design, but physically we have two servers.
Why Two Machines?
Notice that one of our machine is completely devoted to FAST (our search product). While we could use just a single server for delivering search results we need the grunt power of a second machine when we “ingest” our data (load it) into FAST.
If you have a comment or suggestion about our setup or simply want to brag about showcase your own, please leave a comment, we’d love to hear from you.
Popularity
We’ve had a few comments and feedback emails about our voting system (or you can call it recommendations or even word of mouth) so I thought I’d take the opportunity to talk about it. Mostly the questions have been around how it works, why it works that way and what does it affect, so I’ll tackle these questions in this post.
How?
We use a +1 model, that is, each time a user votes for a business the total votes go up by one for that business. So the more votes a business has, the more people have said that they liked it. Each user is allowed to vote for a business only once (which is why you need to register to vote). This is done for integrity reasons. Our users told us that if they couldn’t trust the system, then it didn’t matter how many votes a business had.
Why?
The usual objection to this is that people want to vote negatively as well. On the surface this seems completely reasonable, but there are 2 main reasons why we didn’t. The first and biggest reason we went with a +1 model is that people are far more likely to give, and look for, positive ratings than negative. We’ve done our own research into this (which unfortunately I can’t go into) but others have shown that positive ratings tend to eclipse negative ratings. The second and lesser reason is that being a business directory, we need to be a little sensitive to those businesses.
It also makes sense if you just think about it – when you’re asking friends where you should go for dinner, your friends will tell you about places they like. They might occasionally tell you about places to avoid, but the recommendations far out number them.
So that’s why we’ve gone with a +1 model, after all Yellow Lab is an area to try things out.
What’s Affected?
At the moment the number of votes a business has won’t affect your search unless you explicitly say so – which is done by sorting your results by votes (instead of the default ‘best match’). We have had considerable discussion on whether the number of votes should influence the best match result – there are reasons for and against. Two of the stronger ‘against’ reasons are location searches (I want the closest, not necessarily the best) and reputation (did those 5 people that like that restaurant like the same food as you, etc.).
If you want to see what effect there is, you can compare these 2 searches for a cafe in south melboure: sorted by best match and sorted by votes.
So hopefully that’s given yo a little background on our voting system. if you’ve got any more questions or comments about it, feel free to ask them in the comments section.
Cheers,
Dan.
Playing Tag on Yellow Lab
So what’s happening in the Yellow Lab?
One of the features that we have been looking at in the Lab are tags and how they can used with the business information that we have.
Tags themselves are certainly not something new with websites like delicious, flickr and Facebook using them to share, save and classify websites, people & places.
Over the last 3 months our users have been busy tagging businesses whether that be something unique, like jazz on Tuesday, something helpful for other users, like free Wifi in Sydney, through to the downright weird, like strange business names.
So what else could you use tags for in Yellow Lab?
So I’m going for a holiday in Noosa with my girlfriend (one of my favourite destinations) and I want to make a list of accommodation places to check out.
I could do a search for accommodation in Noosa then go through the list of results & tag all of the places that I am interested in finding out more information about with ‘accomodation for holiday’.
I can then send the list to my girlfriend to get her opinion on each of the places, if I need to look them up I can go to to my profile page (you have to register to get a profile) and click on the tag ‘accommodation for holiday’ tag to see the list for myself.
Then once I have decided on a place I could then delete the tag from the businesses if I don’t need it any more (through the profile page), leave it for my future reference or if I think it will help others going on the same trip.
Over to you
So why not show us how you would like to use tags by trying it out yourself. If you have any problems, questions or comments please post a comment on the blog.
Go on make your mark and add a tag!
Cheers
Anthony
We’re listening – seriously!
There are 2 ways in we which try and build things that make Yellow Lab better for you. The first is via feedback through the website and blog. We try and answer this feedback reasonably quickly and sometimes ask our own questions back so that we can understand your feedback better. We keep an eye on this feedback and try and pick tends or regularly requested features – which in turn get a higher priority.
Secondly we conduct reasonably regular user testing. The user testing can take different formats, but usually it’s either trying out some ideas in the form of paper prototyping (seeing which solutions users like best before building it) or giving newly developed features a test run to see if there are any problems. We recruit users for user testing from outside the company so that we can be sure they won’t be biased towards our business goals. We also have our own sexy Design Lab where we conduct the user testing. The Design Lab is set up with cameras, computers and even one-way glass so people can watch without disrupting the session.
Obviously we have some business goals we need to work on, but we are also working on things that you think are important too. As Dr Frasier Krane said, “… I’m listening”, so keep that feedback coming!
Cheers,
Dan.
A quick guide to the Yellow™ Lab blog
This blog will cover a variety of topics, but you might not be interested in all of them. To help you out, we’ll use a few different categories so that you can target the posts that you’re most interested in. Here’s a quick explanation of the categories we’ll use:
Site updates: Pretty much what it sounds like. We’ll give you a quick run down of what we’ve done in the latest update to the site.
UX: UX stands for User Experience. This is a broad term that covers things on the site that you interact with directly. It can range from simple interface designs decisions like why something is on the left rather than the right, all the way to more complex ideas such as user defined (location) search areas.
Dev: Short for developer, the Dev category is for all the techies out there that interested in the ‘behind the scenes’ workings. There’ll be posts ranging from how we’re using the FAST search engine, to how we’re going with developing on Rails. It’s hard to tell from the surface, but there are some tricky technical challenges for our developers.
Search: The site is for finding businesses, so search is at its heart. In this category we’ll be talking about search algorithms and how we’re measuring search quality – without giving away company secrets of course!
Features: Most likely this category will be paired with one of the others mentioned above, but essentially it’ll talk specifically about features you get to try out (but you probably already guessed that…)
Hopefully that helps you focus on the posts you care most about. We also hope that means you’ll join in with some discussion when we do post, after all, we want to hear what you think about our ideas.
Cheers,
Dan.
Welcome to Yellow™ Lab
Hi and welcome to the Yellow Lab blog. We have launched the Yellow Lab site to give you a preview of some of ideas coming out of Sensis and, in turn, letting you help shape what makes it out of the Lab onto www.yellowpages.com.au.
Have a look around and let us know what you think of what we have done so far. We will be constantly introducing and evolving features so make sure you drop in again to read the blog and see what has changed.
If you have any questions about the site, what we’ve done, what technologies we are using or things you’d like to see post your comments and start a conversation with the guys putting in the hard yards.
Cheers
Anthony


