Posts

Showing posts from August, 2011

Java: Covariant Return Type — a demo & definition

Returning a covariant type  is the return of a subclass within an overridden method . An overridden method can only be defined in a subclass which is not related to the returned subclass. Methods can also return interfaces. // Return type classes : class SuperClass { } class SubClass extends  SuperClass { } // Classes demonstrating the covariant return type : class NotRelatedSuperClass { SuperClass getInstance ( ) { return new SuperClass ( ) ; } } class  NotRelatedSubClass extends NotRelatedSuperClass { SubClass getInstance ( ) { return new SubClass ( ) ; } }

Java: Static vs Instance Methods — a definition

Static methods in Java are also called " class methods " as they are shared by all instances of a class (aka objects of a class). So static methods  can be used to increment a class field that is also shared by all instances of a certain class. A class field is just a variable within the class scope. This variable might be used to increment a serial number which would be independently accessible by all instances of a certain class. Instance methods are just regular object methods that can be only called by an instantiated object and which are only relevant within a specific class instance (aka object ). class MyClass {     private  static  int myClassId = 1; // this is a  class field ,                                                   // this variable is called "field" because it has a class-wide scope     private int myObjectId = 1; // this is an instance field,                                            // this variable is called "field" be

GWT RequestFactory: Could not locate domain method getMyStuff

Caused by: java.lang.RuntimeException: Server Error: Could not locate domain method getMyStuff You should check whether getMyStuff  is marked public within your server-side code.

Using variables in CSS via GWT

<ui:style> @def corporateTextColor #426; @eval corporateBackgroundColor my.company.Resource.INSTANCE.constant().red(); .aCSSclass { color: corporateTextColor; background: corporateBackgroundColor; /* certain CSS property definitions */ } .anotherCSSclass { color: corporateTextColor; background: corporateBackgroundColor; /* certain CSS property definitions */ } </ui:style>

Several ways to inject CSS in GWT

There are several ways in GWT to include CSS into you code: via  *.gwt.xml using  <stylesheet src="my.css"/> via your container.html  using  <link href="my.css" rel="stylesheet"> <style> /* my CSS */ </style> <style>@import url("my.css");</style> via  *.ui.xml using <ui:style> /* my CSS */ </ui:style> <ui:style>@import url("my.css");</ui:style> <ui:style src="my.css"/> in this case your CSS is checked for validity, so you can't use some CSS3 yet <ui:style import="my.project.CSSResource"> whereby  my.project.CSSResource has to be annotated with @Shared  via the @Source annotation using [ in this case your CSS is checked for validity, so you can't use CSS3 yet] @Source("my.css") MyCSS myCSS();  within an interface called (in this case) My that extends ClientBundle  with a nested interface calle

Scalability: Vertical vs. Horizontal

To scale vertically means that you replace your garage machine, that your cat is using to play Sudoku, by a mid-range server, that may soon became too underpowered, until you have to replace him by an ultra-fast and hyper-expensive high-end server. The point is that you can't extend your server collection but have to replace slow calculators by faster ones . To  scale horizontally  means to assign more servers to the same task. It's basically the idiomatic cloud computing concept. Striving for the later is better in most cases. An economical advantage of horizontal scalability is that it might be cheaper to buy many mid-range machines than a single high-end monster.

Go has closures

Function literals are indeed closures. func adder() (func(int) int) {     var x int     return func(delta int) int {         x += delta         return x     } }  f := adder() fmt.Print(f(1)) fmt.Print(f(20)) fmt.Print(f(300)) Prints 1 21 321 - accumulating in f's x.

Restart/reset sound drivers/service in Lion

After a couple of weeks after its release, Apple's Lion is by far not the synonym for stability & reliability. If your sound system resp. the drivers crash and you  don't want to reboot the machine , just type this into the Terminal. And then ..."it just works"! sudo kill -9 `ps ax|grep 'coreaudio[a-z]' | awk '{print $1}'`