There has been a lot of debate on the various new Tiger language improvements. One of the most debated is the new static import functionality: static import java.lang.Math.*;
This would allow the math geeks to use:
return cos( sqrt(9) );
return Math.cos( Math.sqrt(9) );
but this is controversial…
People are discussing the feature on TSS and elsewhere.
Cedric puts up a defense
The new feature does allow you to bypass qualifying static methods all of the time, and also static variables:
static import javax.naming.Context.*; ... settings.setProperty(INITIAL_CONTEXT_FACTORY, "weblogic.jndi.TengahInitialContextFactory");
One of the main considerations was the fact that currently a lot of people place “constants” in empty interfaces, and have their classes implement that interface to suck in the values. Some people really think this is an antipattern as it tightly couples components together and can be dangerous.
The “right way ™” to do things with 1.5 is to create a class that can’t be instantiated, and use static import to read in the values.
Nic has an interesting idea.
He would like to see an alias setup. If you work with SQL dates and normal Java dates you can get fed up with qualifying the class name all the time:
new java.sql.Date(new java.util.Date());
Nic suggests aliasing:
import SqlDate=java.sql.Date; import StrangeDate=blah.blah.blah.blah.Date; new SqlDate(new Date());
Now that would be a change :/