Monthly Archives: June 2008

A One-Question Job Interview

Interesting article on the perfect interview question.

When reviewing somebody else’s code, what is it that you usually find most disturbing?

Here is the answer key:

An answer about syntax is a bad sign, and an answer about design principles is a good sign.

Definitely worth a try!

Here are some other questions I’ve heard in interviews that are useful to discern personality, experience and intelligence:

  • What are you looking for in this job that you don’t have in your current job?
  • What interests you about this field and language of programming more than other fields and languages?
  • Tell me about the something that was very difficult for you to learn and why.
  • Do you consider yourself more of a fast programmer or more of a meticulous programmer?
  • On a scale of 1-10, how would you rate your interest in this position? One being “no thanks” and ten being “this is my dream job!”
  • What kind of work do you see yourself doing 5-7 years from now?
  • Which is better: client-side validation or server-side validation?
  • If you were to start an application from scratch, what code frameworks or approaches would you use and why?

Compiled JavaScript Templating

Using a find-and-replace template system is often very useful. In Prototype JS, there is a built in class called Template. But for larger html blocks that need basic template logic and formatting functions, compiling the template is fast and robust.

I’ve got my old version of CompiledTemplate online in a Pastie. It’s got the source and a simple example. I need to finish my new version and do some benchmarking.

It actually isn’t often useful since it is usually better to generate content on the server side.

Flexible, Grid-Like Layouts in CSS

Update: I’ve made some comments on cssnewbie.com talking about how this technique is useful for magazine-type layouts and is actually more semantic in that case.

Just when you assumed that everything that could be done in CSS has already been done, the geniuses at A List Apart have really come up with a potentially revolutionary technique.

I haven’t yet wrapped my head around it, but Eric Sol has posted a wonderful A List Apart article about achieving flexible, grid-like layouts in CSS.


Example of Faux Absolute Positioning in action. (by Eric Sol, A List Apart)

The basic idea is to use position: relative; left: 100%; margin-left: -##% (non-percent units such as px also work). Eric calls the technique “Faux Absolute Positioning”. The items generally have the same behavior as inline elements and avoid some of the fragility of floats. Eric explains the inspiration for the technique:

Our use case was even more complex: my team was developing a web-based WYSIWYG form generator that allows the user to drag items to arbitrary locations on a canvas. We needed to let our users create beautiful forms that didn’t use overly static layouts and to let them align columns as needed.

For example, let’s assume we want a form that puts the postal code and city fields on the same line because they are semantically connected. To accomplish this, we tried using floated positioning inspired by the Holy Grail technique. Using this method, we needed to adjust the width, borders, margins, and/or padding of the postal code field to pin the city field to a fixed horizontal position. That was a problem because if the width of the postal code field needed adjusting, or if we wanted to adjust the amount of whitespace between fields, the city field would need to move as well. The more elements on a page–the more cells in your grid–the more tedious this kind of adjustment becomes. Additionally, the positioning is sensitive to the slightest change in a number of parameters, which makes it nigh impossible to control in case of dynamic form items.

Next, we tried using absolute positioning. This gave us much more control over the positioning of the items and is robust. But absolutely positioned elements have no height, and that caused the containing element (the canvas) to collapse. This made it hard to position content without making everything absolutely positioned–which is impossible to achieve with dynamic content.