Note to self: the importance of choosing a correct tech stack

Recently, I decided to use embedded MongoDB instead of using H2 SQL based in-memory database for my personal pet project . However, migration was not as easy as expected.

Initially, I thought that I just need to comment out the dependencies for the H2 and include MongoDB. However, turns out that I was wrong. H2 currently, tightly coupled with the code, and effort to change to MongoDB is larger.

Lessons learned: proper planning has to be done before development starts. Familiarity with the tech does not guarantee the best result, however, proper planning and tech selection give a better result. After all, tech can be learned along the development process especially if the project is small.


What are the advantages of constructor autowiring over normal autowiring or property autowiring?

Constructor autowiring has advantages in that you can make the wired in fields final (particularly useful if your bean will be called from multiple threads as threadsafety is easier to analyse with finals). And you can ensure that the bean is always constructed in a valid way (although you can always implement InitializingBean and use the afterPropertiesSet method to achieve the same if you’re wiring in properties).

One of them is that when testing, doing a mock over a constructor is easy, but over properties it’s a little bit hard

ule of thumb: stick to constructor injection. Why? A constructor specifies the required dependencies of the class being instantiated. With setter/field injection on the other hand, you always have to look them up (by looking at the source code). You may run into troubles (eg NPE’s) because an instance misses some required dependencies. Have a look at


Profile page in React

Finally, profile page is more or less complete. Moved from JSP and JavaScript to pure React.

New profile page is available here:

I’ve noticed that once the terminal is closed the app will stop too. So to prevent app from stopping start with this command:

nohup npm start > output.log &


Move findmydoctor’s front end to react

it’s time re-develop front end of my app at to use React instead of JSP.

Jsp, tiles and handlebars provides cool templates. But React has more appealing component approach that I find more flexible.

Not sure how long it will take to move whole ui, but this move seems meaningful move to do.


added ssl cert to my blog


Initial CSS

It’s a good idea to custom set styles for the elements. However, elements are pre-set to certain puddings and margins . So it’s better to reset them. In your css file:

What are the options we used inside, you can see in my previous post.



Sometimes older browser might not be able to provide support to newer features. So if we want to use unsupported feature(ex.: Object.create() not supported in older IE versions), we must add this support first. Manually adding support is called Polyfill.

To do so, we we must check, if the feature is supported, and if not, then only add it.

In below example, I will add support for Object.create() for IE(or any browser that does not support it).

So, what happens is, we first check if browser support the object create by running (!Object.create) . If browser doesn’t support it, then we go inside the if statement. Then we add create  variable to Object  which will hold the function. Then we check if we are correctly passing the Object that we need to extend (arguments.length > 1) . Then we create new object F(). Then we define F()’s prototype to be o (which is the object we pass inside). Then we return the F(). To sum up above code, the most useful part is F.prototype = 0; . This is how JS extends the features of one object to another. Just like Java’s inheritance.

Then we can use the Object create as usual, even if the browser doesn’t support this feature.




2 Years anniversary!

I created and maintaining this blog for more than 2 years now! YAhoooo!!!

This blog was initially created on 

I’m thinking to move this blog to a new place, so that it will be easier to post the posts with code inside, because currently the posts with code don’t look too good.

Python Uncategorized

Python: Revere string

Probably the easiest and close to the fastest way to reverse a string is to use Python’s extended slice syntax. This allows you to specify a start, stop and step value to use when creating a slice. The syntax is: [start:stop:step].

s = "String to reverse."
print s[::-1]

If start is omitted it defaults to 0 and if stop is omitted it defaults to the length of the string. A step of -1 tells Python to start counting by 1 from the stop until it reaches the start.

When working with large strings, or when you just don’t want to reverse the whole string at once, you can use the reversed() built-in. reversed() returns an iterator and is arguably the most Pythonic way to reverse a string.


s = "String to reverse."
print ("".join(reversed(s)))

Living in the Singapore, cost of living, finding the room or apartment

It’s been almost 9 months I’ve worked in Singapore. I will be sharing some information for those whom can benefit from it.

The average cost that I spend per months goes as follow, all values are in SGD:

  1. Rent – 750 for common room(need to pay deposit 1 month when starting the contract )
  2. Transport(bus and mrt) – 70-80
  3. Communications(Singtel) – 70
  4. Food(fruits, lunch, dinner, snacks etc) – 500

Total: ~1400

The best way to find the room or apartment is to ask the agent to find it for you(you will need to pay the agent fee which equates to the half of the rent(for both room or apartment)). I find the agents from most useful(can recommend to email to please note he only handles the apartment rentals)

If you don’t want to pay agent fee, then your best chance is to go to and put your add there.

Another places where to find the room/apartment is, , (in no particular order). Or facebook groups.