Opinionated Software, The Podcast

A while back I was contacted by Cal Evans over at the Zend Developer Zone to contribute to a new podcast he was starting up called PHP Abstract. Very cool idea, a small 5 to 7 minute podcast by PHP developers where they talk about a topic of interest to them (and hoepfully to you). Well, being one to never miss out on an oppurtinity to promote myself I agreed to contribute what I could. I settled on a brief talk about opinionated software. Also known as “convention over configuration” by the Ruby on Rails crowd.

Go over and have a listen and don’t be shy in sharing your feedback via the comments there or here. Opionated software / convention over configuration / tools with rules is a powerful yet misunderstood programming practice.

What’s Chris Thinking About, February Edition

My apologies for the lateness (and shortness) of this post. Real life has intruded this week. More news on this later. But here’s what’s jumping around in my brain:

  • Nate from CakePHP is helping me out with the work on my proposal for an interactive console. Trax (a Cake “competitor”) has an interactive shell so I’m taking a look at how they are doing things to see what I can use from it. Thank you open source licensing!
  • There has been great feedback from those who watched the screencast of my talk from Vancouver and I’m going to tweak the talk for May. Remove some slides, avoid duplication and build up the parts that drew a lot of interest: deployment and programmer ego.
  • I’m going to have to dive into the slightly old Typo install and figure out how to stop the huge amounts of trackback spam we’ve been getting. Seems that the Typo install I’m running ignores requests to stop accepting trackbacks. Gotta fix that by hacking at the source

Rallyhat.com — moving forward

I’ve gotten some work done on Rallyhat lately, mostly on the train ride home but some stuff in the evenings when I need an internet connection for looking up some sites and testing. Here’s what I’ve gotten working:

  • User signup (complete with email and activation code)
  • User authentication

The next thing I’m working on is the Hunt stuff. I’ve got to write some code to create hunts, allow people to join up with a hunt and stuff like that. As part of that I will also have to do work on the image upload and storage part of the site, which has me worried due to potential bandwidth issues, but I might use Amazon’s awesome SSS for that and see what the bills are like. Along the way, I’m writing unit tests to go with my code because when my current host upgrades to Rails 1.2 I want to be able to do the same at my end, and a simple “rake test” command will run all my tests and point out anything that will be broken and needs to be fixed. I suggest that interested parties go to the Rails blog to see the latest news about Rails 1.2

Application authentication

On the CakePHP mailing list I see frequent questions about various ACL and authorization plugins that are available for cake. I’ve never used anything beyond simple authentication and access control and always felt that ACL schemes were either too hard to implement or too restrictive. Honestly, do you really need to have one person who can see 5 reports and another see 6? I never saw the point of that, but perhaps one day I will run into a scenario where that is needed.

Rallyhat needed some authentication. Being a Rails app, there were tons of options. Basically, they revolve around the same principle: there is a feature called a before_filter that runs before you execute any action in a controller. Lucky for my fellow CakePHP users, there is a similar feature in CakePHP. So, you create a function that you call via the before_filter (beforeFilter in CakePHP) that verifies that the person has permission to access the current controller. Yep, it’s really that simple.

Of course, there are many varied ways to do the whole login / assign roles to users, too many to list here. Don’t expect any code here either, as I haven’t written any. Like any lazy programmer, I steal from the best. ;) For Rallyhat I’m using Rick Olson’s awesome acts_as_authenticated plugin. Man, it is PERFECT for what I need. You install the plugin, head over to the stikipad where the documentation is and it gives you just about everything you need. Signup, login, activation codes, email confirmation, “forgot my password” stuff. I can’t imagine how much time this has saved me. Oh yeah, on top of it it comes with tests to make sure everything is working. Make a change, run ‘rake test’ and fix any errors that pop up. Rallyhat will require a full commitment to writing tests, so I’m glad to get into the habit of it.

So, if you want some simple authentication then if you’re using CakePHP, fool around with using a beforeFilter to do things like look for a cookie or look in the session for a variable that says you are logged in. Authentication doesn’t have to be complicated, it just has to work.

How Has Ruby on Rails Made Me A Better Programmer

Via one of the RSS feeds I read I found out about an interesting contest where people are asking to post their thoughts on how Rails has made you a better programmer. The winner gets a free book. I thought “What the heck, I don’t care if I win the book but I do need a posting for today.” :) So, here goes.

Although my day job involves programming in PHP, my experiences with Rails have been completely transferable. Discovering Rails showed me a bunch of new tricks that have streamlined the way I program. There’s no shame in stealing good ideas from one language and applying them to another, and anything that can make me a better programmer is a bonus for me. Learning Rails prompted me to start talking about my experiences with it, and has led to giving talks at conferences and a magazine article. I can say with no hesitation that Rails has brought nothing but good things to my career as a developer.

Convention over configuration is the biggest thing I have taken away from Rails. PHP’s greatest strength is that it is flexible, allowing you to accomplish all sorts of things and build rock-solid web apps (yes PHP haters, Yahoo! is an example of rock-solid web apps that use PHP). However, that flexibility comes at a price. You can easily co-mingle your business logic with your data sources, with a splash of display logic built in. We’ve all done it. Why? Because PHP says “I don’t care how you do it, but I’m going to give you the tools to do so.”

In the Rails world, you are programming within a system that has rules, or conventions, on how to do things. To me, Rails is saying “If you follow some simple rules about how to build your application, I promise to take care of a lot of low-level details and let you get back to the process of just building things.” Some other developers have argued that this concept is akin to having to learn a new language (or perhaps even harder), so what advantage are you really getting? I believe that once you learn the conventions, your will find a rapid increase in your productivity. With so many developers talking about the increase in productivity they felt when switching to Ruby on Rails from other programming languages, there has to be something to it beyond just hype.

Ruby’s syntax and object-oriented nature has shown me that simplicity matters. Too often I’ve worked on a piece of code, got it working and have then abandoned it for the next project. Now, I take the time to go back after I’ve gotten it working and to see what I can strip out, what I can rewrite, what I can improve to make my understanding of the problem better. I’ve been working with CakePHP for my recent “build-from-scratch” projects in PHP, and being a Rails-inspired framework a lot of the concepts have been totally transferable. I find myself building out prototypes faster with Cake than if I banged out the code myself. The code I create reads differently than the hand-crafted stuff I did before and I find it easier to go back and fix stuff after my memory has dimmed on how I solved a particular problem. The simple the code, the more likely I’ll be able to figure out what I did in order to fix it or extend it.

Finally, I realize that Rails has set a standard for the next generation of modern web development frameworks. Full-stack solution based on the underlying programming language? Check! Extensive selection of information available via Google for beginners? Check! Loads of helpers for creating Ajax functionality? Check! Testing tools built right in? Check! I could go on and on but I think you will get my point here. The job of a framework is to provide you with all the tools you need to build an application quickly, and Rails has shown me that any solutions I use going forward need to be held up to the same standard. So far, CakePHP is meeting my expectations in the PHP world, but Rails forges onwards with things like RJS templates and ActiveResource. Who knows what else DHH and the crew are planning. I know as I continue to build out my latest Rails-based project I’ll be keeping a close eye on developments.

Want to advertise on this blog? Send email to chartjes@littlehart.net
GTcars Canadian Car Audio TurboDodge Car For Sale Sign
Audi Forum Mustang Forum Dodge Intrepid Miata Turbo
GTscene Pontiac Bonneville


@TheKeyboard is Digg proof thanks to caching by WP Super Cache!