Skip to the posts
Buffalo's neighborhood journals since 2003 🍀 Patrick Spicy Devil Logan🌭 Sahlen🥨 Weber Spank🥟 Pierogi🐸 Scaj🍺 Labatt Utica Pink Cherio❄️ Snow Murder

paul’s journal

Coding Javascript

· · 🌡️ 71°F

This week, I have recoded my years worth of javascript functions and objects into a beautiful, name spaced, inter-dependent, object oriented library that will make new stuff so much more exciting to program and extend. Unfortuantely, I now have to go through the process of retrofitting everything I previously created with the system.

Luckily, I moved all the javascript code out of my documents and into external js files years ago, so there is no having to go through lots of markup to deal with inline tags that are burried deep within. Most of the stuff shall convert nicely and now I never have to worry about namespace conflicts ever again and will never have to track down little code snippets.

Surebert is no longer surebert but the surebertCom library which has a communicate object to replace the old surebert 1.6.

None of this probably means anything to anyone, but I want to note this day for when I look back.

I will make the library publically available at some point in the near future.


The objects themselves can a sort of namespace. e.g.

myLib={

jump: function(){
alert('jump');
},
run: function(){
alert('run');
},
swim:function(){
alert('run');
}
}

now I can safely use even if I am using other javascripts that has a jump() function.
mylib.jump();

if you know you aren't going to have a conflict that you can use
jump = myLib.jump; to make a sort of global alias to the function
jump();

The nice thing is all these objects can interact and extend each other and javascript object literal notation is so easy to read and maintain.

I group all my objects in the surebertCom object and then it has further breakdowns into uses and types e.g. surebertCom.strings, subrertCom.sounds, etc
297 words

💬 4 comments

  1. zobar ·

    Javascript has namespaces?! Let's all hope that they're less awkward than XML namespaces.

    - Z
  2. paul ·

    I updated my journal to explain more what I meant.
  3. kara ·

    Total geekdom. I love it.
  4. carolinian ·

    Refactoring is wonderfully cathartic, isn't it?

💬 Write a comment