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.
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 olivergierke.de/2013/11/why-field-injection-is-evil
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).
+' only accepts the first parameter.');
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.
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."
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.
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:
Rent – 750 for common room(need to pay deposit 1 month when starting the contract )
Transport(bus and mrt) – 70-80
Communications(Singtel) – 70
Food(fruits, lunch, dinner, snacks etc) – 500
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 http://www.orangetee.com most useful(can recommend to email to firstname.lastname@example.org 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 easyroommate.com and put your add there.
Another places where to find the room/apartment is https://www.gumtree.sg/, http://www.propertyguru.com.sg , nestia.com (in no particular order). Or facebook groups.