Sarah Learns a New Term - Namespaces

Working on implementing SWFUpload or a similar type uploader. On reading the documentation, I see:

The main features that SWFUpload provides are:

  • The ability to select multiple files in the file browser dialog.
  • AJAX-style uploading without a page refresh.
  • Upload progress events.
  • Namespaced classes compatible with other JavaScript libraries (i.e., jQuery, Prototype, etc.).
  • Flash 9 and Flash 10 support. (Flash 8 support dropped in version 2.2.0)
This brought me back to the days of my childhood, when, reading a book, I would keep a dictionary beside me and look up unfamiliar words. (Yes I was a big nerd from the moment I was born I guess.) So I decided to look up exactly what a Namespace is and share it with my nonexistent blog readers.

Think about this: You are writing the next big Facebook - your php code is getting to around 10,000 lines, and you are using multiple third party plugins. Suddenly you come across a predicament - that nifty third party User Widget has conflicting class names with that other nifty third party thing-a-majig. Namespacing avoids this by allowing you to 'classify' your code (how punny). Assigning a namespace to a php file (you can even assign more than one per file) ensures that the widget USER class does not get overwritten by the thing-a-majig USER class.

For an explanation that actually makes sense, see here:
http://www.sitepoint.com/blogs/2009/07/13/php-53-namespaces-basics/

0 comments:

Post a Comment