While developing some javascript classes with MooTools’ new Class() pattern I found myself being mysteriously redirected from http://www.example.com/test.html to http://www.example.com/[object Object] every time I opened the page.
Turns out instead of saying
I had, forgotten the second new and written
I can’t explain the redirect, but once I added the missing new keyword everything was back to normal. This happened in a much more convoluted situation which made the missing keyword harder to spot. I guess it goes to show that you shouldn’t try to be clever, even when “just writing an unit test”.
This is one of my pet peeves. Language with prolific use of the underscore character. I have many times looked at Ruby to see what all the fuss is about and never gotten past all those damn underscores. I will never use a language that relies on underscore as a word boundary.
Underscore is not a space, it doesn’t look like a space so why bother trying? Instead it breaks logical units such as variable names or function names into units that may or may not belong together. By skimming I cant tell if that is a . (dot) deference or just a pseudo word boundary. Further more it slows down typing because you have to move your fingers way out of the normal flow.
Camelcasing is tried, tested and found divine, stop messing with it.
This latest rant was brought on by the JSSpec framework for unit testing in Javascript, which I am considering forking because of the underscores.
Next week, possibly a rant on the curly bracket character, and why it is impossible to type reliably on scandinavian keyboards. Stop using it too!
Keeping the Magpie Developer in mind, I have decided to adopt a javascript framework. After mature deliberation I decided on MooTools, here are my reasonings:
It’s in active development
It lets me maintain references to the real DOM elements, unlike JQuery.
I generally build my DOM from javascript (progressive enhancement) and so I already have references to the elements that I need. I dont need a query language (JQuery) to find my elements.
I am not looking to add glitz to my sites with a few lines of code .
I should note that this is by no means final, hell I was half way writing this about PrototypeJS before I dug deeper into MooTools and found it excellent.
Our customer has a e-mail campaing system that sends out around 30.000 opt-in emails to its customers every now and then. Nothing spectacular but it handles keyword substitution, independent operation for long running tasks, some pretty wild cyrillic texts.
Recently though sending newsletters to customers with non ASCII characters in their names stopped working, something which did work before, the only recent changes were some added tracing instructions and exception handling.
Here’s why!
Calling the ToString() method before ToEncodedString() (which is called when sending the message) will pollute the MailAddress internal state with an unencoded version of the address that is returned as a cached version on subsequent calls to ToEncodedString().
Turns out some of the added tracing code printed out the address of the receiver it was processing at the moment, triggering the bug in the framework.
Now, if I could only find somewhere to report this…