Uncategorized: Posts

Error handling in javascript

I was helping someone today with their javascript and they asked me about how and when I manage errors in the classes and functions that I write. I wrote him back an email which I think actually could be useful to others, so here it is.

There are three types of error handling that I use:

  • Graceful: if possible, just ignore the error and continue with some default state or without a meaningful value
  • Debug: throw a warning to the dbug.log method but continue otherwise
  • Break: Either explicitly throw an error or (more often) just let the error that is thrown at runtime be thrown

| Read the rest »

CNET API uses: New Facebook Application

There is a new "Facebook" application that utilizes CNETs great API system. This app that was developed is called "My Tech".
Apart from the great technology use, it is a fun way to show off your latest tech gear to your friends. The best part is you can show your disdain for certain tech products if you absolutely hate it... Good times

CNET My Tech ScreenShot

"Tag line from app profile"
This application allows you to let everyone know about the latest tech gadgets available using MyTech powered by the CNET API. Facebook users can find it at: http://mytech.cnet.com

CNET Report on CNET MYtech

Upcoming changes to Mootools: version 1.0 to 1.1 changelog

Valerio posted over on the Mootools forums today a list of changes in the upcoming 1.1 version of mootools. We've been hard at work on a lot of this stuff and I'm excited to see it come out. After this version, we anticipate working less on the core framework and more on plugins and widgets.

------------------------------------------------------------------------------------------------------------
#Additions
------------------------------------------------------------------------------------------------------------

  • CUSTOM EVENTS!
  • $each also iterates objects
  • added Element::getStyles
  • added Element::hasChild
  • added Array::include
  • added Array::merge
  • added $merge, to merge objects
  • Dom.js uses XPATH in supporting browsers
  • the use of +'px' in setStyle is not required anymore.
  • added XHR::cancel

------------------------------------------------------------------------------------------------------------
#Changes
------------------------------------------------------------------------------------------------------------

  • Object.extend is now $extend, still compatible
  • Object.native is now $native, still compatible
  • Element has been splitted in Element.Events, Element.Form, Element.Dimensions

------------------------------------------------------------------------------------------------------------
#Elements Creation
------------------------------------------------------------------------------------------------------------

  • elements creation is easier: new Element accepts second param
  • elements creation for elements with name/type is easier, just use second argument.
  • setProperty for name/type are is supported anymore.

------------------------------------------------------------------------------------------------------------
#Notable Fixes
------------------------------------------------------------------------------------------------------------

  • dom logic is highly optimized and its blazing fast
  • better sortables, no more flickering, removed Drag dependency
  • Fx.Slide now accepts borders and margins. Positioning is now possible.
  • Element::toQueryString in ajax now works as intended with all Form elements, including multiple selects.
  • Element::setStyle supports float
  • Element::setProperty and Element::getProperty now supports "for"

------------------------------------------------------------------------------------------------------------
#Obvious Things
------------------------------------------------------------------------------------------------------------

  • code cleanup and optimization
  • bugs and incompatbilities fixed
  • mootools is faster, FASTER, FAAASTEEERRR

------------------------------------------------------------------------------------------------------------
#TODO
------------------------------------------------------------------------------------------------------------

  • some bugs left
  • testing
  • css3 selectors (?)
  • ???

Mootools version 1.0 tutorial - the “Mootorial” wiki

I've updated my Mootools Tutorial for the upcoming version 1.0 of the library. It (the library) is still in development, so my tutorial is likely to always be a little behind the svn, but if you're digging into Mootools for the first time, or you want to see what's different in version 1.0, here's the place to start.

I've also installed a copy of docuwiki for all my example and tutorial work. The old stuff is still there but I'll be moving it all over to the wiki. Expect to see more examples of code I've written in the coming weeks.

Mootools Extentions Tutorial

Hi gang,

To go along with the posting of our collection of scripts, I'm still writing tutorials on how to make use of all our code. Today's update is for all our extensions to the Mootools libraries that we've written.

You'll find new helper functions, new extensions to ajax, string, element, window and more. For the most part, you can just drop these scripts into your environment and they should work. If there are dependencies, you can find them listed at the top of each script.

Some examples of Mootools in action

I spotted this post over at the Mootools forums and thought I'd share. It's really amazing how much you can get out of this little library. One of the things our new framework does is let us create functionality like this and deploy it so any producer/engineer can use it with relatively little effort.

Tabs

The original author asked me for a moo-conversion, work is in progress. Will refactor still much of the code and add support for Dragging into tabcontent (Dragging over a tab activates it).

http://dev.digitarald.de/tabs.html

Playground Dragging (Reverse Dragging)

Dragging reversed, wonky because onStart and onComplete have this 10ms delay, so in some situations the position is changing.

http://dev.digitarald.de/drag.html

Fly-over-background

Scrolling effect, like the effect in flash used on some nice sites. Scrolling from content to content that is attached to a big background image. Just a performance check ;)

http://dev.digitarald.de/tile.html

Ghost Dragging

Shopping Card dragging? Drag your favorite element and drop a copy of it, like in Rich Client Shopping cards or Item-to-Category. Very basic, added my personal spice with ajax and more checks inside my own rich client project ;)

http://dev.digitarald.de/ghostdrag.html

More to come (Better Lightbox, mooSelectBox, conversion of Floating Windows).

Some early blog posts on MooTools w/ examples

MooTools continues to impress me. Check out the Class.implement and Class.extend functionality in this great article from Cory Hudson (there are numerous code examples).

mootools implements a class inheritance scheme that is inspired by Dean Edwards' wonderful Base class. Creating a class is similar to Prototype, but now you don't ever have to think about the prototype object when you define the class...

...mootools supports multiple inheritance in a Ruby mixin style with the Class.implement() method. Using the implement method of an existing class, that class can inherit methods and properties from another class or object. Unlike Class.extend(), the implement method is called on the class you are modifying, not on the object being copied. This method can be used to support multiple inheritance.

And here's another article from Cory on MooTools numerous helpful utility functions:

The new mootools JavaScript framework has quickly impressed me with its design and usefulness. The library was clearly written to meet real programmers' needs while working in JavaScript. Just take a look at some of the new utility functions and methods it provides.

Note: This article covers functions and methods found in the Array.js and Function.js modules of mootools.

Optimizing Javascript for IE

A while back I posted articles on memory leaks and how to avoid them (read them! seriously). In the process of learning that lesson, I had to rethink the way I wrote my code a little which was a little painful. Actually, every week or so I realize there's a better way to do something and when I look at code I wrote a month ago I want to rewrite it.

So this article, is kind of frustrating, as it highlights a level of javascript I'd previously not considered much and, as I think about it now, wish I didn't have to. Specifically, this article talks about how the IE javascript engine works with IE's DOM engine and how to avoid expensive namespace lookups. It's worth reading, but having read it I find the knowledge itself annoying. Maybe this stuff would be easier to write in Assembly...

via ajaxian (of course):

Peter Gurevich and Justin Rogers from Microsoft's IE team recently wrote a blog entitled 'IE + JavaScript Performance Recommendations - Part 1'. It's an interesting read, containing such tips as:

  • Precede your variables with var if you are truly defining them in the current scope
  • Cache Variables Whenever Possible
  • Cache Function Pointers at all costs
  • Cache Function Pointers at all costs

Yahoo! Web Services Using JSON

by Douglas Crockford (Yahoo!)
June 14, 2006 from 6 - 9:30 p.m.
6 p.m. - Reception; 7 p.m. - Presentation

JSON is rendering the "X" in AJAX superfluous. JSON or JavaScript Object Notation is a universal data format. It provides an uncommonly effective bridge for moving data between systems and between languages. JSON is also really simple. In fact, many of the Yahoo! Web Services provide JSON as an alternate output format to XML. | Read the rest »

Categories

Archives

Links and whatnot