Monday, February 15, 2010

Aardvark - A Valuable Business Tool

Couple of days before I got a news that Google acquired another popular Internet service called Aardvark in nearly $50 Millions. Aardvark is a social search engine service that connects users live with friends or friends-of-friends who are able to answer their questions. Based on my short interaction with the tool i realized that it can become a great boon for any kind of organizations.

I started using the Aardvark after this news and i found it really good tool to get the answers properly and pretty fast. I am using Yahoo Answers for all my non-technical questions and Stackoverflow for technical questions as I am a software engineer. Though both of these tools are doing pretty well, I was still finding that both the services are missing something.

Now to show Aardvark from an organization perspective, I work in a quite a big organization which employs huge and diversified manpower. Such a big enterprise contains an MIS system to keep employee profile information for future references. However its really hard to keep the latest profile information of each of the employee in the organization.

Every organization generates enormous amount of industry specific problem. When the problem arise they either seek an internal help based on the employee profile information or contact external agencies for support. In any case its time consuming at first and huge investment at the end, in the worst case an organization spends huge money on an external agency who fails to do the job and eventually either the problem is dropped or they find someone from inside.

To not cause such a heavy damage, now a days most of the companies (well software in particular) use Wiki/Forum/Blogs to tackle the situation and spread the knowledge. But this approach is limited to a set of companies and its not interactive. User seeking the information has to search through the set of services to find the answer to his problem.

People tend to learn new things every now and then so their profile keeps on updating compared to organization which prefers to update the profile information every six months or a year. So this approach creates mismatch between the actual employee profile and its organizational print. Because of this match many a times Organization end up hiring brand new resource or seek for some external agency to solve the problem.

Aardvark is a tool which can really bridge the gap between this mismatch. Employee getting new knowledge every now and then can update her profile immediately. Aardvark is intelligent enough in delegating the question to right persons. Such an intelligent and fast communication medium can be used in Enterprises to solve problems immediately without investing further valuable resources.

Well while writing this Aardvark is officially part of Google so in future we might see many new features combined with existing Google services.

Thursday, February 11, 2010

Google Buzz - sharing with GMail

Buzz a new service just announced by Google available under the GMail account. Buzz is designed to share day to day stuffs like text, images, videos, etc. Most of the features are similar to other popular social sharing services apart from the GMail front and other Google services integration.

Following are few buzzes of the Buzz.
  • Two mode of sharing is available. Public sharing similar to twitter and Private sharing where update is visible to the users of selected group(s)
  • Many external applications can be configured as a connected sites like YouTube, Google Reader, Picasa, Blogspot, Blogger and Flickr. As such you can paste link having images or videos, Buzz will scan the media files and show you the available contents to select if there are multiple images or videos available. I tried with flickr, vimeo, wikipedia and smashingmagazine
  • All Buzz entries are available in your Google Profile page under Buzz tab
  • Any post shared in the Google Reader will be available as a Buzz entry if the Reader is configured as a connected site
  • A Buzz can be directed to user(s) through '@' symbol before the username like @dhaval.b.nagar@gmail.com
  • Twitter updates are available as buzz entries if Twitter is configured as a connected site
  • To create RSS for your own Buzz entries, go to your profile page and select the Buzz tab. Copy the URL and add it in the Google Reader under Add Subscription
  • Buzz allows to post Link, Images and Videos to entries. Images can be seen with presentation feature on the same page. Videos can be seen live
  • Each conversation can be seen independently from the Time Link given on the top right of the dialog box
  • As such you can paste any link on the conversation dialog box and Buzz will find all the available images and videos on the page. You can select at max 4 media content to post.
Overall Buzz falls somewhere between the Google Wave and many other popular social applications. With the failure of Google Wave (or may be Buzz in near future) we will see many such applications trying to fit in the "Social Shoe" from Google.

Wednesday, February 10, 2010

Groovy Category and Dynamic Overriding

A Category class is an ordinary class which contains set of methods. The class can be used for a duration of code block and when used first parameter type of each method treats the declared method as its member method.

class TestCategory{
static def test(String str){
return "testing"
}
}

use(TestCategory){
// test() can be called as a member method inside the use block
assert "testing" == "a".test()
}

A category class can contain method without any parameters but it is not possible to use such method in the use block. A category class method should at least have one parameter to get called from the use block. The following code will throw an exception at the time of execution.

class EmptyMethodCategory{
static def emptyMethod(){
return "empty"
}
}

use(EmptyMethodCategory){
assert "empty" == emptyMethod()
}

Operator overriding is the most suitable use of the Category classes. In case of operator overriding, if the caller is not matching with any of the overridden methods, original method will be executed.

class StringSumCategory{
static def plus(String str1, String str2){
return str1.toInteger() + str2.toInteger()
}
}

use(StringSumCategory){
assert 3 == "1" + "2"
assert "12" == "1" + 2
}

If the category class contains a method with only one parameter of type Object, that method will be available to any possible type in Groovy.

class SerializeCategory{
static def serialize(Object obj){
// do serialization stuff
return serializedObj
}
}

use(SerializeCategory){
println 1.serialize()
println "a".serialize()
println ([1, 2, 3].serialize())
println this.serialize()
println serialize()
}

Groovy is full of surprises. It contains some of the best features from many static and dynamic languages.

Spread operator

Spread operator helps Groovy collections (list, range and map) to simple comma separated values. Spread operator is so flexible which can be used anywhere. For example:

def test(a, b, c){
return a + b + c
}

def numList = [1, 2, 3]

If you want to pass the above list of values to the test() method you have to write some boilerplate code to extract the elements and pass them in the method.

Whereas the spread operator is introduced to eliminate boilerplate code and follow clean coding. The above method can be called with the given list without a single extra line of code.

test(*numList)

An asterisk followed by list, range or map will spread the collection and convert all the containing values to comma separated values. The above example will work same for Range.

def numRange = 1..3
test(*numRange)

Map has different syntax compared to List and Range.

def aMap = [a:1, b:2]
def bMap = [c:3, *:aMap]

Likewise Groovy contains many such shortening facilities where development time can be reduces and code can remain clear and understandable.

Groovy spread-dot operator in GPath

GPath is an expression language integrated into Groovy to process nested objects. The dot and spread-dot operators helps to build the GPath expression. The dot operator is used to access the properties and spread-dot operator is used to access property, field or method.

class Person{
String firstName
String lastName
int age

int calc(){
return age * 2
}
}

def personList = [
new Person(firstName: "dhaval", lastName: "nagar", age: 25),
new Person(firstName: "nachiket", lastName: "patel", age: 24)
]

To access the firstName property one can use either of the operators:

println personList.firstName
// ["dhaval", "nachiket"]

println personList*.firstName
// ["dhaval", "nachiket"]

To access the calc() method spread-dot operator has to be used, whereas dot operator will raise an exception:

println personList*.total()
// [50, 48]

Apart from the access restrictions both the operators works differently when collection contains null values like:

personList << null
personList << new Person(firstName: "sandeep", lastName: "shah", age: 30)

println personList.firstName
// ["dhaval", "nachiket", "sandeep"]

println personList*.firstName
// ["dhaval", "nachiket", null, "sandeep"]

The spread-dot operator will add the null value for each null element in the resulting list.

Both the operators works same when the list element is not null but the requested property is null.

personList.clear()
personList << new Person(firstName: "dhaval", lastName: "nagar", age: 25)
personList << new Person(lastName: "nagar", age: 25)

println personList.firstName
// ["dhaval", null]

println personList*.firstName
// ["dhaval", null]

To avoid such null values in the resulting list, grep expression can be used.

println personList.grep{it?.firstName}.firstName
// ["dhaval"]

Here grep will try to evaluate the true boolean condition, as per the Groovy Truth if an object is NULL it will be considered as FALSE. So above expression will reject all the objects where firstName property value is null.