I love ActiveRecord. I don’t really much like working with relational databases (like Tolkein wizards, databases tend to be good at getting you out of the kind of trouble that databases get you into…).
Sometimes, though, you get a requirement that seems explicitly designed to drive both ActiveRecord and your database of choice stark raving mad. Here’s an example based on an actual client requirement (details changed to protect the innocent):
Drupal, the popular open source Web Content Management System, has got a massive and passionate community of developers, designers and webmasters. Drupal.org, their official website was faltering under the weight of this growing community of diverse users, so this past summer the powers that be at Drupal decided to hire an outside agency to do a complete redesign of the site. The firm they hired decided to take a “design by community” approach to the project. They wanted to get as many Drupal users as they could to participate in the redesign. So, through a number of collaboration mechanisms–setting up a Twitter account to follow mentions of Drupal, opening a Flickr account where the community could post pictures, and actively engaging the existing Drupal forums–they opened the design process up so that anyone in the Drupal community could share in the process.
Conventional wisdom says that design doesn’t work as a democracy. It takes the genius and inspiration of a small team or one person to understand what the customer needs, and design the right solution. As Henry Ford said it best, “If I’d asked my customers what they wanted, they’d have said a faster horse.” So I’m not surprised that according to Mark Boulton, the lead Designer on the project, many people though that this type of open process would fall flat on it’s face. I’m not convinced that it won’t, but from what I’ve seen, the site is looking good.
It’s still in prototype phase, so it remains to be seen if the redesign, once implemented, will be a success. but you can get a look at the evolution of the design here, and of course follow the links to the discussions. It’s a fascinating look at one designers experiment in design by community.
Out of all visualization frameworks for Flash Platform that I came in contact with, Flare is looking like the most customizable. I also like it’s structure. At first I didn’t, but now I love the fact that Visualizations are based on Sprites. I find that good for performance and transitions. You have to do a little extra work, but you will be happy with the result. All in all, I’m sold on it for now.
Have you often run into a situation where you have a hash full of properties and you want to either create a new ActiveRecord object (if it doesn’t exist) or update one (if it exists)?
class User # has properties: ssn, first_name, :last_name, :age, :email, :password def create_or_update_by_ssn(params) user = Disease.find_by_ssn(params[:ssn]) if user.nil? user = User.create(params) else user.update_attributes!(params) end end end
Here, the business rule states that a user’s SSN is unique, so called natural-key.
If we can identify what constitutes a natural-key for each model object in our domain-model, when we could DRY out this functionality.
As I’m sure most of you do, I am spending more and more time online watching video. So I thought I would take some time and rate the various video players I use on a frequent basis.
I’m using a 10 point scale, and I’m rating based on a both functionality and visual look and feel.
ESPN.com 7 out of 10
Fairly simple, two color, semi transparent control bar, appears only when moused over–a design pattern I’m seeing more and more lately. It’s there when you need it, it shows you what you want and it gets out of the way quickly. It’s got a single play/pause button, a timer, a playback countdown, a volume control which displays only on mouseover, reducing clutter, and a menu which when clicked brings up some additional options for embedding sharing and the like. A nice touch: Mouse over any point on the timer and you get a little tooltip that displays the time at that point. Another nice touch: the small (no morethan 10 pixels vertical) bar at the bottom which displays how much has already played as a portion of the total.
Youtube 7 out of 10
Gets the job done. Period. Simple consistent interface. Youtube also allows publishers to add annotations and captions to their videos, and naturally allows viewers to turn either on or off, with a simple hover menu at the very right side of the control bar. Youtube is actually doing some really cool stuff to allow publishers to make their videos more interactive, including adding hyperlinks within a movie. The evolution of online video will be interesting to watch (and maybe take part in) but that discussion is beyond the scope of this post.
NYtimes.com 6 out of 10
Elegant interface, but could be better. The control bar stays present throughout the video playback, and occupies a significant portion of the total video player. However its muted style–3 shades of grey–makes it easily ignored when not needed. The playback control is done superbly. When moused over, a small draggable button smoothly and elegantly appears, it’s affordance as a scroll mechanism to move to any point in the video is crystal clear. The volume control is nice and large, with the same measure of affordance, however it looks like it was designed separately, as it doesn’t conform to the rest
of the control bar’s aesthetic. Also, I may be nit-picky, and I’m sure this won’t bother 99% of nytimes.com viewers, but there’s a large empty space in between the play button on the left, and the full screen button
on the right, creating an odd asymmetry which, the more I look at it, the more it bothers me.
MTV.com 6 out of 10
Nice minimalist design. Allows you to change the video quality during playback. Also nice, allows you to choose from 3 sizes; standard, large and full screen.
Viddler.com 6 out of 10
Lets the video publisher skin the player interface. This great tools allows users to comment on and tag the video in the timeline. The interface is ugly, though, and some of the buttons aren’t self explanatory, nor do any of the buttons have tooltips. At the end of the current video it automatically plays the next video, whereas most other players present a menu of videos to choose from.
MSNBC.com 5 out of 10
Slick looking. I like the fact that the playback bar is given the entire width of the video, allowing the viewer to be more precise in navigating to a specific point in the video. The other controls are slightly confusing. It looks like the interface was over designed.
Virb.com 5 out of 10
Beautifully minimalist design. No full screen mode, but it does have a cool feature that “turns off the lights” on the rest of the page.
Facebook 5 out of 10
Fairly simple interface. Standard controls, done adequately. Its got none of the useful social media features of Youtube. No ability to tag or comment in the timeline. Pretty basic for such an important part of such an important website.
Metacafe 3 out of 10
Poorly designed. It’s distracting when trying to watch video, and ugly to look at when interacting with. The big blue shiny play and stop buttons look unprofessional, and why is there even a stop button. The draggable playback scroll mechanism moves from left to right as the video plays, but it could have been made much more subtle. There’s no need to see it unless you want to move navigate the video. And why does the entire playback bar glow when I mouse over it? Also not cool is the visually loud menu underneath the control bar.
As with any list, much o this is subjective. I’m looking forward to hearing your opinions. Also, there are so many web video players out there, this is just the tip of the iceberg. Let me know which ones you find especially appealing, or truly horrible.
handler is undefined
While not particularly threatening (no ill side effects seem to occur), the error causes a lot of noise and, quite frankly, is pretty annoying. Fortunately, there is a quick and painless patch to keep your error log free from this bane.
What’s really going to happen in 2009 that will impact all of us RIA developers? The first raft of Ajax-enable webapps will be undergoing maintenance. Supportability is the real test of frameworks, architectures and designs. How easy are they to support? How painful is the life of a maintenance programmer working on a Dojo codebase versus a JQuery codebase?
We’ve been emphasizing the use of application level MVC frameworks here of late.Why? Because we feel that the best and most sustainable metaphor for RIA’s is that of the desktop component GUI, not of the souped up webapp — client/server making its triumphant return. Without this guiding principle — that we are writing applications that consume backend services rather than backend services that display interfaces — we face escalating development and maintenance costs.
I hope then to see two front end web development trends for the coming year:
What are you predictions for the coming year?
http://localhost/~username/sites go haywire, it’s time to dig into your Apache config files
As Rails pros know, Phusion Passenger allows you to serve multiple Rails apps on the same Apache webserver instance with few configuration or deployment headaches. When you install it in your local Mac dev environment, you can easily work on a bunch of Rails projects simultaneously without having to manually start and stop individual server instances all the time. The OS X Passenger preference pane makes deployment even easier. Just add a project, give it a custom local URL, and point it at a directory. You’re good to go.
But what happens if you’re already using OS X’s built-in Apache webserver to dish up local content such as PHP applications or static HTML? When I first got Passenger up and running, all of my local sites in
/Users/<username>/Sites/ stopped working. It took a bunch of digging, but I eventually realized that something in my Apache configuration had gotten messed up during the Passenger installation process. I was missing the configuration file for my OS X user account. OS X generates this file the first time you enable web sharing for any individual user. It’s responsible for mapping your
/Sites subdirectory to localhost URLs, so that
http://localhost/~<username>/myapplication/ points to
Here’s a slightly edited version of my Twitter feed for December 23rd, 2008:
1:59 PM: Wow! Rails 3 = Merb 2.
2:50 PM: Merb is fun to say. Merb Merb Merb Merb Merb. We welcome our new Merby overlords.
2:50 PM: Also twitter added actual people search, so it’s a weird day all around.
2:57 PM: Co-worker, over IM: “I feel like the communists and capitalists just joined forces.”
2:58 PM: Let’s see… the Rails/Merb backlash should start in about an hour. The backlash to the backlash is scheduled for Tuesday.
2:57 PM: Message from @faithfulgeek: @noelrap it’s not like MS just open sourced Windows!
2:59 PM: @faithfulgeek Only, one hopes, with a lot fewer bugs
3:04 PM: @greggpollack So when do we get the I’m RoR/I’m Merb video that ends with the two of them… well, I guess I’d leave the ending up to you
3:25 PM: Am I in a silly mood because I’ve been saying “Merb Merb” for the last half hour, or am I saying “Merb Merb” because I’m in a silly mood?
What have we learned from this? A few things:
As I have discussed earlier, you can go very, very far in unit testing your view controllers using the following recipe, without the need to bend over backwards or employ any mocking frameworks:
loadViewmethod within your
This works well enough for view controllers, but when it comes time to test your application delegate, this simple approach can begin to break down. Unlike
UIViewController, your application delegate is only initialized as a by-product of loading the NIB. Thus, to get this code under test I find OCMock particularly useful.
I show an example unit test below, and discuss how I approached the problem..