Thursday, September 28, 2006

Today's discovery: Google AJAX Search API

Look around a little... Do you see that Google Search text box at the top right corner of my blog? :-) Yes..there you go. That is the latest addition to my blog template and will remain there for some time at least. And today's blog is going to be about this little discovery I had today.

Google AJAX Search API (http://code.google.com/apis/ajaxsearch/)is a Javascript library that can be used to embed our very own Google Search in our web pages and web applications. The library provides simple-to-use Javascipt objects that perform inline searches over a number of Google services, which interestingly include:

1. Google Web Search (this is our very own google search engine)
2. Google Video Search (this is something interesting, especially from the point of view of one of the projects we might be doing)
3. Google Blog Search
4. Local Search
5. Google Map Search

Steps to follow to include Google Search within a web page:

1. Include the URL of the Google AJAX Search API Javascript library via a <script> tag in the web page as follows:
<script src="http://www.google.com/uds/api?file=uds.js&v=0.1&key=ABCDEFG" type="text/javascript"></script>

Note the "key" parameter. The value needs to be replaced by your key that you can get by signing up for one. (This seems a little unfriendly, discussed below as a down-side)

2. Include the CSS stylesheet that is used by the Google search component:
<link href="http://www.google.com/uds/css/gsearch.css" type="text/css" rel="stylesheet"/>

3. GSearchControl is the main class of the API that co-ordinates the search across different services. These services are to be added as children of this class.

4. GlocalSearch, GwebSearch, GblogSearch and GvideoSearch are the objects representing the various services. One or more of these can be added to the GSearchControl component using the "addSearcher" method.

5. Layout option: All these different searchers can be added on one page. They can be laid out linearly or in a tabbed page. Take a look at the google search I have added to my blog site. When you search for something, three tabs come up - Web Search, Google Blog Search and Blogger Search.

6. The control is drawn using the "draw" method of GSearchControl

7. When the user enters a search expression in the search textbox and clicks Search button, the "execute" method of the GSearchControl object is to be called to perform the actual search

8. The results are displayed inline. The number of results to be shown by default can also be controlled.

Some good points about this API:

1. With this API, I can very easily include Search capabilities in my web pages
2. The Video Search feature also provides a Playback feature using which I can play videos in the web page itself
3. The search results could be distributed or shared with other people. This is done by providing a "Copy" option below the links. So, when I click on the "Copy" option a callback function can be called. In this function, I can write my own logic for storing / copying these links. Makes a lot of sense in a "Bookmarks" kind of an application I am trying to develop right now. So the user can search for new URLs from within my application and store them as bookmarks then and there.

Some of the down-sides as of today:

1. This is still an experimental API, current version is 0.1. Google will be coming up with a version 1.0 soon which is expected to be a little different from this version. So at that time people might also have compatibility issues. And since this is just a basic first version, it will have bugs and early adopters will have to face some issues.

2. To use Google AJAX Search API in your web pages, you need to sign up for a key for a particular URL. The idea is that one can use that key in all the web pages under that directory. I am finding this a little tricky (especially when it comes to testing out applications that I am testing on my local Tomcat server) and also a little fishy, in terms of business use.

3. Browser compatibility: Currently supports Firefox, IE 6, and Safari, with support for additional browsers coming soon..

All in all - pretty exciting to try this out in some of the web applications.

P.S.: If you want to add Google Search capability to your blog, let me know :-)

Monday, September 18, 2006

One day with Google Gadgets

I came across the Google Gadgets API today (I know that is an old news already!). Google Gadgets API lets you write gadgets (referred to by Yahoo as widgets) or mini-applications that can run on a Google Personalized web page, Google Desktop or Google Pages (http://pages.google.com).

Here is the URL of Google Gadgets API: http://www.google.com/apis/homepage/index.html. As the overview page says, with basic knowledge of HTML and Javascript you can get upto speed wihin minutes with developing your first Google Gadget! Follow the steps given in the developer guide to build a simple gadget (it is a simple XML file), upload it on google pages or google base or any public web server and you are raring to go.

Try one simple gadget I developed (? :-)) to start with:

1. Go to www.google.com
2. Go to the Personalized Home
3. Click on the "Add more to this page" link at the top left hand corner
4. Click on the "Add by URL" link, next to the "Search Homepage Content"
5. Enter the URL http://arati.rahalkar.googlepages.com/myfirsttimegadget.xml
6. A dialog box saying "You are about to add a feature that was not created by Google. Do you wish to continue?" will appear. Choose OK.
7. The gadget will get added to your personalized Google home page displaying the current time and a greeting depending on the time of the day.
8. You can change some of the preferences by clicking on the "edit" button. This will show the preferences in a pop-up. Specify your name, the date-time format and the background color and click Save. See the preferences being applied to your gadget.
9. The next time you visit your Personalized Google home page, don't miss my first time gadget :-)

Pretty cool for starters huh?

One of the things I was searching for is to be able to embed these google gadgets in web pages other than just the Google pages. I tried embedding my gadget on my Google pages home page (you have to enable experimental features in Google Pages settings in order to embed standard / third-party gadgets). Check out my google pages home page at: http://arati.rahalkar.googlepages.com/.

However, I had to follow a very crude approach to embed this gadget on a web page. Viewed the source of my Google pages home page, and copy-pasted the div section that contained the gadget. It worked, but without the "Edit Preferences" option, as you can see below:



One of the nice things about Google gadgets which I have not really trid it out on the first day is that you can write AJAX-enabled gadgets. So you can have gadgets that fetch data from the server asynchronously and show you latest updated information.

As with all the other Web2.0 things and AJAX enabled toolkits, Goolge gadgets is not the only one in market. There are Yahoo widgets which have been around for a longer time, cannot compare the two since I haven't checked it out still.

On a side note: With AJAX and Web 2.0 coming so strong, I think good knowledge of Javascript is definitely going to be one of the skills a programmer needs to have. Cannot keep running away from Javascript code anymore!

Tuesday, September 12, 2006

Design by Contract

Dr. Bertrand Meyer, the man behind the Eiffel language the famous Design by Contract approach had come to our company to deliver a lecture. Although I did not know much about this approach, I attended the talk along with a few of my colleagues.

The talk was nice, with timely comic interludes. He talked about Eiffel as a language, the various features it provides, how it is better than any other existing language :-) and of course finally the Design by Contract approach.

The whole approach is centered around contracts - specified as pre-conditions and post-conditions. It is like signing a contract between the caller and the callee.
He gave an example of a water tank with two valves - input and output valve. The function of filling the tank is done by a method "fill". Now the pre-conditions for this method are:

1. Input valve should be open
2. Output valve should be closed (otherwise as he mentioned, it will take a long time to fill it :-))

The post-conditions are that:
1. Input valve is closed
2. Output valve is closed
3. Tank is full

This seems like a difficult thing to achieve in languages like .Net, Java, C++, but Eiffel language provides support for defining such contracts, thus making them a part of the design process itself. He gave examples of this language being used in many mission critical applications, one of the examples was the Chicago trade center - with terminals and monitors showing real-time stock data almost 24*7.

I do not know much about this approach, but as one of my colleagues who attended the talk with me said - He has been following this technique and approach with C++ and has found it to be very effective.

Tuesday, September 05, 2006

Preparing Powerpoint Slides - A skill?

Many freshers have joined our group very recently, and as part of their mentoring programs, each of them had to give a 10 minute long presentation on the scope of their mentoring assignment, what they are going to do, a brief look at the technologies to be used etc. etc.

I sat through all of them and at the end of it, actually ended up having a list of TO-DOs and the NOT-TO-DOs as far as preparing powerpoint slides is concerned. I am not talking about the "talking skills" or the "rendering" part, that is a different domain altogether - and takes more of personal capabilities, confidence, attitude etc. than mere TO-DOs. And I am discounting all the fresh graduates from that aspect - some people like me take time to get over their stage and people fear :-) So I know how it is and I am not even going there.

So here are some of the points to remember:

1. Use a good, pleasing template
Should be peaceful to the eyes of the reader. Please don't have a total black background with white text on it - so irritating to the eyes!

2. Be uniform, consistent as far as the font, font size, style, bullets are concerned
Microsoft PowerPoint gives you a lot of options I know - but that does not mean you have to try and use a different one in each slide. Consistency and uniformity is the way to go!

3. How much text to put on a slide?
There might be a lot you want to say, but make sure you do not clutter up the slide with your entire speech poured on it!
The other extreme, just two points in small font on one big slide with lots of white, blank space - again a no-no.

The whole idea is - Be crisp, short, to the point (words that make a lot of sense especially when you are making presentation slides)

4. Use animation wherever possible
While I say that, I also want to say what my manager rightly mentioned: Don't overdo it, don't have a cartoon character come running from somewhere and pointing at something on your slide :-)

But yes, animation used in just about the right proportion goes a long way in making an OK presenation an impressive one! (If not anything, you are going to have people wonder how you managed to get that animation :-))

5. Have an agenda at the start of the presenation
This will help you decide the direction of the presentation while you are making one and ofcourse at the time of giving the presentation as well. And then, it also helps the listeners know what is in store for them.

6. Agenda and the Contents of the presenation should go hand-in-hand
This seems obvious, but I have seen presentations where the agenda said one thing, and I, as a listener, kept on waiting for that one thing in the agenda that had interested me and well..that point never showed up later!

7. Full-stops come at the end of a "sentence" please
Yes - I have seen a lot of people putting a full-stop at the end of a point. A point is not a proper sentence and should not be ended with a full-stop. Definitely not at the end of the labels in an architecture diagram!

8. Flow of the presentation is important
Remember - you, the presenter, decide the direction of the presentation. People rely on you to take them in the right direction. You are the captain of the ship. Make sure the flow of the presentation is such that you take people along with you, get them interested in what you are saying and kind of come up with slides and content that they expect to be seeing next.

9. Spelling and grammar mistakes
Creates a very bad impression unnecessarily. You may be a great orator, but when I see obvious english mistakes in your slides - I am going to remember..yes - this is the guy who does not understand the difference between "Its" and "It's, Their and There, the importance of a 'a' and a 'the' at the right places".

It is just about being a little more careful really, isn't it? But I have observed that many people just don't care! And this "not caring", "casual" attitude may be "cool" sir, but I am not impressed.

10. A Thank you - Any Questions? slide is a good way to end the presentation (in some cases after References slide)
You are done, you have talked what you wanted to - leave the floor open for people to ask questions and doubts.
And of course - it is ok if you cannot answer them. "Lets take it offline" is a good way to handle questions or better still "I haven't really looked into this aspect in detail.. I will get back to you on this".

Next time you make a presentation, think before you write :-) And I am sure you have already started thinking of many more TODOs that I have perhaps missed.