Archive for May, 2007

Ruby on Rails

Its somewhat amusing for me to be working on RoR. First I don’t really know the langauge, even though it OO it’s cryptic enough to a Java programmer. Second I’m literally amused by its syntax, such as:


return true unless read_fragment(name)

when_fragment_expired 'fragname', 20.seconds.from_now do
end

Also things like gem (Ruby, Gem, get is just as clever as the way Java Beans and Jakarta project relate to Java itself. Anyway, here’s a vid to tell you it’s the end of JARs…

http://www.youtube.com/watch?v=PQbuyKUaKFo

Comments

IE renders web page bigger than FF

If for an unknown reason your Internet Explorer seems to show things bigger than Firefox, and you’ve checked that it’s not the Text Size, it may be because of your screen DPI settings. The most obvious symptom is when images in IE appear larger and low quality (jagged edges) due to the enlargement.

If so, open your Display Properties, choose “Advanced” under the “Settings” tab. The view here might vary by display card, but look out for an option for DPI settings. For my case I was having 120dpi instead of 96dpi. Once I changed it back and restarted the machine IE was doing fine. However doing so makes my other screen fonts too small on the high-res monitor.

To fix that you’ll have to manuall adjust the fonts in the Display Properties again. I was too lazy so I switched back to 120dpi again, and stayed with the IE tab plugin…

Comments

Static methods in Inner classes

Hit this seldom seen compilation error while writing inner classes.


public class OuterClass {
	public class InnerClass {
		public static void InnerStaticMethod() {
		}
	}
}

This is what the compiler said:

The method InnerStaticMethod cannot be declared static; static methods can only be declared in a static or top level type

Java don’t like inner classes to have static methods, unless the inner class is static. A static inner class means you can instantiate the inner class without an enclosing outer class instance. One quick way to fix this situation is below, but note that you lose access to the outer class instance variables. InnerClass may also be instantiated without an OuterClass by new OuterClass.InnerClass(). Of course this can be prevented by limiting the access of the inner class.


public class OuterClass {
	public static class InnerClass {
		public static void InnerStaticMethod() {
		}
	}
}

Similarly, when the inner class is non-static, static member variables are not allowed. But static finals are permissible.

Comments (1)