Revealing Module Pattern in CoffeeScript

My friend Colin introduced me to CoffeeScript last week through Mindscape’s Web Workbench.  As I started to learn CoffeeScript, the first thing I wanted to do is to hand translate some of my JavaScript files to see how the CoffeeScript compiler would convert them to JavaScript so I would end up with the functionally same code in the end.

I use the Revealing Module Pattern quite a bit. I found an implementation written by Burk Holland and in the comments of Burk’s post Steve Howell and Elijah Manor provided additional implementations.  Although, Burk’s example came close to what I was looking for in simplicity and cleanliness, I felt that there could be some improvements:

  • It defined the module in the global namespace.  I always create my modules in a namespace I define for the my project to further protect against naming collisions.
  • I didn’t like how the module ended with the definition of a variable to contain the  public functions.

I put forward the following:

I use the existential operator to use my project’s namespace if already defined or to create a new one.  Although, the || operator does produce nicer JavaScript output.  I’m sitting on the fence to which way to go.

I create an object as the last expression in the function that will be returned.  This skips the creation of the temporary variable that is never referenced. 

I’m pretty happy with the JavaScript that is produced.  It very closely matches how I implement the Revealing Module pattern in JavaScript, and it upholds the simplicity and cleanliness of CoffeeScript.

Print-Ready Cheat Sheets for Web Developer

Here’s a great link I thought to share.

http://www.backtoessentials.com/tools/40-useful-print-ready-cheat-sheet-for-web-developers/

It contains 40 great cheat sheets pdf links so you can download them and print it right off.

Free UX Tools and Extensions for Websites

Here’s a great blog post with the compilation of great tools if you’re a web developer.

Top 29 Free UX Tools and Extensions

I ran a few of the test on our website, and boy are there a few optimizations we could have done, especially for the JavaScript within the pages to improve performance. And also some quirks xhtml and css errors which will just make things nice and more standardised.

Microsoft Codename Volta

If Google can do it, so can Microsoft. Volta is the GWT of .NET. Enough said. Here's a description of what it is.

The Volta technology preview is a developer toolset that enables you to build multi-tier web applications by applying familiar techniques and patterns. First, design and build your application as a .NET client application, then assign the portions of the application to run on the server and the client tiers late in the development process. The compiler creates cross-browser JavaScript for the client tier, web services for the server tier, and communication, serialization, synchronization, security, and other boilerplate code to tie the tiers together.

Developers can target either web browsers or the CLR as clients and Volta handles the complexities of tier-splitting for you.  Volta comprises tools such as end-to-end profiling to make architectural refactoring and optimization simple and quick. In effect, Volta offers a best-effort experience in multiple environments without any changes to the application.

Download it here.

You need Visual Studio 2008 and .NET Framework 3.5.