Category Archives: habits

It’s important to take break, once in a while

“It’s sunny today, and the road is better.”

When long is the road, and it seems there’s no time to stop.
Try to take a little break, every time you have a chance
Because its value is invaluable.

[youtube=http://youtu.be/Ye7BGnlTZmQ]

http://youtu.be/2OSAhYUacCc  đến lúc thả diều rồi

Hope every one have a good time this weekend.

Good comments, Bad comments

/**
/* Vietnamese:
/* Đôi điều suy nghĩ về cách thức ghi chú (comment) trong mã nguồn.
/* Nếu bạn là một lập trình viên từng bực mình đến phát điên vì ai đó code “chuối”,
/* có lẽ bạn sẽ quan tâm đến những điều tôi viết dưới đây
**/

Not too long ago, I came across an “interesting” question on StackOverflow. It was “What is the best comment you have ever seen?“.

The answer list is very very long with thousands of comments. The highest-voted answer is a comment “placed far, far down a poorly-designed God Object“:

/**
* For the brave souls who get this far: You are the chosen ones,
* the valiant knights of programming who toil away, without rest,
* fixing our most awful code. To you, true saviors, kings of men,
* I say this: never gonna give you up, never gonna let you down,
* never gonna run around and desert you... /*a lot more here*/
*/

Well, it seems all of us developers need a little humor to spice up our steady (sometimes tedious) work. In a work environment with lots of tension, laughs are always loved.

But the thing that caught my eyes in that SO question is not humor. I mean dirty code, which smell through the comments.

// somedev1 - 6/7/02 Adding temporary tracking of Login screen
// somedev2 - 5/22/07 Temporary my ass

From that comment, you see how long a hotfix can live.

#define TRUE FALSE //Happy debugging suckers

If you quit your job, at least don’t treat the maintainers like that.

//Dear future me. Please forgive me.
//I can't even begin to express how sorry I am.

You may think it’s funny. Actually, to me it’s not. Please remember that 60% of developing effort is put on, not coding, but debugging.

Bad code along with poor comments is truly a nightmare to developers. Do you want days in & days out fix bugs caused by comments like this, please go on:

/** * Always returns true. */
public boolean isAvailable()
{
return false;
}

So the question is that: how good a comment should be?

Accoring to Robert C. Martin, comments don’t make up for bad codes. In stead, code should speak for itself, by good naming & structure. For a very simple example, the following code doesn’t have a comment, but it should be fine by itself:

      User currentUser = userService.getCurrentUser();
      if (currentUser != null) {
            if (urlOnlyAllowAnonymousAccess(requestUrl)) {
                log.info("An authenticated user try to access a non-logged-in link. Redirect to homepage");
                httpServletResponse.sendRedirect(contextPath + "/account/home.do");
                return;
            }

            if (urlNotAllowNonActivatedTVAccess(requestUrl)) {
                TVTracking tvTracking = currentUser.getAssociatedTV();

                if (tvTracking == null) {
                    log.info("A non-activated user is trying to access settings. Redirecting to activation page");
                    httpServletResponse.sendRedirect(contextPath + "/account/activate.do");
                    return;
                }
            }
        }

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?

What to do when the computer go crazy

Last week I go to see a trouble laptop of a friend. There are two problems: the DVD drive doesn’t play, and she can’t use Microsoft Office to edit documents. Those things was just fine before re-installing Windows, so I don’t think it’s a hardware-related problem; if yes, a visit to professional repair service is needed.

I tackled the second one first: re-installing Microsoft Office. An error pops out: can’t un-installing MS Office Home & Student. Fine, a search in Google: “can’t uninstall MS Office student home” solve it.

The first one is more trickier. Checking drivers: no problem. Inserting disk: nothing happen. I detect no abnormal symptom, except the additional “DVD Region” on the device manager was pointing to US. Try changing it, the disk shout that an “appropriate region disk” is required. So I… Google again :)

I got some relevant results, just like the first case, but this time it can’t be sure what cause the problem. My only guess is that the “DVD region” might be responsible. Walking through lots of proposed solutions yield no good result.

I gave up at that time. After home, I re-think and find out that my methods depends too much in finding how people solve similar problems. It may not work for a brand new problem, as the solution doesn’t actually arise from the problem itself. I’ll put a short list of my thinking here – hope this list saves someone a little time. On the other hand, if anyone have a propose to improve the methods, I’m more than pleased to discuss it :)

1) What’s strange with the computer? Is there any new software just installed? Is Windows re-installed? Is there any abnormal symptom or configuration?

2) Googling: in my experience, searching in English yield more good results than in native language (Vietnamese). The more you specify the problem, the better the results you get.

3) Ask on supporting forum: there are plenty of them out there. I prefer asking in English global forum like superuser, but any native technical forums is also good.

4) Consider re-installing Windows/Linux/Mac (your operating system). This solution is better if you prepared a Ghost of your system or keeping the original install disk. Otherwise, finding drivers might become a painful task.

5) Ask the experts.

Fighting with the Black Box

Recently I had the opportunity to work with OpenSocial, an rather famous alternative for Facebook Platform. To make long story short, I have a difficult time: the API standard document is fairly good, but it depends on third-party implementations. The troubles arise from here: the OpenSocial implementation of the site is incomplete and have some non-standard parts. I was stuck.

This situation reminds me about many previous cases, in which I must work with a blackbox, with very few documents available. Zend Framework, SocialEngine, Grails… all pre-built system is a big scary Black Box. It’s like a big closed machine: you don’t know what mystery happens inside, but you must depend on it. And in case it’s bad documented, you must figure a way to wade through unexpected results & doubts… Well, I don’t like to say WTF, but it’s really that bad sometime.

On the other hand, it’s just good for not building a thing from scratch. I don’t know how many months it will take if I try to construct something like Grails/ SocialEngine by myself, in case I can live just for doing that. Every programmer once use an API/Framework: nothing new. And all must find a way to ease that pain.

So how to cope with the Blackbox?

First solution is asking senior programmers, who have lots of better experience. I have learn much from Younet seniors in SocialEngine (it have NO bit of document just yet) and just as much about Grails, Java from Evolus seniors. It was a big help when I’m with them – as it still be now.

The second place I look for help is from the community and black-box developing team. Most of this approach happens in cyber space, so I don’t have to worry about disturbing people, but it only works if someone out there know my problem. If the framework/API has a fair community, there’s a good chance that someone met a similar problem before. Hence I can try a Google search, ask on StackOverflow, or simply throw a question on the supporting mailing lists. But notice: when joining a community, there’s some responsibilities that come along with benefits. You need to figure out what you can do in returning the help you received.

Last but not least, in case you get nothing by previous ways, you can only use your creativity now. In my case, if I understand what causes the problem, I will try coming up with a work-around. If I don’t, I will try to throw several kinds of input into the Big Blackbox. The results will tell something, and changing the input little by little may tell where the problem is.

Above is all of my few heuristics for dealing with a closed system. It’s far from perfect and I am looking for some enhancement, but that’s another story.

Dealing with negativity – an incomplete post

Recently, some of my friends often complain about their stress, lonely feelings, worse mood… In short, they feel bad. It’s like spurring ink fluid into a water glass. So I decide to write something for my friends.

About a year ago, I share their same feelings. Graduating from university with not so-high grade, but I’m seriously lacking belief about my ability. I choose to work – not stay at school for learning higher – for the fact that I don’t like studying theories anymore. But I also don’t know if I can work well – I was born an earth-worm and my all family hope that I would become a professor, PhD… But I failed them.

I also failed someone I’m very caring about.

When thing happens, it happen. After all events, I suddenly realize that I fail myself. I fail to protect the one I love for my inability, for the fact that I haven’t trained myself facing difficulties, and lacking of preparation. I said to myself: things can’t be like this any longer. I must get back to shape as soon as possible. The spirit come back.

Well, if someone is in my case, maybe he will be a lot stronger and get back faster. Whatever.

I just need to know what do I live for.

Reading by selection

Reading Happiness

Before going to work, what is your choice of reading? Newspaper, blogs, facebook, twitter,… or nothing at all?


** Vietnamese: Bài viết trình bày ngắn gọn về việc lựa chọn thông tin nên đọc đầu mỗi buổi sáng. Bài viết hoàn toàn dưa trên cách suy nghĩ của cá nhân, và tôi sẽ rất vui nếu nhận được những ý kiến chia sẻ từ các bạn :) **

In our fast-paced society, the things that most people do at the very beginning of a day is consuming news. You can read local news from online new papers, industry news from famous leading-websites, information about your friends & relatives on Facebook, Myspace… But all those information are simply too huge for a single person to read: Digg calculate that everyday the world produce a year-reading for the fastest-reader. What will you read?

It’s worth noticing that not all the information is useful, truthful or even noticeable at all. So what is a good tactics to get the most out of things we read? In my opinion, the first tip is selective reading.

My list of choices for a simple morning:

  1. Inspired story: It’s my first choice. Simple, because I’m all tired with the hard work yesterday, and need replenishing the mind. Those stories also reminds me about what I believe, the motives for that I take actions, the true goal of my life and what should be done now. Philosophically, you may say, but it’s useful to me.
  2. Blogs of choice: following several blogs might be a good idea – I see many good people do this. I believe that following stories of your favorite people would give a big push in motivation. If you are a tech-guy like me, you might also interested in TechCrunch, ArsTechnica or InfoQ, those great sources of innovations, startups, blah blah… StackOverflow/Mailing lists is also a decent selection for a programming careers
  3. Facebook/Twitter: a quick glance for friends, family and so on… Twitter can also be the tools to follow the newest trends in your industry/hobbies, given that you follow the right people ;)
  4. Local News: the fact that until I’m writing this line, I remember that I have ignored this issue for quite a time. It’s not very good: but then I should consider re-organizing the little remaining time.
  5. Task lists: yes, this is indispensable. After reading this, we totally throw ourselves to a new day of work :)

How about your choices?