commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Schley Andrew Kutz <ak...@lostcreations.com>
Subject Re: I've ported CLI to C#, next steps?
Date Sat, 26 Apr 2008 16:37:05 GMT
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Well, I see the desire, and perhaps need, for them. Otherwise there  
would be ERR constructors for Option.

- --
- -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 26, 2008, at 11:32 AM, sebb wrote:

> 2008/4/25 Schley Andrew Kutz <akutz@lostcreations.com>:
>> -----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: dev-unsubscribe@commons.apache.org
>> For additional commands, e-mail: dev-help@commons.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (Darwin)

iD8DBQFIE1oxTg8lceyAqqQRAhgQAJ9ELvN1JtLOFAAl5Kt/mT12RoDNgwCcCvXo
f/cePJnuwleH9QQySqkMYho=
=aAUs
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Mime
View raw message