Monday, December 31, 2012

Moving the blog to my domain

I am moving my blog under my domain. Please visit me there. Thanks.

Monday, August 20, 2012

First Impressions of a budding functional programmer

I have just started learning functional programming. Having spent almost all my time as developer on the JVM (and mostly java), it would have been easier or may be natural to pick up Clojure. I did start on it but somehow could not keep with it. Also I had a burning desire to venture outside the JVM. So I picked up Haskell.
For a brief time now I have been trying to learn Haskell. And boy isn't the language amazing. It's pure functional nature makes you appreciate how the functional paradigm is refreshing different from the imperative world I have been on. Wanted to write down a few impressions, I have had on learning functional programming through the language:

  • The simplicity of the Head and the Tail and how many ways it helps to solve problems
  • The amazing power of recursion and how it can used to solve problems which you never thought could be solved.
  • Higher order functions which allow passing them around and currying which makes problem solving so elegant
  • Type which really govern behavior - Honestly this is something which I am still not sure whether I have wrapped my head around.
  • The thrust in the language to write simple and clean looking code all the time.
These are just a few impressions.
I missed one obvious one obviously. Functional programming reinvigorates your love for math (or for others it might be the first time). I am currently looking at picking up math courses and buying math books.
The journey has just begun and I have a long way to go. If I do something original during this time, you will surely hear from me. Bye for now.

Wednesday, July 18, 2012

Test Driven Development - Recording I

Sometime back, I was working on the development of a service (as part of my work). It was actually a rewrite involving conversion of a legacy EJB based service into simple POJO based service exposed to the external world through Spring remoting. As I had been practicing TDD (and leaning towards behavior driven tests) for sometime, I decided to use the same technique for this work as well. I decided it would be good to record some of my thoughts or opinions about what I was doing and that is why this write up. Though the rewrite use case is the not the typical use case for TDD (which is developing on green field), where it is considered to come out in all its glory, I still felt there are some good points which came out this exercise. Here are a few of my observations of doing TDD with behavior based testing:
  • Let us take a scenario where the Object under test is interacting with third party code. When we do behavior based testing in this scenario, we need to get to know more details of the implementation of the third party code. I did not like it much and started feeling the behavior based testing is making me do this thing, which felt wrong. But later on, I realized that behavior based testing is actually bringing out the fact that the third party code is actually not designed properly and hence the reason for my strife. So this gives me a chance to fix that piece of code. Now, this is nice if I have control on the 3rd party source code. If I have no control on the 3rd party source code then I probably have to move away from behavior based testing to avoid brittle tests.
  • In the pursuit of truly isolating the method under test, I try to mock out all other significant method calls whether external calls or internal methods calls (thanks to mockito's spy). In order to do that I have to increase the visibility of these methods from private to default (package level). I actually don't like doing this. The only saving grace is that the visibility is increased to package level only which still means that it is only visible within its part/sub system of the application.
  • As I write these behavior based tests, I find them very very close to the implementation. So I know that if I have to change the implementation I have to change the tests as well. I am not sure whether this is a completely bad thing. Giving that test is supposed to drive the development, this might be something which is expected (want to think more about this).
  • I realized that as I keep developing through TDD and behavior based tests, I tend to make methods much more granular and cohesive. The methods tend to be small and focused on a single task. This made it easy to test them by mocking other things out. This is a very pleasant outcome of TDD for me.
  • One thing I observed during the process of development is that it is important to have a good set of integration tests. This allows me to catch wrong assumptions I have made during writing of unit tests. Unit tests because of their nature are very focused and hence suffer from shortsightedness. Integration tests help me to overcome this problem.
  • When I am trying new stuff during implementation (say a new technique of persistence etc.) I find it worthwhile to write a integration test immediately after writing a unit test (and the implementation as they go together). This allows me to check out whether the technique is working fine. This idea is just taking the concept of iterative development to a micro level.
As I continue with development, I feel the need to go back and read some of the state vs behavior driven tests related articles. The starting point probably can be 'Mocks Aren't Stubs' article be Martin Fowler. But this time I have decided to read more of them (or may be a book) to get a better idea. Some day I will share what I learn from that.

Saturday, June 30, 2012

Why do Android developers do not make money?

Okay now. Don't expect me to bring some new reasoning here. This is probably known to a lot of us (if not all). Even I have heard about it before many times. But only a few days back, I sort of got it (Eureka! Eureka!).


A friend of mine had bought an iPad 2 just few weeks back. He intended to buy an Android tablet (Asus Transformer) but somehow things worked out differently (that is another story and does not have a place here) and an iPad 2 landed on his lap. He has been using it for sometime now. A point to keep in mind is that he owns a Android Motorola Defy for quite some time and uses it a lot and likes it a lot (already rooted and flashed).


We were talking about apps on iPad (since I have been using one for sometime, I am considered a locally available subject matter expert - I suppose in the country of blind, the one eyed man is the king) for reading PDFs. Good Reader came up as a possible choice and we talked about the fact that its costs a few dollars and is not free. Then it happened...


My friend said: "I need a good app for reading PDFs and since I have already put in the credit card information into the iPad 2, I might as well buy a good app".


I heard that but it did not register first. And then it hit me! My friend has owned an Android phone for a very long time and has never bought an app in the Google Play store. He has never entered his credit card information in his Android phone till date. And he probably will never do it.


When an iPad 2 is registered with an Apple id for using the app store, one is mandated to enter credit card information. Google Android phones on the other hand allow the user to skip that part. That means that as a user, my friend never entered his credit card data in the Android phone but he entered it first thing in the iPad 2. I am sure he must have felt forced and wronged when he had to put the CC information in the iPad 2 and would have liked not to do it. But over a period of time, this just became a matter of fact for him. 


Eventually what matters is that Apple has his credit card information within just a couple of days of him having a Apple product and that has opened the door for his spending in the App Store within weeks. Where as Google still does not have his credit card information and he has not spent a dime in the Google Play store for close to a year.


Like I said, what I am saying is nothing new. I have heard it many times. But when you experience things first hand, it has a way of making things very clear in one's head. That is what happened with me and I had tell it everybody.


What should Google do? Should it force the consumer to enter her/his credit card information upfront? Will that push the consumers to spend on the Play store? Will that make Android a better platform for developers to develop apps? What do you think?.


  

Sunday, June 17, 2012

What is SPDY?

Lately there is a lot of talk about the SPDY protocol (pronounced as Speedy). The recent launch of Firefox 13 with SPDY available by default is very welcomed. Though created by Google, a lot of large entities (amazon, twitter, mozilla etc.) are interested in this protocol. Google has submitted this as a draft to IETF as the next gen replacement Http. Even microsoft is interested and they have also submitted a parallel proposal, which is very much inspired by SPDY.

Now that I have built up the interest on SPDY as the next gen http (hopefully), you might ask: "What is wrong with HTTP? Why should I care?"

Problem with HTTP

HTTP has served us well for a long time and in many ways it was never conceived to be used. Today the content which flows through the internet is very rich with images, dynamic scripts, videos. Some of HTTP's early decisions are not good enough any more in terms of performance. For example
  • One request per connection at a time - Everything a server has to send to the client comes in a serial manner - send one and then the other and then the next. Too slow. Browsers circumvent this by creating parallel connections to the server (creating new connections is not cheap at all).
  • Request always initiated by client only - HTTP works by the principle that client initiates the request and the server responds to it. Even if the server knows that the client would need these resources, it can't really do much about it (neither pushing content nor providing hints).
  • HTTP Headers keep sending redundant information and that too in uncompressed form.
All these mean that HTTP makes the web experience much slow (at least at the rate at which we want it today). That said, HTTP is very prevalent and it handles various kinds of content very nicely.

In comes the SPDY

SPDY as the name suggest is a protocol aimed at changing the performance aspect of HTTP. It preserves the application usage aspect of HTTP and tries to solve the performance issues. It sits on top TCP and provides a session layer. It tries to:
  • work with many concurrent HTTP requests in a single TCP session/connection in the form of streams. A new frame format helps doing this
  • reduce bandwidth usage by using compressed headers and removing unnecessary headers
  • create server initiated streams (push or hint)
SPDY also tries to ensure that content does not have to change to achieve this. This is important because with the amount of web content available in the world, this would just be unreasonable. The idea is to change the user agent (browser) and the content provider (server) to provide support for SPDY.
Another thing to note is that SPDY stays at the application protocol (HTTP is one) layer and does not move into the transport (TCP) layer. This is not because there is no optimization possible at that level. It is more to do with the fact that such changes would need the entire internet infrastructure to change and that will make the protocol a non-starter in terms of its acceptance. 
SPDY also prefers to work with SSL. This does cost on performance, but the idea is to promote a more secure way of interaction between client and server. 

SPDY Implementation 

Google has worked on implementing this protocol and testing it extensively. Their browser (guess which one) supports it and their server infrastructure supports it as well. That itself is a good testing bed for SPDY. A lot of details about their testing is provided in the SPDY white-paper if you interested to check out.
Of course other companies are getting involved as well as I mentioned before.

Development Support

The SPDY project page refers to a lot of frameworks and server software that support SPDY. Some interesting ones are

There are lot more servers and libraries supporting it - please refer the project page mentioned above.

Conclusion

SPDY is already there in the wild now. It makes the web interaction faster for consumers/producers like us. It has picked the interest of other big entities who are trying to improve it further. Google itself is very much involved and is doing a lot of testing. It also wants to involve the open community on it. May be its time we get to know more about it and contribute to it in whatever way we can. 

Sunday, April 29, 2012

Micromax Funbook seems to have some fun in it

Sometime back I came across a news item on the launch of Micromax Funbook. Seemed interesting and hence wanted to read it. Finally got to it today. Also watched iGyaan initial video review on youtube.

Few very good things going for it:
- Android ICS
- Price of 6.5k
- Capacitative
- Google Play available

The looks are also decent. A bunch of useful pre-loaded apps thrown in. Only thing which did seem a problem during the video is the browser speed/snappiness. That is a cause of worry. At the same time I think its worth checking out.

I am going to do that for sure. Given the price, I am very convinced to give it a shot. What about you?

Saturday, April 7, 2012

Zite on Android

It was only yesterday I was talking about Zite to my friend (I have mentioned the app before to them).

I have been using Zite for sometime now. It has been my go to magazine app on my iPad 2 for reading tech and development articles. I have backed its own feed with my google reader and twitter feeds. Almost on a daily basis I keep looking at the top news section and catch a lot of stuff I like to read. It is just become part of my daily routine.

Yesterday, during conversation with my friend I mentioned all this. She was very intrigued and interested and wanted to use it. I told her that there is only a iPad version of the app (and she has a Samsung Galaxy S2 like me and no tablet)  and hence it is not for her.

I was completely wrong. Today morning (actually just a few minutes ago) my iPad was out of juice and I wanted to catch up on some tech/dev news (like usual). I thought Zite might have online presence (I doubted it as soon as I thought it somehow). So I dutifully logged on to their zite, oh sorry site.

And lo behold, what was waiting for me. An Android version. And next thing I did was installing it. I took it for a very very short test drive (using the same account I have on my iPad 2) and at first look I liked it. The content was all there (I still have to check out the user interface properly). According to Zite this was customized for the Android phone and not the tablet. God knows why (may be it is because android phones are much popular than android tablet) but it suits my need well.

As soon as I finish publishing this out, I will message my friend about it (to correct the wrong I did yesterday). 

Sunday, March 11, 2012

Gadget's and their batteries

The new iPad boosts some great features - retina display, higher graphic performance, 4g connectivity etc.  Now all this is nice but what is nicer is the battery life claimed on it. All this and yet a battery life of 9 hrs is great. Of course there is a secret - bigger denser battery. Knowing Apple, they have probably patented it already.

Today's gadgets (smart phones, tablets etc.) are very smart and power hungry. My android phone and iPad are no different. Since I carry my phone around, I always keep a charger handy with me. I am even considering buying a travel battery pack (something like this but maybe of more capacity. May be someday.

Couple of days back I came across some news on silicon nanowire based battery which can hold 10 times that and tweeted about it. Now this was amazing news. 10 times more battery life will be dream come true. But then I noticed that the news item was from Jan 2008 or earlier. What happened after that? I did more digging...
Amprius is the name of the start-up which is working on this and I found an article in GigaOM for a later date (late 2010). It talks about work still happening on the technology to commercialize it. The start-up is backed by many venture capital firms and Dr. Eric Schmidt (I wonder who is that now). Also found this nice graphical piece of writing which explains the technology in simple terms. The amount of increase it can give (whether 10 times or less) is still under question but even if we get 3 times more that will be good.

If this start up makes commercialization of this technology viable then every gadget maker worth their salt (read Apple and Google) will be behind them. Now will some Dr.Schmidt have any say in the matter.

For me, I hope this technology does not get stuck with one of these big players. This technology can make a great impact to on our lives. So what do you think! 

Wednesday, March 7, 2012

Google rebrands its digital content offering as Google Play (No more android market)

Google is creating a single destination for all its digital content: Google play.

I am still trying to figure out what the 'play' here is. I understand that it is good to bring all their offerings to a single place (part of their consolidation strategy I suppose) as that allows me (the consumer) to not have to go to multiple places to get stuff.

What I don't get the name 'play'. I tried reading the faq to find if there is anything mentioned there which will make things clear but could not. Is Google trying to take a shot at the philosophy that 'life is a game, play it'. Or is it that you play games, movies, music and hence the name (but I don't play books. I also get a lot of work done through the apps). I don't get it.

I understand they wanted to move away from being called "Android Market" because it is more than just about Android. Some people have suggested that they should have used something like "Google Market". That does make sense to me but the only thing is that it looks like a beaten/used name with no 'new' factor (others would say it is a well established brand now).

Why so much hue and cry about the name? Its just a name. But if we think about it, it is the name people use the connect to what is offered. Common sense and even user experience science suggest that having a clear good name is always better than having some vague catchy stylish name. Consumers/customers get simplicity and clarity.

So why is Google doing this? Am I missing the 'play' here?

Wednesday, February 22, 2012

Ubuntu for Android

With the news of Mountain Lion out in the open, a lot of integration between iOS and the new OS is being talked about. The desktop OS is trying to be closer to the mobile one thus making the transition seemless. People are also talking about how this might impact the mobile industry and work against Android. When I thought about it, I felt that the argument made sense.

Today I saw the news on Ubuntu for Android. I read further about it in herehere and here. This is a truly novel idea. One device which gives you two different experiences and without any compromise (if it really works like it says). I truly will be able to use a device in two different fully functional and integrated modes (ok, that is repeating the previous line but I just am amazed at the idea). And best part is that it is favorite desktop OS too. Just reading about the amount of synchronization and synergy there will be (sharing the same kernel surely helps) and what can I do with both is really amazing.

One thing that is not clear is the kind of ubuntu based application that will be available on this ubuntu version. More news might trickle down the line.

Now, if you don't want to read all of these links which I have provided above and just want to taste of this thing then jump straight to the below video: