Tuesday, June 24, 2008

Understanding JSON

Some pple get scared when they see strange words like JSON. But if you take a closer look they are nothing ;). So here is a basic guide for JSON. JSON stands for JavaScript Object Notation. Also remember there is no "A" in between J and S ;P.
Here is a simple JSON object
{name:'Dilan'}

There is another way to write this
{'name':'Dilan'}

Both are same. Then how do we use JSON in javascript? Answer is pretty simple... here it is..
var person={'name':'Dilan'};
alert(person.name);

Done! That is it. Wait a sec how about if a person have many interests.. that needed to be represented in an array.. ok! here we go
var person = {'name':'Dilan', 'interests':['watch movies','play crickets','code']}

who la! We are done! So this should be a good foundation for you to start! Next time when your fellow developer or interview board ask for a JSON don't freak out! Just hit them back with a good example! cheers!!!

Assigning values to vars in Dojo

In dojo you can populate vars by using below syntax. Here continentStore is populated using countries.json file, method using is dojo.data.ItemFileReadStore.

<div dojoType="dojo.data.ItemFileReadStore" jsId="continentStore"
url="../tests/_data/countries.json"></div>


I have come across situations where I wanted to get this values assigned to just plain variables without using divs and dojoType etc. So this is how we do it.
var waveTreeDataSource = new dojo.data.ItemFileReadStore( {
data:{ identifier: 'name',
label: 'name',
items: [
{ name:'XXX', type:'media',
children:[{name:'A2P',children:[{name:'MCA'},{name:'Forex'}]},
{name:'P2P'}]},
{ name:'YYY' , type:'media',
children:[{_reference:'Test'},]},
{ name:'Test', type:'person', children:[{name:'test'}] },
{ name:'Dilan', type:'person'},
{ name:'Anuruddha', type: 'person'},
{ name:'KD', type: 'person'}
]
}
});

Just remember that we need to include same data structure in JSON file but we have to include it as object with data attribute as shown above. For more information take look at API documentation for dojo.data.ItemFileReadStore.

Monday, June 23, 2008

Eclipse - Ant View

Most of the time we prefer writing custom build scripts in ant for eclipse projects. But when we want to build/deploy project we will open that file and view the outline view to select the action we want to select and then right click on that action and build.. This is a tedious process if you need to build and deploy over and over again. But recently I have notices that there is another view that can have ant view so that we can double click on an action(deploy/build,etc) and make it work without having to go to the ant build file.
To enable that in eclipse all we have to do is go to Windows-> Show View -> Ant and click on it. Then you will see ant icon is left side dock area. Click on that to open ant window. Then right click on ant window body and select add build file. Select the build file from the project folder and who la! You have a ant view where you can double click and action to invoke it!
This looks confusing if you don't know what I'm talking about.. But if you are working on a spring project in eclipse I'm pretty sure that you know what I'm talking about! ;)

How to write blogs..

Well I must say that I'm not experienced blogger. But recently I have noticed that we take lot of time to get prepared to write blogs and end up writing nothing... So from now onwards, I thought of just writing on what I'm doing and problems that I encounter day today and How I overcome those stuff... Also I ask you(my friends) to do the same so that I can learn from them too...

Getting help for Dojo

Dojo is one of the best javascript toolkits. I would recommend it to anyone who want to try feature rich and robust toolkit. It is the most complete toolkit that comes with a liberal licensing scheme. Even though dojo is such an wonderful toolkit sometimes ppl find little difficult to find help related to dojo. Except for the fact that is has a wonderful getting started tutorial at dojotoolkit.org, all the other information are hidden and little difficult to find. So here I'm mentioning some of the information sources that may be useful to you.
1. http://dojotoolkit.org/
2. http://dojocampus.org/
3. http://sitepen.com/
4. IRC channle #dojo

Note that API , documentation and forums are available in dojotoolkit.org. Dojo campus contain more comprehensive tutorials and podcast for some important topics, etc. Sitepen has a brilliant blog which has more to the point information regarding features. Also IRC channels can be used to get in touch with most of the developers.

Saturday, June 14, 2008

Sampath Bank - Leaps ahead in customer satisfaction


Last week I was trying to increase the credit limit of my Sampath Bank credit card. I called over to bank and informed them my requirement. Then I had to write a letter of request and fax it to the bank. As soon as they got the fax, I've got not just credit limit increase but also upgrade from Silver card to Gold. My new gold card was ready 2 days after that.

Yesteryday I went to collect the card from Sampath Bank HQ at Sir James Peiris Mw, since it's the closest to my office :). When I signed the card, it happens to be that I have signed while it was upside down. I was so curious why they would mind that! According to the bank it's general practice to verify the sign with card with proper side up! If you signed it upside down store might reject you or worse you might get charged for credit card frauds. Since it would cause problems they wanted to issue another card instead of it. But I was worried that it will take sometimes(another 2 days may be). But to my amazement they said they can issue another card in 2 hours! It was SUPER FAST! I must admit that I'm really impressed with the type of service offered by Sampath Bank and would recommend everyone to get the same treat!

Tuesday, June 10, 2008

GIT - A bad choice for enterprise

While surfing around the Better Explained site, I happens to see a article which introduce users to the distributed version controlling (DVCS). At the end of the article there was video on youtube which happens to be a session on Git by Linus Torvalds for Google. It drew my attention and I actually watched it all the way through. Linus being a inspiring speaker is one thing but his version controlling thing, as in my opinion is not yet ready for a production companies. One the arguments he brings up in the session is that git allows open source to get over with it's politics of committer access. That is a valid point, having being able to have your own repository avoid having monarchy style control of a project. But this is not valid for enterprises who always want to have an upper hand on things. Also even though branching may be more smoother in DVCS, other troubles like lack on central control (even though we can mimic this) is not going to attract many enterprises soon to use DVCS.
Btw I'm not saying that SVN or CVS is better than Git but I think we need something that has better centralized control and have better merging support!

Wednesday, June 4, 2008

Spring turorial

After some time I decided to update little bit on what I'm doing these days. Well i've been messing up with spring mvc and spring web flow(SWF). Still i' m not very confortable with SWF. But I thought it would be nice to dissipate some knowledge on what is spring mvc and how you can use it. Before I start I must admit that I'm also new to this field, so what I'll be telling might not be accurate as some experts. :). So from today onwards I'm going to walk you though the concepts of spring (possibly with some tutorials).
So what is spring framework? Well it's another java framework which has lot of libraries and stuff... Probable reasons why u should use any framework is due to the fact that you can use already solved design patterns when u use them. WOW that was not so clear ;)! wait a sec... what is design pattern...well... design pattern is a basically a solution that is given for a well identified problem. So if you happen to encounter that same problem while developing what ever you develop you can use the solution for that design pattern to get over with it. (But you might need to customize depending on your exact requirement).
So where were we.... aha.. frameworks..spring framework... So basically we are using a framework to make our lives easier.....
I like spring framework because it has a great web framework under spring mvc and also support things like aspect oriented programming ...
I guess that is enough for this post.. I will be posting second post soon.. till then you can search buzz words.. spring, mvc, aspect oriented programming, framework, design patterns