29 Jun 2009

Playing with Javascript namespaces

I often have javascript colisions when using different ajax frameworks in the same page...
So I was wondering how namespaces works in javascript...

I found the beginning of an explanation in this article: 24-javascript-best-practices-for-beginners

But there doesn't seems to be any real convention about this looking at this blog and the associated comments: JavaScript Namespaces

I tried various versions, it seems to me the simplest/shortest is the best... my 2 cents

// simple namespace like ExtJs
Project = {
name : "joe"
}

// a bit like java package but with underscore
com_company_project = {
name : "joe"
}


// java package style
com = {
company : {
project : {
name : "joe"
}
}
}

// Yahoo style
// var X = YAHOO.util.Dom.get();
PROJECT = {
core : {
Functionality : {
name : "joe"
}
}
}

function display() {
console.log("namespaces");
console.log("root: " + Project.name);
console.log("unscore: " + com_company_project.name);
console.log("nested: " + com.company.project.name);
console.log("yahoo: " + PROJECT.core.Functionality.name);
}


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>Javascript</title>
<script type="text/javascript" src="namespaces.js"></script>
</head>
<body>
<h1>Javascript</h1>
<h2>consoleLog</h2>
<div id="consoleLog">
<input type="submit" value="console.log" onclick="javascript:display();"/>
</div>
</body>
</html>


25 Jun 2009

Eclipse Galileo is out (1 year since Ganymede)

I was talking with someone recently and he told me he was using eclipse 3.3...
I'm using eclipse 3.4.

I told him, he should update since eclipse releases are not so frequent and just a minor number change is actually many months of efforts...

But I didn't know if it was 2, 4 or 6 months.

Well it turn out it's actually 1 year excatly between releases!

So now that Galileo is out you should really update your eclipse version or you'll have a 2 year old software ;)

I think many people don't update eclipse that often because of the quality of it, there is so few bugs that you don't feel the urge to update (my 2 cents)

Release Date Platform version Projects
Eclipse 3.0 28 June 2004 3.0
Eclipse 3.1 28 June 2005 3.1
Callisto 30 June 2006 3.2 Callisto projects
Europa 29 June 2007 3.3 Europa projects
Ganymede 25 June 2008 3.4 Ganymede projects
Galileo 24 June 2009 3.5 Galileo projects

source: wikipedia

17 Jun 2009

Eclipse and Updates

Eclipse is a great tool as a Java IDE and also an excellent plateform for application development (nothing new here).

But I've always found the software update system "awkward".

Not on the technical side, as explain by Benjamin Cabé: Déployer avec Equinox p2 [fr], the technology behind it is good, it's even more than just a "plugins updates" system.

But from a usability point of view I think they could enhance it much more, for example:
  • I would never expect it to be in the "Help" menu
  • Automatic updates could be "on" by default (see how firefox pushes update automatically), I suppose expert users would turn this off but for "Average Joe" it's a diferent story
  • I found the "software list" scary, I keep asking myself
    "Do I really need to update so many things?! I'm pretty sure something will break..."
    I think it would be better to hide it or group things in big categories like "update eclipse (core)", update spring plugin" etc...

No more desktoptopia.com wallpaper ?

Last few months, I have been using a windows tool (exist also for Mac) made by http://www.desktoptopia.com/ to change wallpaper every day.
What I like about it, is that they have quality images... but lately I kept getting the same images over and over :(

At first I thought it was a bug but it's far more simple the website is down :(

I don't know for how long but I think it's be going on for quite a long time... too bad I was looking for such a tool for a long time with minimum setup and nice images...

If you know something equivalent, drop me a line in the comment area ;)



16 Jun 2009

Polyglot programming

I was trying to explain the concept of Ployglot programming to someone but couldn't find a clear definition. I stumble on this link recently: Polyglot programming.



...writing good multi-threading code is hard. Very hard. So why bother? Why not use a language that handles multiple threads more gracefully?

Need a nice web-based user interface? Why not use Ruby on Rails via JRuby

It's all about choosing the right tool for the job and leveraging it correctly.

3 Jun 2009

XPath notepad ('like' queries)

Nothing fancy in this post, I just don't want to forget how to do 'like' queries in xpath

XPath: //category[@name='abc']
is equivalent to
Sql: select * from category where name ='abc'

XPath: //category[contains(@name, 'abc')]
is equivalent to
Sql: select * from category where name like '%abc%'