Saturday, October 26, 2013

Tips for High Performance Web Site

I am enjoying my new book "High Performance WebSite". Few awesome tips for making your website better..

1) Make fewer HTTP request
2) Use a Content Delivery Network
3) Add Expires Header
4) GZip Components
5) Put Stylesheets at the top
6) Put Scripts at the bottom
7) Avoid CSS Expressions
8) Make Javascript and CSS external
9) Minify Javascript
10) Avoid Redirection
11) Make Ajax Cacheable
12) Remove Duplicate Scripts
13) Use Image Spites for CSS
14) Versioning Static Assets

We all know most of the stuff but it's always nice to revise :)

Cheers!
Manisha

Tuesday, October 22, 2013

Updating existing Playframework project from 2.1 to 2.2

It is very trivial but got few minutes wasted for not reading the play migration documentation...

I had my old project in 2.1 and wanted to updated to newer version 2.2.0.

So here I am after downloading latest version of Playframework. Subsequent to downloading, I updated the class path to latest version and changed the version in my plugins.sbt file. Dreaming it will work :(.

First Error
-------------
unresolved dependency: play#sbt-plugin;2.2.0: not found
-------------

Simple enough to understand that some plugin name has been changes. Previous plugin name was play but now it's com.typesafe.play. Hence the new line looks something like below.

// Use the Play sbt plugin for Play projects
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.2.0")

After updating this I was confident that I will be able to work on my project now but NOPE... Same old exception. After a while realized that new version of Play comes with new SBT version. So had to update build.properties file to 0.13.0

Update line in build.properties file
-------------------------------------------
sbt.version=0.13.0

This time I was super confident that I will feel the taste of success but same error greeted me with smile. I had to come out of play prompt and did "play clean-all" and then started the play console again. 

BOOM!! Could compile it with new version..

-Manisha



Wednesday, October 9, 2013

Byte Code Enhancement: Eliminates noise for you

In one of our pairing session, I wrote couple of Model classes and public fields. You guessed it right my pair started lecturing me on encapsulation and why it's important to hide the internal representation of an object.  :D 

I am not going into the details of why and what was wrong with exposing the public field. We all know it and pretty much following the javaBean specification all the while for a reason. In gist, we want to save our internal state and don't want anybody to destroy it unintentionally or on purpose.

I assured him that Playframework will takecare of his concerns and will replace the public fields reference with getters and setters right after your original code is compiled by slightly rewriting the byte code.

Playframework helps you eliminate all these boilerplate code where you’d normally write a simple getter and setter, and allows you to just use public fields whenever you DON'T require special logic in a getter and/or setter.

You don’t have to use it, if you don’t want to, you can just create your own getters and setters and Playframework won’t touch your classes.

I would recommend to think little longer if you decide to export or re-use your class outside your application because Playframework does it's magic after class is complied therefore if you ever change your mind to use setters and getters, you have to rewrite your client code. 

Have fun
Manisha