Skip to content

Instantly share code, notes, and snippets.

@darylteo
Created February 20, 2013 08:40
Show Gist options
  • Select an option

  • Save darylteo/4994015 to your computer and use it in GitHub Desktop.

Select an option

Save darylteo/4994015 to your computer and use it in GitHub Desktop.
Discussion on static accessors
// I don't believe this should be required
public static MyObject hypotheticalFactoryMethod(Vertx vertx){
Vertx.container.getLogger().log("Created");
return new MyObject();
}
// or even this
public static MyObject hypotheticalFactoryMethod(Logger logger){
logger.log("Created");
return new MyObject();
}
// I could do this, but defeats the purpose of using the platform
public static MyObject hypotheticalFactoryMethod(){
Logger logger = new Logger(...delegate);
logger.log("Created");
return new MyObject();
}
// What I want
public static MyObject hypotheticalFactoryMethod(){
Vertx.locate().container.getLogger().log("Created");
return new MyObject();
}
// Or maybe
public static MyObject hypotheticalFactoryMethod(){
Logger.instance().log("Created");
return new MyObject();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment