ramblings on PHP, SQL, the web, politics, ultimate frisbee and what else is on in my life
back 1  2  »  

Dr. Strangelove or How I began to worry about convention over configuration

I hope you all have seen Dr. Strangelove by Stanly Kubrick. I gave a copy on DVD to my uncle for Christmas and we saw it together the other day. Hope you gives forgive me this minor give away from the story. Just skip ahead to the next paragraph if you have not seen the movie yet. In one scene the Russian Ambassador mentions that the Russians have build a Doomsday Machine which would automatically destroy all life on the surface of the planet if a nuclear deceive was to explode over Russia. Their line of thinking was that this way they could get out of the arms race with the Americans, which was ruining them. Of course the entire idea of such a machine was that the other side knows about it and therefore will never attack. Unfortunately the Russians had released the Doomsday Machine, but had held off announcing it to the world for a later occasion.

Now I have been starting to use of those "convention over configuration" frameworks since about 2 months now. And I can see the power. Every convention I have figured out seems to cut down on code a lot. However the problem is that there are just a lot of conventions to remember. So I keep forgetting some. I also by far still do not know all of the conventions of said framework. There are some very nifty overloading magic tricks in the framework. If you know them its amazing how enabling one thing can magically transform your API. But if you don't, then you sit there wondering how to do the obvious. The API docs do not cover these optional transformed method signatures.

So what I am wondering about. Is saving those lines of code really worth the constant wtf?-learning curve? When will I really know enough about the framework that I actually feel more productive because I do not have to code all the details? In the past I had my own framework. It had its own conventions obviously, but I would claim it was a lot less surprising. Also due to cut and paste from my default project, most of the configuration was done already as well. But all the configuration was there for me to read and look at if I forgot things. And yes you even forget about stuff you have written in your own framework .. its even worse with someone elses. As you can see from my example the framework I am using is taking this entire convention thing way beyond just covering conventions over file or database table names.

So with these comments I turn towards my audience. The "configuration over convention" thing has been around for a while now, what are your experiences with it .. what am I missing maybe .. what could be improved?

PS: If someone has a good URL describing "convention over configuration" I would love to add it to this article. All the ones I found from a quick search were too specific to a framework.

PPS: I had a (freudian?) typo where I mixed up the words "configuration over convention" which should have been "convention over configuration"

Comments



Re: Dr. Strangelove or How I began to worry about convention over configuration

Cake PHP?

Re: Dr. Strangelove or How I began to worry about convention over configuration

For me support for creating reusable components/modules (however you call it) could be improved. Though, I'm a bit biased.. But the more I think about how to make it better the more I get into real time problems.. so for now I leave everything as it is... ;-)

Re: Dr. Strangelove or How I began to worry about convention over configuration

Try Agavi :)

Re: Dr. Strangelove or How I began to worry about convention over configuration

After looking into SVN: No I won't. Don't know who copied 75% from whom, but Symfony looks nicer. ;-)

Re: Dr. Strangelove or How I began to worry about convention over configuration

Hi Lukas. Here's a quote from the wikipedia entry for Ruby on Rails explaining "convention over configuration"

'"Convention Over Configuration" means that the programmer only needs to define configuration that is unconventional. For example, if there is a Post class in model, the corresponding table in the database is posts. (Note that Ruby on Rails automatically pluralizes the table name based on the model name.) Thus, using Rails' conventions when developing a web application from the ground up reduces the amount of code that needs to be written.

Defaults can be over-ridden. For example, if the table is unconventional (e.g. blogposts), it can be specified manually (set_table_name "blogposts"). Rails can be configured to use a legacy database with an unconventional schema, albeit with more code than a conventional approach.'

If you're coming to php|tek in May I'd be glad to talk about it with you some more. I'm the guy giving the "What can PHP Learn From Ruby on Rails" talk.

Re: Dr. Strangelove or How I began to worry about convention over configuration

Yeah, I will be there. Actually I think I already partially sat in your talk at php|works, though I was mostly busy with other stuff .. shame on me.

Like I said I do see the power of the convention approach. I am just not sure that the steep learning curve is worth it. With things moving on so fast, new shiny frameworks come and go. But it seems to me like learning a convention based framework is harder than learning a new programming language. Convention feels like black magic, eventually you learn to wield it I guess, but my that time even blacker magic is wielded by yet others ...

Re: Dr. Strangelove or How I began to worry about convention over configuration

Yes, I agree that you have to spend some time figuring out the conventions. Personally, I have noticed the speed gains the next time I start a new project or go back and refactor an existing one. I just find that a lot of the stuff I used to write for myself over and over again (code reuse being a problem when youve shifted employers and don't own what you used to use) is there in the background as "black magic" and I can concentrate on solving logic problems or worry about making something look right with CSS, etc.

I suspect that "convention over configuration" gives a speed boost to experienced developers, no beginners. After all, how can you measure the boost if you've never done it the hard way yourself before? ;)

Re: Dr. Strangelove or How I began to worry about convention over configuration

I'm not convinced either. I have to be missing something, but when I've tried with Rails/Django it's not been productive. Perhaps I'm just too familiar with PHP, but there's a lack of flexibility I miss.

Re: Dr. Strangelove or How I began to worry about convention over configuration

@Chris: Well code reuse is a different topic really. You can reuse code without going down the convention over configuration path. Like I said, in my old projects I ended up reusing most of the configuration files as well. But there was always a configuration file I could look at and say .. ah this is what I configured. There was not wtf? why is this template loaded?

Anyways I will continue learning the ways of convention over configuration in my current project, which will last until August. We will see if I will be converted to conventions by then :)

1  2  »