Monthly Archives: July 2011

The power of community

Here are some thoughts about community & its influence to technology.

Together we build the communities

“Community power” – this word has stuck in my head for a long time. If every people spend a penny to help a poorest people, he then will becomes richer than 10 richest man of the world. There are many sample for that:

First, the Great Wikipedia. No money for maintainers. No money for contributors. Just a place for people to build their knowledge towers together. The interface of the site is very simple – but refined enough to easily see the structure. Now what? Every year, it brings on hundreds millions of dollars from donators – and even more valuable – the contributions of millions of people, which makes the site in 10th most visited site in the world.

Second, StackOverflow – the place for guru & junior programmers. Its philosophy is simple: if you meet a problem, there’s a good chance that the problem has happened for anothers. So why don’t put all the questions & solutions in a place, so that the others can find them later? The success of StackOverflow also depends much on its community: you won’t easily find a QA site that every question has good answer in a couple of minutes, and often not more than a day. How can the site do that? If not because of a community of active members of programming experts (at least to some extent – everyone is an expert of what he has done). Where are that community come from? It has a good start: lots of beginning members are from the Joel Spolsky blog Coding Horror.

Third, you may count Groupon; Facebook; Quora, GooglePlus. In short, it’s social. You may ask why I put so much big name at the end. Well, I don’t know them as well as two first example, that’s a fact. But there’s another reason: long time has passed since the day we only believe in what the mathematical statistics tell. Even Google indexing algorithm partly based on the selection of majorities to tell which link is good and which is not approriate, for a specific keyword. Now, when the social time has come, we not only want to know what “stranger & general community” tell, which may not be familiar with us. We want to know what our friends, couples, relatives,…  - the people in our personal, “selected” community – think and like.

And the only thing that those companies do is making for us a tool to do that.

Believe me, Facebook is nothing without its huge community of user. They just set up a place for people to meet, and they come. Setting up a place like that is not hard – the important point is how to attract people come in. And look at Facebook success, I believe that problem worth solving.

Groupon is another great example. You buy one shirt and I buy one shirt, the price is double. But if I buy 2 for both, I may get a discount. If people with the same needs join to buy the products they need, they give save tons of money – and the producers will save their advertisement, too.

Thanks my good friend Vu Phong. Your enthusiasm about beautiful technologies give me energy to write this post :)

And thank for my sagisou, too.

The total of your FB friends – complicated rules confuse users

Facebook friends

It’s a shady day today. It’s great being outside with the small rain, windy air & not too harsh sun. I feel it’s really a good time to take a break, after all the long days.. but now, instead, I return home to write this tiny article.

Facebook’s great success makes “FB developing” one of the technology “buzzword” today. When making a website, there’s a good chance (if not always) the customer will ask to socialize things up, and well, the certain solution is Facebook. And I can be sure that many of developers would be proud to call themselves “Facebook app developers”, a title which seems more shiny to non-technical buddies.

Well, actually, the inside is not that glorious. If you do not concern much about IT, you may not know that most people who call themselves “FB dev” actually have no relation to Facebook. They just use the API libraries that Facebook provides to build application on Facebook Platform.

And that APIs sometimes sucks.
(warning: technical stuff next)

Surely Facebook has invested some efforts in their APIs. But personally, I think it’s not good enough comparing to their big success. Facebook APIs is rather likely to change, their documents are not very-well organized, and sometimes, make developer’s life harder because of mysterious “bugs”. I myself once met a bug like that – which is named the total friend number.

If  in any chance, you notice that your FB friend number increase or decrease(without adding or removing any friend), you will know what I talk about. And you may already find a friend which is in your friendlist, but you can’t see them in your Mafia war clan.

Our case is like this: in the project we use RestFB APIs to retrieve user infomation from Facebook to import into our system. Things work fine, until the QCs complain that her friend number on Facebook is different to the number of friends we got from calling FB APIs.

And the bug hunt begin :)

First, I think that it’s because of Facebook. Sometimes I see my total friend number varies after several seconds. It go up then go down without any reason. I thought that some of my friends deactivate their account, so they won’t be count at that time.

But our experienced QC brings another surprise: she point out 4 person who are her active friends on Facebook, but “invisible” in the list we got from RestFB service(249 in her list vs 245 returning by Facebook APIs). Very real & very magical – I can’t understand what happened, so I ask her to carefully filter the friends that we can’t get from the APIs. It maybe because some sort of text format – RestFB may have some bugs when users put strange characters in their username. And when the QC re-check – thanks God – she saw that she have 250 friends, not 249! Even Facebook doesn’t know how to count, man!

About 4 people that missing in the list, we eventually find out what’s the trouble. Facebook privacy settings is complicated indeed. They provide a setting option that give the user right to turn off all applications. Whenever the user activate this function, they are invisible in all application, which means their friends can not invite them in any FB platform applications, games, and so on..

In the end, we closed that bug. It’s such an irritating experience when working with third-party APIs.

Warning about primitive ModelAttribute

Recently while working with Spring Framework 3.0, I stumbled upon a trap that might be a bug of Spring Framework. It costs our team lots of time & efforts, since the bug is like a mystery that happens randomly. Eventually we decide to take a work around, but it’s still take lots of time to change the way the system was working.

The mystery is called Model Attribute, a handy utility supported by Spring 3.x.

Personally, I like this feature a lot. The ModelAttribute Annotation way gives me the ability to declare and init a variable just once, then it will be automatically added into model of any action. For example:

public User getCurrentUser() {
return userService.getCurrentUser();

But a problem happen here & there when I use primitive type (long, int, …) or even their wrapper type (Long, Integer,…) for the ModelAttribute. An error just pop out of nowhere:

java.lang.NoSuchMethodException: long.()<init>

Following my senior hint, I even comes to the code of Spring Framework, and actually see that it try to call the default constructer of Long type. Since that constructer does not exist (certainly), it fails and brings up the error. The headache is that this thing does not always happen: I still can not figure what trigger it up. But the fact that it’s out there make me & our team change the course of the program: instead of an tidy assignment, now we need to call the same function again & again whenever we need that modelAttribute (almost always in my case).

I have put a question out there in StackOverflow, but it still get no-good answer. I wonder if I should raise a bug for Spring… but until then I think that this “brilliant” way shouldn’t be used.

Hope this post is useful for anyone come across the same problem.

Finding key issues of the framework

Website System

1. How to learn a framework fast?

2. To learn a framework, you should grasp the “key” issues. But how to know what is a key issue?

Those two questions are pinned in my head somehow.

Not long ago, I’m investigating MVC model in Spring Framework 3.0. Most of the concept is fine, but I have problems doing the work with Spring 3 annotation config. It just seems all the book out there mention about Spring 2.x syntax, which is “xml configuration”. It’s easy to understand because that Spring 3 just appear and it will take a relative time to make a book available. So my habit about following book guides was discarded aside. I must try to find another source.

According the advice of my seniors, I go to the Spring document & find most of the thing is already here. Enough details, though a bit complex to a not-quite-familiar-with-java coder. I struggle with those concept a bit. But by comparing the document to several examples, finally I got some “working things”, which is great.

But here comes the most complicated part: integrating between frameworks. In one of my projects, I should use Spring combined with Freemarker. I investigate, and luckily enough, find this page which tell me how to use Freemarker macro to perform bindings (it’s not an easy luck).

But WTH, I can’t find a way to use the formCheckboxes! I found no working sample, and I’m not alone.

Dozens people out there can’t find a way to use that macro.

And the solution?

Well, I write my own macros.

It took me quite a time before I relize that simple solution, and curse how stupid I am. Since the end results of freemarker is HTML, who cares if it was rendered by supported macro or customed macro?

When you know what actually happens inside that big system, the answer seems to be natural.

Still remember 2 questions at the beginning of this post?

I must says the truth, that I don’t know the best answer. But I have something that seems to work:

The solution depends on the needs. If you just use the surface of the libraries API as the common “players”, some popular tutorials might be enough. Parsing XML maybe a good example for this issue. With the same reason, I think with beginner, Grails (instead of Spring) is a good start, cause it requires little work to make a full-fledge simple application.

If you want to create a customized & not-so-popular web application, it requires more tons of work. And a solid background is preferable.

Say and Do

This post is written as a principle reminder – maybe for my whole life.

When I promise a thing, I will do it. Whatever anything happen.
I will value my promise. When I say a thing, I mean it and will never be regret.

Are you listening, my sagisou?