Archive for May, 2006

Fun with Fixtures

Thursday, May 18th, 2006

Fixtures are a neat feature of Rails. However there’s a small caveat that pops up when your classes don’t follow the conventions and use a table whose name is not a pluralized version of the class name, e.g. the class is `HorseShoe` and the table name is just `shoes`. The corresponding fixture would have to be name shoes.yml and included in the test case with `fixtures :shoes`. Now as soon as you try to access one of the fixtures through `shoes(:iron_shoe)`, the fixtures code will try to look up the class name to instantiate it. With the default conventions it will look for `Shoe`. To avoid this, I found one way (probably not the only one) to tell the fixtures code what class to use. After defining your fixtures you can tell it which class to use for which fixture:

class ShoeTest < Test::Unit::TestCase
fixtures :shoes
set_fixture_class :shoes => “HorseShoe”

end

The call to `set_fixture_class` will merge your custom table-class mapping into its own, and whenever you’re trying to access one of the fixtures, it will default to your configured class instead of the singularized table name.

As I said, this probably isn’t the only way, but it is one way I found while browsing through the fixtures code.

Enjoying a New Kind of Freedom

Saturday, May 13th, 2006

Thursday was my last day at my regular job. Felt kind of weird, but it felt good. I won’t delve into details too much here, but I don’t regret it. The future is too exciting right now. Working with Rails for a living (to a certain extent) is great. Good to know that I’ll be working with it for the next couple of weeks or even months. Geoffrey Grosenbach (of Ruby on Rails Podcast fame) just wrote an article for O’Reilly Ruby about working fulltime with Rails. Good stuff.

While I can’t wait to get into my new office, it’s nice to have some time at home and in my Kiez (the Boxi on the linked Wikipedia page), especially on a nice spring day with a lot of sun on the balcony.

As a nice reward for the end of my normal day job, I ordered the shiny and new 17″ MacBook Pro. Can’t wait to get my hands on it. Hopefully IDEA will ride fast as lightning on it. Some speed is very appropriate after spending almost two and a half years on my first generation iBook G4.

I also signed up for RailsConf Europe in London. Really looking forward to this, because I’ve never been to a conference before, and because I’ve never been to London before. An 8-hour stay at Heathrow waiting for a flight to Melbourne probably doesn’t count.

For the soon-to-be-founded company I’m thinking about writing a small CRM tool in Rails. I’ve looked at SugarCRM and friends, but it’s too bad that all those tools are way overbloated for smaller companies or freelancers. If you know anything smaller, let me know. The 37signals guys apparently are working on something, but nobody knows a release date. Well, if worse comes to worst I’ll get some more Rails experience and maybe release it as a small open source project ;)

Technorati Tags:
, , , ,

Ruby on Rails - Looking past the Hype

Monday, May 8th, 2006

For about two years now, Rails has been in our lives. It has arrived sort of violently and with a lot of buzz. Some say it’s all bullsh**, others love it to death, just like with every new technology. Both sides have their points. But the important thing is, does Rails have a future?

Right from the beginning. Rails has been dismissed as a toy and bitched about, especially by the Java community. Is it fear? Is it ignorance? I’m not quite sure. Maybe it doesn’t even matter anymore, because those voices got quieter over the last few months. And you don’t even have to look far to find some influences. Although Rails as a framework has its downsides (surprise!), it quickly influenced a lot of other frameworks, including Trails, Grails (I’d suggest finding new names), CakePHP or TurboGears.

Concerning the downsides, it seems that the first thing people looking for is negative things. Rails can’t do this, Rails can’t do that, you heard it. That’s an easy and comfortable way to do things. Pointing out the obvious is simple, suggesting an improvements or asking why it’s been done that way is another. Granted, David is quite picky about how things are done in Rails, but hey, you can always write a plugin. What I’d wish for are sayings like “Why isn’t this done that way, I/we could achieve <insert-some-cool-and-money-making-feature-here> if it were”, and not “I hate Rails, because it does xyz not the way <insert-some-other-framework-here>”. There’s always a reason, and granted, if it’s not implemented the way you like it, there are two possibilities, either you’re looking at things from a too technical point of view, or you just shut up and move on.

In technical terms Rails is still quite young, having reached v1.0 last summer. Does that mean anything? Probably not, since all technologies add up to what is Rails are only glued-together components that build up on existing knowledge and technology. That’s what surprises me. People bitch about it although it’s not really anything new. They use similar frameworks in their applications, be it Hibernate, WebWork, EJB and whatnot. Granted, Rails as it is has been a little over-hyped, for that matter. But in the end, it’s not ground-breaking news (which, of course, nobody said it would be ;).

So set aside all the good and the bad, the question still is, has Rails already reached its tipping point? Has hype become mainstream? From a technological point of view, I’d say yes. Rails as a combination of good practices and existing technologies (as in ways to do it, not frameworks) is definitely on the right side of the bell curve. The conservatives already have taken over what’s proven to work. But Rails as a framework is what I’d say still a tool for early adopters. I don’t mean that in a negative way. Rails is being adopted by more and more people, who are curios, or sick of other, more heavyweight ways to do web development. Some people already are convinced and do all their web development with Rails. Good on them! Others do it for fun (and maybe a little profit). For the time being I see myself as one of the latter.

The wide adoption of Rails is still to come, if at all. I’m not being negative here, but it’s a possibility that a new technology will never be adopted by a broader audience. Some would probably love to see Rails fall, others to see it rise to the tipping point. It’s hard to predict when the tipping point will be reached, but what isn’t? I’m not sure, if I’d fully count on Rails for starting or running a business, but I’d definitely include it in my portfolio. Don’t get me wrong, I’m keen to see where Rails will be going, but for the moment I’m planning to stay with at least one leg on the J2EE side of things. Although I gotta say, sometimes I feel a little confused, when I come back from some Rails hacking, back to working on Java-code. It’s all so complicated and unexpressive ;).

So it’s not up to me to decide what the future has in stock for Rails, it’s up to the masses. If they won’t get acquainted with the Rails way of things, and start using it on more and more projects, Rails will not hit the mainstream. If that’s good or bad is up to you. I’ll be there celebrating, if it happens. And for the time being, I’ll make a living of both, J2EE/Java and Rails.

And meanwhile, you might wanna register for RailsConf Europe. See you there.

Technorati Tags:
, , ,

Second Edition of a Rails Classic

Thursday, May 4th, 2006

Why, what’s that in my mailbox? Oh yes, it’s the first beta of the shiny and new second edition of “Agile Web Development with Rails”. It’s in the works of being updated for all the glory features of Rails 1.1, including RJS-Templates (which are awesome, by the way), migrations, Capistrano, etc. The beta program will work in a way that the first edition will be transitioned to the second page by page. The second edition is already at almost 600 pages. The chapter on installation got a complete overhaul, including more detailed database setup, available editors, stuff like Instant Rails and Locomotive. Will be great to see it growing, and slowly transition into the second edition.

And now the covers features a picture of one of my favourite hobbies, too ;)

You can buy the book as a beta PDF now, or with the dead-wood edition when it’s finished. If you desperately need the paper edition, you can buy the transition combo including the first edition as paperback and the second edition as PDF.

In other (slightly older) news, the Radium CMS has gone public.

Technorati Tags:
, ,

Ramping up the Bookshelf (for Fun and Profit)

Monday, May 1st, 2006

Spring (as in season, not as in framework) is always a good time to get some great new books to read in the sun (if you dare exposing your geek-skin ;). To be prepared the books are slowly piling up on my shelf. It’s sad though that they’re not including the time to read them. The main focus at the moment is AJAX and Rails, so let’s see what’s in stock.

Manning just released two great books: “POJOs in Action” and “Ruby for Rails”. The first one sounds like a no-brainer on first look. If you dig deeper, you’ll see that this book is about a lot more than just POJOs (you could write a short Friday book about these in probably a day). It’s about current lightweight frameworks like Hibernate, Spring, JDO, iBATIS, and, to complete the circle, EJB3 (though I don’t consider EJB3 to be lightweight, but that’s probably a different discussion). EJB3 is mainly included to make the reader see what solution xyz would look and work like with the next generation of JEE. The book is an excellent read and gives a nice overview about all the technologies, and how to design lightweight “enterprise applications” (ah, I love that word) from API to locking and transaction strategy.

“Ruby for Rails” goes into the complete opposite direction. Though its main focus is also lightweight web development, it’s Manning’s contribution to a growing stack of available books on Rails. It covers both Ruby and Rails, and also how they work together, which is probably the biggest plus of this book. If you’re stuck with ideas on how to move on after reading “Agile Web Development with Rails”, this book maybe is for you.

Of course, The Pragmatic Programmers don’t sleep. They’re on the edge of throwing out “Rails Recipes”, a nice collection of small recipes (surprise) about different parts of Rails. It covers a lot of different aspects, and though some consider it more like a collection of entries in the Rails Wiki, it’s still a good composition and easier to use and read than the Wiki. It includes e.g. versioning, of course AJAX, tagging, security, testing, and a lot of generally applicable recipes. Have a look at the TOC for the bigger picture. It’s still a Beta Book, but it reached RC1 a week ago and will probably be released soon.

Next up is “Pragmatic AJAX”, also by The Pragmatic Programmers. Having just left the beta cycle, it stands in firm line with the other popular books on AJAX, like “AJAX in Action” or “Foundations of AJAX”. All three jointly took a seat on my shelf and wait to be read. Looking forward to reading all of them.

Last but not least, and fresh from the press, say hello to “Practices of an Agile Developer”. A book which joins the shelf of books on best practices for the everyday-life of a developer. It’s a close companion to the original “Pragmatic Programmer” and “Ship It!”. Though I’m not so fond of the word “Agile” anymore, the practices in it are still very applicable.

What I’m reading with the most interest right now is “Eric Sink on the Business of Software”. While focused on small ISVs, it’s still a very good book with stories from someone who succeeded with his own company despite making a lot of mistakes (which he’s happy to share). Very entertaining read and also full of good advice.

I’m already working on some of these books, and can say with confidence, that at least “POJOs in Action”, “Ruby for Rails”, “Business of Software”, and “Rails Recipes” are highly recommended.

Those aren’t the only new books, of course, but I reckon it’s enough reading material for the next weeks ;)