What do you call someone who works at Code Genome?

That’s right, a garden gnome. (Apparently, some British dude had trouble saying the name of our company.)
It is with great pleasure that I announce that a new gnome has joined the team: Pierre Olivier Martel. PO is our first rails garden gnome guru-to-be. Welcome aboard PO!
Popularity: 25% [?]
(company name) Code Genome, based in (city name) Montreal, the world leading (whatever it is you do) Ruby On Rails consulting firm, is looking to hire (position name) a Ruby On Rails developer for its (adjective) star team.
(Mad Libs are are the ultimate tool to create a job posting.)
Ruby on Rails Guru
We are looking for a Ruby on Rails guru. You have a couple of projects under your belt (a black one). Everything you ever wrote ended up in a plugin. You’re just that good. You should be the one writing this job description and telling us what a real Rails guru is all about.
Ruby on Rails Refugee
We are looking for a Ruby on Rails refugee. You have a couple of years of experience in web development in Java or .Net. One night, you built a small project in Rails, wanting to know what the hype was all about. It was love at first sight. Now, you loathe your day-time job and all the unnecessary complexity involved. It’s time for a change.
Ruby on Rails Guru-to-be
We are looking for a Ruby on Rails guru-to-be. You have built at least one small project in your spare time using Rails and fell in love. You are now aspiring to have an international career as the next rock star of ruby development. But you need someone to give you a chance.
For more information, visit http://jobs.codegenome.com
One more thing. The best part of this job is that you get to work with me, the only ruby witch doctor in Montreal. Oh, and if you feel guru is overused, you get to call yourself whatever you want: ninja, kung fu master, sith lord, drunken monkey cowboy of hell, papa smurf, or the ultimate, zombie ninja pirate. Nothing beats a zombie ninja pirate.
Popularity: 16% [?]
It appears that Rails will switch to git real soon. Nice! However, it means confusion for developers used to svn. You might find a few tips on this blog to help you get started, but right now I want to give you the secret to git mastery:
You need to think in terms of how you want to modify your graph. My what you say?!? A git repository is a directed acyclic graph of commits (the nodes). Huh?? Read this article: Git for Computer Scientists. Do not continue reading before you understand that article. Everything falls into place when you understand that all git commands manipulate these four basic structures: blobs, trees, commits and tags.
From now on, before typing a git command in the shell, try to picture in your head how you want your repository to look after the command. Your best friend is gitk for visualization (use the –all option to see all branches). Run it before and after each command you do with git. Here is what you should be thinking when using these commands:
- git commit: I am creating a new node in my graph, linked to the current node.
- git branch branch_name: I am tagging a node with a name.
- git merge: I am creating a new node that will link two parents nodes, one for each branch I am merging (could be more than two).
- git fetch remote_repos: I am adding all the nodes from a distant repository to my graph.
- git push: I am sending all the nodes I created to a distant repository.
- git pull: I want to fetch all remote nodes AND merge.
Once you think like this, “advanced” git stuff becomes trivial. For example, this morning one coworker realized that his last three commits actually belonged to a branch. Try to visualize the solution. When you think about it, nothing has to change about the actual graph, just which nodes the tag (the branch name) needs to point at. So you just create a branch where you are, on the last commit, and then you can use the reset command to move back the other branch to the correct commit.
That’s the core of git. There are maybe two other things to worry about when using git. The first is the index, which is sort of a staging area where you prepare your commits. The other thing is the way git configuration works and the way it names and references branches (and the special reference HEAD) and remote repositories. Check out the git user manual.
Popularity: 30% [?]
Rails developers will switch to Git because just like Rails is ten times better than any java( or .Net) framework, git is ten times better than subversion.
I will be presenting git at the next Montreal On Rails. You may want to wait for my presentation to switch to git, but that means going a whole month without benefitting from git’s awesomeness. So here are a couple of links to get you started:
- Linus Torvalds presentation on git at Google: You NEED to listen to this talk to change the way you look at source control and understand why git rocks so much. Linus is great and funny in this talk. Warning: he will call you stupid.
- Peepcode screencast on git: Peepcode rules and this screencast will show you how to use git. It costs 9$, but if you were at the last Montreal on Rails, you should have a special code to get one screencast for free.
- Using Git to Manage and Deploy your Rails Apps: Here’s another screencast that will walk you through setting up a new rails project using git, setting up a git server and then deploying with capistrano (capistrano 2.1 supports git for deployment).
- Setting up a new Rails app with Git and Setting up a new remote git repository: two excellent and detailed walkthrough.
- Why distributed version control: Very good explanation of the advantages of git.
- Using Git for core development and Using GIT for Rails Development: Two other very good tutorials.
- Git tutorial and git svn tutorial, two tutorials from the official site.
That should be enough to get you started. Make sure you listen to Linus’ talk. It’s one hour long, but it’s definitely worth it.
Popularity: 28% [?]
Dan Webb has very very interesting presentation called Metaprogramming Javascript. I think it’s the most simple and understandable explanation of how the diffferent javascript frameworks extend javascript. It takes five minutes to go through and you gain a better appreciation of javascript’s simplicity and power.
Here is another presentation to put your new knowledge to test that builds a small DSL for working with forms that allows for something like this: show(“province-field”).when(“country”).is(“Canada”).
Popularity: 11% [?]
The problem:
Having logic in your view is bad. Putting some in the helpers can help. Some methods can be put on the model. Sometimes, your view involves a couple of models, the helpers get bigger, you’re not sure on which model to put a method as it needs data on a few of the associations. The view is getting ugly, you have to go through pages of helper methods to find things. You’re feeling dirty.
The solution:
Move all the methods related to one of the view to a class (the presenter). Create it in the controller by passing it all the objects it needs to manipulate. Change your view to only call methods on your @presenter.
Implementation:
You will probably want to have access to the ActionView::Helpers::* in your presenter so it can useful to declare a base presenter class you will inherit from like this:
class Presenter
include ActionView::Helpers::TagHelper
include ActionView::Helpers::FormHelper
include ActionView::Helpers::FormTagHelper
include ActionView::Helpers::FormOptionsHelper
include ActionView::Helpers::DateHelper
include ActionView::Helpers::JavascriptHelper
include ActionView::Helpers::AssetTagHelper
def intialize(controller)
@controller = controller
end
end
Some helpers need the @controller to do their magic.
Success stories:
I’ve used this approach two times now. Last time, I had a view that showed deeply nested data (parent => children => children => children). There were a bunch a checkboxes that needed to be all checked/unchecked at the same time depending on which element was clicked. Putting all the methods required to generate the checkboxes with ids and class and restoring that from the params in case of an error was ugly. However, that ugliness was nicely sealed in a class that prevented infection of the rest of the code.
Further links:
- Jay Fields Thoughts: RailsConf Europe 07: Presenter Links
- Simple Presenters
- Model View Presenter Pattern
- Jay Fields Thoughts: Rails: Rise, Fall, and Potential Rebirth of the Presenter Pattern
- Giles Bowkett: My Version Of Rails Presenters
Warning:
The approach I described here may not fit the original presenter pattern as described in those other links. What’s important here is, if your view is getting ugly, hard to test, you have too many helpers, or the code is starting to smell, you can move stuff to a new class. This may seem evident, but I sometimes feel people using rails forget that you can do stuff “outside” of the way rails normally structure a project. Also note that the presenter pattern is definitely not something you need for every project.
Popularity: 13% [?]
One of the best books I’ve read about design is Domain Driven Design: Tackling Complexity in the Heart of Software, by Eric Evans. InfoQ has a small ebook called Domain Driven Design Quickly that provides a nice summary of the book. It was a good refresher for me as I read DDD about three years ago.
So What is Domain Driven Design? Read the link to have a good overview. Here are the two most important points:
- Focus on modeling the domain and domain logic of your application.
- Build a “Ubiquitous Language” that is used by all the team (from domain experts to analysts to developpers).
The most interesting part of the book for me was the patterns presented as the basic building blocks of a model-driven design: Layered Architecture, Entities, Value Objects, Services, Modules, Aggregates, Factories, Repositories. These are all very simple but fundamental patterns in software development. These are types of objects that are present in all designs. Understanding the difference between a value object and an entity is crucial and can help simplify a design.
The book also discusses the importance of iterative design, the importance of incorporating back what you learned about the domain in the model as you iterate and how to preserve the integrity of the model. There is a good discussion of ways of separating the model as the team gets bigger.
The value of this book for a Rails developer
Ever heard about skinny controller, fat model? This is THE book about building a rich model.
However, it really depends on the type of application you’re building. Most Rails application are mostly concerned about CRUD operations without too much logic behind. You won’t get out much from this book.
But if you’re working on a business app with a lot of business logic, then this is a must-read.
The ebook also has a small interview with the author. He highlights the expressiveness of ruby and mentions that DSLs are probably the next big step in Domain Driven Design.
Popularity: 31% [?]