2008/4/25 Schley Andrew Kutz <[EMAIL PROTECTED]>: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > In C# you cannot reference a static method, field, or property accessor > from an instance reference (static or otherwise), hence the following code > is illegal: > > Option timeLimit = OptionBuilder > .withLongOpt("limit") > .hasArg() > .withValueSeparator() > .withDescription("Set time limit for execution, in mintues") > .create("l"); > > So, in order to maintain elegance I have come up with a solution. I have > changed OptionBuilder's static methods to instance methods, but created a > static property accessor called 'Factory'. Factory is defined as such: > > /// <summary> > /// Returns a static instance of OptionBuilder. > /// </summary> > public static OptionBuilder Factory > { > get { return instance; } > } > > So the original code now works with one small variation: > > Option timeLimit = OptionBuilder.Factory > .withLongOpt("limit") > .hasArg() > .withValueSeparator() > .withDescription("Set time limit for execution, in mintues") > .create("l"); > > Instead of accessing static methods via a static instance, the code is now > accessing instance methods via a static reference. This should avoid > performance degradation and maintain the elegant way you have documented to > build options via OptionBuilder, with the small addition of 'Factory'. > > Thoughts? >
Seems like a good idea. I always disliked the chained static references. Although Java alllows them, some IDEs and code quality checkers rightly (IMO) complain. > > - -- > - -a > > "condensing fact from the vapor of nuance" > > gpg pubkey: http://www.lostcreations.com/~akutz/akutz.gpg > lostcreations ca: http://www.lostcreations.com/lostcreations.com-ca.crt > > On Apr 25, 2008, at 4:43 PM, Schley Andrew Kutz wrote: > > > > > > -----BEGIN PGP SIGNED MESSAGE----- > > Hash: SHA1 > > > > > > Damn Java and its allowing you to access a static method from an instance > reference!!! The with... methods in OptionBuilder have lost their > elegance... > > > > - -- > > - -a > > > > "condensing fact from the vapor of nuance" > > > > gpg pubkey: http://www.lostcreations.com/~akutz/akutz.gpg > > lostcreations ca: http://www.lostcreations.com/lostcreations.com-ca.crt > > > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.4.7 (Darwin) > > iD8DBQFIElhkTg8lceyAqqQRAh0gAJ9ScFgyYbkXaVaD7bybyhKyLq89pACg7Z05 > v01+3CRt7/h3AdBf6E5LJTY= > =RTaB > > > -----END PGP SIGNATURE----- > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]