February 9, 2012

Prototype library – dissected

surgical tools Prototype library   dissectedThanks, Jonathan Snook for creating such a useful (and gorgeous) set of printable reference sheets for the excellent Prototype library for Javascript.

I use Prototype to support almost all my Javascripting on the net, both at work and on personal projects. It is a great library, and this reference just makes it clear how clean and well laid-out the library actually is.

[tags]javascript,prototype,reference[/tags]

Javascript Programming Conventions

chain Javascript Programming ConventionsI’ve been meaning to write a Javascript “best practices” style guide for some time. Bad Javascript is just so painful to read and so easy to find that it brings a bad flavor to the whole language. I might be exaggerating, but only a little.

The Dojo Javascript Programming Conventions just released recently makes the first part of that article no longer needed.  I agree with all their suggestions.  Ok, not all, but most of them.  Basically, I agree enough to modify my own style just to have a standard to follow.

Javascript is such a fun and powerful language, and it has really come into its own with the rising popularity of “Web 2.0″.  It is high time for programmers to treat it like we do any other “real language”, with standards, best-practices, and excellent toolkits.  Dojo and Prototype are leading the way, in my opinion.

[tags]Javascript,dojo,standards,coding standards[/tags]

Fresh design examples

searching magnify Fresh design examplesWeb Design From Scratch has a nice, well illustrated article on Current Style in Web Design.

Of course, I don’t want to advocate always running with the herd, but in this case I’d argue that it isn’t so much the herd, but more of a pack. OK, so that isn’t such a great metaphor. What I’m trying to say is that I think the sites they mention exemplify some of the best, freshest sites on the net, and that I personally take a lot of inspiration from them.

I think the first thing I’ll do from this list is to lighten up my various sites templates a bit, making the page less “weighty”:

The great sites above share the following design features:

  • Simple layout
  • 3D effects, used sparingly
  • Soft, neutral background colours
  • Strong colour, used sparingly
  • Cute icons, used sparingly
  • Plenty of whitespace
  • Nice big text

[tags]design,layout,web design[/tags]

Logging is good for frameworks too

log Logging is good for frameworks tooOne thing I just don’t understand is why more people, especially framework designers, omit or skip logging. Django appears to, which is incredibly annoying to me. It is a complex framework, which makes all kinds of assumptions and relies on convention to infer a lot of functionality. That’s great, but being able to “turn up” the log-level and see some discussion about what decisions it is making, based on what criteria it is using would be incredibly valuable to me. Not only to me, I wager, but to everyone who is learning the framework, or who is teasing out a difficult bug. Yet going in and adding framework-level logging is almost impossible, even on an open-source project, since your changes will not be accepted and will quickly become a merge nightmare.

Don’t believe me about changes “not being accepted”? Here’s proof. (That’s not my bug, by the way, just proof). The developers closed the ticket saying they “fail to see what this gains Django”. Foolish and shortsighted.

Logging is preferred by most senior programmers over line-by-line code stepping. It is both more efficient, and allows for post-mortem analysis of problems in a way that debuggers never will. Yet many act as if it is a nice-to-have, or worse an irrelevant distraction.

Shortsightedness is deadly

I once worked on a team with a programmer who refused to add any logging to a super-awesome-framework he’d written for Java. Evidently the framework was the solution to everything we needed. I challenged him in a team-meeting about his refusal, talking about the numerous benefits of good logging throughout a system. He replied “I don’t write bugs, so I don’t need to waste time logging to find them”. I had him fired, and good riddance, within a week. Attitudes like that have no place on a software team. It was his foolish assertion that he didn’t write bugs that was the final nail, but his refusal to see the benefits of logging certainly didn’t help his case any.

Logging is built-in to Python, and is a commonly available module for Java. It is high time to make this practice part of generally accepted programming standards for frameworks. Don’t want a log? Turn it off. But you should always be able to get one. Always.
[tags]logging,java,python,django,rants[/tags]