Surely java programmers these days use Bloch’s suggested form of singletons, e.g.
1:2: public enum Cupcake {
3: INSTANCE;4:5: private Foo someInternalStuff;
6:7: private Cupcake() {
8: // get internal stuff ready
9: }10:11: public void doSomethingInteresting() {12: // super exciting suff goes here
13: }14:15: }
And then in our code we see Cupcake.INSTANCE strewn about.
Ok, that’s fine. But lately I found myself using “$” instead of that big fat “INSTANCE”. I just like how it looks. That “S” with a bar through it says “singleton” to me now.
1: Cupcake.$.doAwesomeness(); // isn't that nice?
This is next to useless information about a personal preference and hardly worth a post. But there it is. :-)
No comments:
Post a Comment