Thursday, December 24, 2009

Impact of NOSQL movement on the datastore vendors

Term #NOSQL (Not Only SQL) props up frequently these days, sometimes rivalling the traditional SQL-based datastores and on a few occasions augmenting it.
Both of these categories of datastores (databases) are no doubt quite different from each other, have different philosophies behind their implementation and most importantly, have different vendors.

Why don't the conventional SQL-based vendors grasp this opportunity and acquire another paradigm support under their belt? Although Oracle, a RDBMS vendor speaks up of supporting map-reduce model (a feature that is associated with NOSQL solutions), it however does not gives explicit constructs of endorsing the feature.

On the other hand, the NOSQL counterparts are emerging one after the other, solutions made in different languages, with slight variations. It seems like these NOSQL advocates turned vendors are trying to make the most of a hole found in the datastore market, and why shouldn't they capitalize on this silver opportunity? RDBMS vendors have left no room for the different DBMS paradigms to grow, and some of them have evolved into immense beasts.

It will be interesting to see how the different vendors, new and established ones will react to the new demands posed by the NOSQL movement. Only time will determine the leading marketshare holder for this new trend in data storage.

Sunday, December 20, 2009

Sherlock Holmes on MSN

As you may already know about the upcoming Sherlock Holmes movie, casting the Iron Man (Robert Downey Jr.) as the detective himself and Jude Law as Dr. Watson, I'm pretty much excited about this adaption of my favorite literary character and the man of scientific methods - Sherlock Holmes.

The title of this blog also bear a reference of the residence of Mr. Holmes (221b Baker Street), a place I wish to visit some day. In fact, I've fancied myself to be like this great detective during my childhood and most part of my premature adulthood, my MSN Messenger's nick has been 'Sherlock Holmes' for more than 6 years, I've developed a role playing game named 'Sherlock Holmes in FAST', I am also the moderator of a group discussing topics relating to 'The Science of Deduction' and it goes on and on. I think my love is obvious.

Today I visited the promotion site for the much awaited movie http://arabia.msn.com/sherlockholmes/ hosted by MSN Arabia and was taken to a crashed page upon filling the registration form with incorrect DOB.


Click on the picture to see the enlarged error. You will see the
HarryPotter.reg.btnSubmit_Click method being used to handle the requests coming from a Sherlock Holmes page. This shows that CCP (Cut-Copy-Paste) is also a trend in Microsoft :-)

Can't tell why I posted this little blunder from MS. Maybe it has something to do with my affection with Holmes, or the negative emotions towards Microsoft, or maybe I just can't bear that Harry Potter's handler is receiving requests from a Sherlock Holmes page :P

(Disclaimer: I am not finished with posts related to Sherlock Holmes.)

Wednesday, December 16, 2009

Retrieving Time Zone's DST information in Java

I have worked extensively with times. By time, I mean the software representation of time and the mapping of various concepts surrounding this tangible entity.

Handling of Time Zone, Daylight Saving Time (DST) is a pretty important use case in most softwares. All programming languages have libraries specifically designed to manipulate time easily. However, the implementation of these APIs isn't standardized and therefore developers have to go through a learning curve in order to use these APIs effectively and correctly. But the fact is that most of the developers take the concept for granted and are contend to directly use the libraries without learning the concepts properly.

Web is full of these resources and help can be found for learning the concepts and correctly utilizing the APIs in different languages.
There's one small use case in Java for which I couldn't find any assistance and that simply is: retrieving DST details for a particular Time Zone in Java.

The java.util.TimeZone does contain DST information, however it is not exposed in a direct manner in any of the TimeZone related classes. Internally, TimeZone calculates DST in SimpleTimeZone class (an implementation of TimeZone), which is accessed within TimeZone via ZoneInfo class' static methods.

Look here for the DST related private members of java.util.SimpleTimeZone.

Fortunately, these fields are visible through the toString() method of this class. Have a look at the source.

For convenience I'm providing a simple listing to extract out the DST information of a particular TimeZone:




1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/**
  * DST details for the time zone i.e. when DST is applied and when it ends.
  * @return
  */
public static String getDSTDetails(TimeZone timeZone) {

if (timeZone.getDSTSavings() > 0) {
/* Java's TimeZone related classes compute the start and end date of DST application but
    * do not expose it. The only way is to decipher the toString method which fortunately
    * prints enough information for us to deduce our required data.
    */
Pattern pattern = Pattern.compile("startMonth=(\\d+),startDay=(\\d+),.+endMonth=(\\d+),endDay=(\\d+),");
Matcher m = pattern.matcher(timeZone.toString());
if (m.find()) {
Calendar startCal = Calendar.getInstance();
Calendar endCal = Calendar.getInstance();

startCal.set(Calendar.MONTH, Integer.valueOf(m.group(1)));
startCal.set(Calendar.DAY_OF_MONTH, Integer.valueOf(m.group(2)));

endCal.set(Calendar.MONTH, Integer.valueOf(m.group(3)));
endCal.set(Calendar.DAY_OF_MONTH, Integer.valueOf(m.group(4)));

final SimpleDateFormat monthFormatter = new SimpleDateFormat("MMMM");

return new MessageFormat("Daylight savings starts at day {0} of {1}, ends at day {2} of {3}")
.format(new Serializable[] {
startCal.get(Calendar.DAY_OF_MONTH), monthFormatter.format(startCal.getTime()),
endCal.get(Calendar.DAY_OF_MONTH), monthFormatter.format(endCal.getTime())
}
);
}
}

return "NA";
}


Complete source code is also available as a Github gist.

Feel free to contact me for queries regarding time handling in Java (and on a side note, Teradata).

Thursday, November 26, 2009

BeTweet

It's been a long long time since my last post. During this quiet period on this blog, I've been through many things in life, both virtually and physically.
Many a times I thought of writing something but didn't come up with something substantial to share, there are still many partial posts lying in my repository, don't know when they will be published.

One reason for this tranquil phase is the fact that micro-blogging has took over. I've been posting most of the technical/geeky things on my Twitter account, personal and fun stuff on the Facebook profile, however I've refrained from posting work related stuff and research areas I've gone through.

It's time to conclude this post, and I do it with two messages:
1. I'll be back.
2. Follow me on micro-blogs.

Tuesday, June 16, 2009

Google playing godfather

"Google it!" is a more popular term than "Just do it!". The search engine giants have had more success stories than anyone could have thought.
From Google search to Gmail, Youtube, Google code and what not, everyone loves Google, even guys at Microsoft. Their workplace, open culture, Phd employees, the whole network is cherished.

They have become the godfather of technology, controlling things they want to, the way they like. Taking high tech companies (e.g. Youtube) within their umbrella and blessing them with more fortune.

On the development end, Google has backed open source. Google Code has evolved into a healthy project repository (competing SourceForge), their developers contributing heartily to the open community, establishing open standards etc. All of this is great but at the same time it is just like Bill Gates running charity foundations or a corporate company going green, just to win the votes of their consumers.

Google promotes openness, yet it's search engine technology is proprietary, they have created Google App Engine (GAE), yet your applications have to run in Google's created JVM which abstains you from using Threads, some standard Java classes etc. They say that their JVM alleviates the need for threading by using their Cloud intelligently. This is SOC, which is good but if I want to deploy my project on GAE then my code will be restricted to their SDK only.

Another example is the upcoming Google Wave, where again the Robots can only be hosted on GAE. Robots seem to be the most useful component of the Wave, yet again we are constrained with GAE. In this case their move seems correct because after all Wave is their own platform yet at the same time they promised open source.

One example, that I encountered currently is the OAuth protocol which is an open protocol for secure API authorization. Google, Yahoo, AOL, Twitter etc. have been the active participants of the protocol and they are also implementing and supporting it on their systems as well. We have the open protocol available but why not have the open implementation as well from these vendors?
There are core implementations of the protocol on OAuth.net but we aren't sure if these vendors use the same in their production environments.
Google extends OAuth by defining it's own parameters for it's own services like 'scope' but it's not documented anywhere. Here the ideal case should've been a published OAuth extension that is inline with their own implementation.

This very blog is hosted on Google's Blogger/Blogspot, I use gmail everyday, I love Google services and maybe that love forces me to think critically of them. I maybe wrong in some points but in the end I've termed them the godfather. Let me know if I'm wrong.

Monday, May 11, 2009

Geek Hero Comics

Geeky comics that covers developer-hacker-project manager relationships and tussles, Open Source software, anti-Microsoft culture, Linux, Git etc.


Comics are updated more than once, within a week. Some only discuss the recent trends or buzz in the software industry but on the whole there is an intriguing story line with adorable characters that keep you wanting for more.

I recommend you geeks to go through the whole comic strip and like me, wait for more.
Here you go:
http://www.geekherocomic.com/

Tuesday, May 5, 2009

TMA or simply Polymorphism?

Template Method Algorithm aka TMA (GoF) has been my all time favorite among Design Patterns. You can find a very good explanation of TMA in 'Head First Design Patterns' as it sheds light on some aspects even missing in GoF. Here are some slides on TMA that I made few years back:



Simply put, it streamlines the most trivial usage of polymorphism. This makes it a candid member of many compound patterns.

One pitfall that I have run into on quite a few occasions is when I try to make my base algorithm encapsulate lots of logic in order to maximize code reuse, pulling even minimally repeated piece of code from the concrete algorithms and placing it in the base algorithm. This all seems to be good and powerful until there come changes specific to the concrete algorithms forcing the common logic in the base algorithm to break.
Another trap of this trivial pattern is that it makes it easy to foresee inclusion of code in the base algorithm which lies outside of the algorithm's scope. Yet again, this is due to it's closeness with the polymorphic theme that the distinguishing line between 'simple polymorphism' and 'usage of polymorphism in TMA' starts to diminish.

Hence, following SRP (Single Responsibility Principle) is the key to writing a successful TMA and not transforming it into one of those god classes.

Wednesday, April 22, 2009

Oracle's Java 7 and the Matrix

The utmost crucial Java 7 release will no more be a responsibility of Sun as the new release will now be spearheaded by Oracle.

I got acquainted by the word Oracle even before I knew it's literal meaning, much earlier than I came to know of Java or Sun. The reason being the billboards in my country advertising courses for Oracle and that was during my 9th grade, back then I knew nothing worthy about computers or technologies related to it.

Since Oracle knows about the forthcoming matters, it should know that Java 7 is a major major step for the FUTURE of Java. But as with all releases, the hype of that very release decreases as the release date hovers near and the features start to diminish, one by one, JSRs declined, community frustrated, but then we always have the release, on time or off it, it doesn't matter and we have become used to it. Then we start hoping for the next release to turn out gold, revolutionizing things, optimism wins over reality.

With the success of many JVM based languages, Java's kingdom over it's own community attenuates.
Java 6 didn't bring out memorable changes and all eyes were set to Java 7, and when again before the release date (no sign yet) hopes started shattering, this acquisition gives it an all new twist. Oracle's Java 7 brings out an ocean of uncertainities. But these uncertainities are far more soothing than the less satisfactory facts that left us anticipating for yet another Java release.

Yet again, optimism wins and we hope that the Oracle knows better about Java's future.

I was just about to publish this post here, but then a thought occured, a wicked thought. Speaking of Oracle, I came to relating it (or the literal meaning of the company) to Matrix the movie's Oracle and Java as Neo :) It's not evil so far, in fact this is cool but going ahead we see that Neo eventually dies saving the world. Scared?
btw I am confused with establishing an anology with Agent Smith.....Microsoft?

Sunday, March 29, 2009

Java's bedevilled take on Strings

"A world without String is Chaos"
(remember this from Mouse Hunt?)


My turn: "A language with befuddling support for String is annoying" :)

Java is not a pure object-oriented language, mostly the impurity comes from the primitive type support. Although primitive types provide fast access and readability, however mixing them with their OOP counterparts is always frustrating. Same goes with C#.

The most annoying bit is the support for String. String is not a primitive type in Java nor was it supported in C++, you would have to create your own char array or use the STL's std::string. Yet there is special support in the language to give it the primitive feel. You can write:

String str = "String object";
String str2 = "this is not a String object but converted to one by the language" + str;
String str3 = "most annoying of all, you could use String's methods on this".toUpperCase();

As the last statement demonstrates, you could even call methods upon this non-standard object while you cannot do the same with other primitive types. Same thing could have been done with an integer literal (int) by providing Integer's methods upon it.

These dual standards are evil and confusing creating doubts about the authenticity of the language.
I'm loving Scala these days, it's stance on these dissimilarities created by Java and C# by providing us the all new and improved data types in the scala package.
Uptill now I have only but one grudge with Scala and that is the Scala's Strings refer to the one in java.lang.String package rather than providing us an improved version of it in the scala package.
Martin Odersky, please do something about it!

Saturday, March 28, 2009

story online: castle and the juice

Check out my brother's post story online: castle and the juice
Marvelous piece of work. I don't know why he was hiding it from me.

Wednesday, March 25, 2009

First hand experience with FP

Three years ago, yes i think it's been 3-4 years since dipping my fingers in the world of Functional Programming. Although XSLT is not a functional language but it strives to follow the FP guidelines and it is the weapon that I hold responsible for my First (FP) Blood.

I started using XSLT in .net, producing result sets in XML and writing XSLs for the visually appealing transformations. First it was simple if-else, for-each, using XQuery etc. but as soon as I stumbled upon variable assignment, I thought I caught a bug in XSLT, "I cannot reassign a variable, what's the use of the VARYiable then?"

Then I tried writing a for loop from a to b, I was troubled again. Soon I realized there was something different going on here and I would have to learn it properly before calling XSLT my preferred transformation language. At that time I read about functional language, which uptil then I thought was another name for procedural language. Satisfied, I went ahead with XSLT using recursion, template calling etc. techniques that were already taught to me but as an alternative to normal programming construct and not as a measure to make out of reassignment restrictions.

After that I forgot about FP and went on with life, rejoicing references, reassignments, reflection and then I heard about closures (around a year and a half ago) and people talking about forcing it somehow in the beautiful, simple, verbose Java language. At that time, I could not get a hang of it and went on with life. Then came the Scala buzz, I was always a great advocate of static typing and Scala being termed as the 'statically typed dynamic language' attracted me. After some days of learning I came to know about the FP fundamentals, side-effects, currying, closures etc. aside from being refreshing, these concepts enabled me to realize the modularization of functional behavior, an essential requirement in a good design that no OOP design pattern has been able to solve in a concise manner.

Sunday, March 8, 2009

Connected

Web 2.0 complemented with Social networking has been responsible for a plethora of web applications of unique nature in the near past. Various frameworks, technologies and protocols have emerged to support this trend. Even the server technologies are emerging to support the movement (e.g. by solving the scalability issue with cloud computing).

Some applications are so dense in terms of user base and features that they didn't care about collaborating with others. On the other hand, the small ones (web applications) emerge with some unique idea needing the larger apps to support them and share their user base. However recently the larger apps are becoming less self-centered in providing this connectivity (loose coupling :)).

Open standards like OAuth, OpenID etc. have paved way in this direction by enabling inter-operation among web applications an established technology rather than an idea pursued differently by different apps. Still the implementations vary depending on the nature of apps.

All of this comes down to USER POWER, where the user is given precedence over the applications. User's profile, image, credibility is carried over from application to application spanning a network of user-app with a two-way directed graph. Combine this user-app set with your browser and you are ready to get a smooth experience resulting in YOU seamlessly using applications throughout the world connected via internet, be it services, social networks, email, forums, blogs, business apps or your own creation.

My proposal is for the already-too-powerful browsers to become more powerful and play a central role in this connectivity business. Like tabbed browsing was an automatic step in aiding this experience by sharing/saving the session throughout the tabs (I'm not sure about Chrome's processes though). If the browsers are responsible for implementing the open standards then all the web apps need to do is suppor the standard. What browsers have been doing for CSS, HTML, AJAX, Javascript, SVG etc. they can do the same for this central connectivity concept, after all they have been termed as the modern OS.


Sunday, March 1, 2009

Design patterns via AOP

Object oriented programming has given this industry numerous gifts and is continuing to prosper. It has been responsible for new methodologies, languages, frameworks etc. As for AOP (Aspect-Oriented Programming) which is a different programming paradigm, never seen as a competitor/substitute to OOP but rather a complement to enhance SOC (Separation of Concerns) experience.

Design patterns have benefited most from OOP and are continuing to grow as new paradigms arise and programming methodologies are born. Advent of AOP has also worked in this direction, even a few patterns can be implemented by directly using AOP constructs and implementation/design of others can vary greatly from their OOP counterparts. And of course there are new ones which lie in this category only.

I did not get a chance to work much in this direction but have come across some good articles which inspired me to appreciate the beauty of a new paradigm/methodology. One of them is a good article by Nicholas Lesiecki.
Dynamic languages come with their own designs and I once went through a very elegant decorator implemented via Ruby. Similarly Functional languages that complement OOP will surely enhance the pattern experience. There is too much ground to cover in this regard, too many directions too go and the catch here is elegance through novelty (atleast for me).

Monday, January 26, 2009

Why did I choose to become a Computer Scientist?

A common interview question, although not yet asked from me (thankfully). Most people say, 'because it was IN at that time', 'my parents forced me to', 'I idealize my ....' and so on.

My answer: Age Of Empires II


It was the year 2000 when I got my hands on this wonderful game when I was studying in first year (XI). I was obsessed by the game, it's story line, game play, sound track, everything just settled into me.

I still remember the first mission's clip: "Behold, the horde of Genghis Khan arrives", and I journeyed through Genghis Khan, Saladin, Joan of Arc, William Walace, oh all that history, what I learnt and what this game taught me, all so true.

I loved the strategy making, playing god, completing the missions till I heard Fajr's adan (yes that was the first time). I remember some of the campaigns exactly how I played them as though my moves were recorded in the pages of history.

During those days, I was just a user of computer, using MS word, playing games, chatting, surfing with a calculated usage of internet (right, I typed my mails in the notepad, connected to the net, pasted them, hit the send button and disconnected), maintaining a notebook of the usage of my 5 hours of net. So, in those days I started thinking about it, you could make a software as beautiful as this just by being a computer science student and having the right amount of passion!!

And so I narrowed down the field of my future studies to be Computers, it was never going to be Medicine as I despised being a doctor (although I loved biology) but Electrical engineering or even a PHD in physics was a possibility.


And I am a very satisfied person to be a Software Engineer and to have that powerful feeling "yes I can make (develop) that".
It's possible in other fields as well, arts, designing, modeling, writing, engineering etc. but the diversity and speed that is found in developing softwares is unmatchable. You have all the elements: creativity, design, architecture, process, engineering, mathematics, equations, business, entertainment, elegance, beauty, you name it.

Was I wrong back then?