Using Content Delivery Networks or Content Distribution Networks (CDN) is a good way to speed up a website. In short, a CDN distributes assets like JavaScript files, images, or CSS files to locations all over the world, so that users of the websites download the assets from a close location. This helps to reduce routing hops and to decrease latency. A few months ago Amazon started a CDN service called Cloud Front. Although, Cloud Front is the New Kid in the Amazon Web Service (AWS) Family and still beta, it already has good tool support and works just fine. In fact, it is no problem to set up your own CDN with Rails and Cloud Front in just a few minutes. Continue Reading »
Sometimes HashMaps are enough, part three
This part will be a short one because I have to pack for my vacation. Yes, I will leave this cold and miserable weather, heading south to fill up my energy again (I am running on solar power).
Last time we switched from a static approach to an instance based one and introduced a register-method to allow adding Singletons from everywhere. There are several issues with this approach:
- doesn’t support lazy initialization, so far only eager initialization was done
- sometimes not all necessary information is available at register time to actually create the Singleton instance
- maybe you want to track, creation, requesting, and so forth of the Singleton.
Sounds complicated and scary? It isn’t, delegation is our friend again. Another way would be the observer (listener) pattern to address the above mentioned issues, however, delegation is more elegant and appropriate for this task.
heli's blog heli 07 Oct 2008 No Comments
Sometimes HashMaps are enough, part two
The previous post shows how to implement a very simple and static approach to create Singletons using a static “Singleton” class. Now it is time to refactor our solution and make it more flexible.
First, I want to get rid of the static context. Static is very simple but also restrictive and we want and need flexibility later on. So instead of using static variables the get-method should delegate to the real implementation of the Singleton. How does this change our code?
heli's blog heli 06 Oct 2008 No Comments
