[DUG] Why use a set when a string will work OK (and less code )?

Neven MacEwan neven at mwk.co.nz
Fri May 11 12:24:56 NZST 2007


Stephe (Nah doesn't work)

I certainly agree as far as to say this part of the language construct 
is broken, but then I hate having to declare
a temp var for no purpose at all but to remove ambiguity in references

N
> Hi Neve  :)
>
> I'm not one of the many who don't use the with statement at all, but I only
> use it sparingly and never nested 3 levels deep like the example. I usually
> end up removing it during debug sessions anyway and kick myself for using it
> in the first place.
>
> I think your mate Malcolm Groves sums it up best in his article a few years
> back:
>
> http://www.malcolmgroves.com/stories/2004/04/05/writingSolidDelphiCode.html
>
> (Under the heading "Hard to see, the Dark Side is" about 2/3 down the page.)
>
> Steve 
> (I guess because like the with statement it saves a little typing and one
> syllable)
>
>  
>
>   
>> -----Original Message-----
>> From: Neven MacEwan [mailto:neven at mwk.co.nz] 
>> Sent: Friday, 11 May 2007 10:28 a.m.
>> To: NZ Borland Developers Group - Delphi List
>> Subject: Re: [DUG] Why use a set when a string will work OK 
>> (and less code )?
>>
>> Steve
>>
>> Please explain? also why you are at it why is the diminutive 
>> of Stephen Steve?
>>
>> Neven
>>     
>>> Interesting stuff...
>>> Is it just me or is anyone else horrified by the with 
>>>       
>> statement abuse 
>>     
>>> in example function getStructures?
>>>
>>> Steve
>>>
>>>   
>>>       
>>>> -----Original Message-----
>>>> From: Sean Cross [mailto:Sean.Cross at catalystrisk.co.nz]
>>>> Sent: Thursday, 10 May 2007 1:49 p.m.
>>>> To: NZ Borland Developers Group - Delphi List
>>>> Subject: RE: [DUG] Why use a set when a string will work 
>>>>         
>> OK (and less 
>>     
>>>> code)?
>>>>
>>>> Q.  What is the function to return the enum name?
>>>> A.  See http://www.techtricks.com/delphi/enumname.php
>>>>
>>>>
>>>> Regards
>>>>
>>>> Sean Cross
>>>> IT Systems Development Manager
>>>>
>>>> Catalyst Risk Management
>>>> PO Box 230
>>>> 50 Dalton St
>>>> Napier 4140
>>>> DDI: 06-8340362
>>>> mobile: 021 270 3466
>>>> Visit us at http://www.catalystrisk.co.nz/
>>>>
>>>> Offices in Auckland, Napier, Wellington & Christchurch
>>>>
>>>> Disclaimer:
>>>> "The information contained in this document is confidential to the 
>>>> addressee(s) and may be legally privileged. Any view or opinions 
>>>> expressed are those of the author and may not be those of Catalyst 
>>>> Risk Management. No guarantee or representation is made that this 
>>>> communication is free of errors, viruses or interference. 
>>>>         
>> If you have 
>>     
>>>> received this e-mail message in error please delete it and 
>>>>         
>> notify me. 
>>     
>>>> Thank you."
>>>>
>>>>
>>>>     
>>>>         
>>>>> -----Original Message-----
>>>>> From: delphi-bounces at delphi.org.nz [mailto:delphi- 
>>>>> bounces at delphi.org.nz] On Behalf Of Myles Penlington
>>>>> Sent: Thursday, 10 May 2007 11:18 a.m.
>>>>> To: NZ Borland Developers Group - Delphi List
>>>>> Subject: RE: [DUG] Why use a set when a string will work OK
>>>>>       
>>>>>           
>>>> (and less
>>>>     
>>>>         
>>>>> code)?
>>>>>
>>>>> The advantage of enumerated types is strong compiler type
>>>>>       
>>>>>           
>>>> checking. Ie
>>>>     
>>>>         
>>>>> no spelling/keying mistakes.
>>>>> If you use the normal convention for enumerated types, .e.g
>>>>>
>>>>> MyStayus = (msActive, msPending, msEnded ) etc
>>>>>
>>>>> Then you can use a function and RTTI to convert the 
>>>>>           
>> enumerated type 
>>     
>>>>> name into a string for display. There is a RTTI function
>>>>>       
>>>>>           
>>>> that returns
>>>>     
>>>>         
>>>>> the name of an enumerated type e.g. "msActive", and then
>>>>>       
>>>>>           
>>>> your function
>>>>     
>>>>         
>>>>> can strip off the leading lowercase characters.
>>>>>
>>>>> Myles.
>>>>>
>>>>>
>>>>>       
>>>>>           
>>>> _______________________________________________
>>>> NZ Borland Developers Group - Delphi mailing list
>>>> Post: delphi at delphi.org.nz
>>>> Admin: http://delphi.org.nz/mailman/listinfo/delphi
>>>> Unsubscribe: send an email to delphi-request at delphi.org.nz with 
>>>> Subject: unsubscribe
>>>>
>>>> No virus found in this incoming message.
>>>> Checked by AVG Free Edition. 
>>>> Version: 7.5.467 / Virus Database: 269.6.6/795 - Release
>>>> Date: 9/05/2007 3:07 p.m.
>>>>  
>>>>
>>>>     
>>>>         
>>> _______________________________________________
>>> NZ Borland Developers Group - Delphi mailing list
>>> Post: delphi at delphi.org.nz
>>> Admin: http://delphi.org.nz/mailman/listinfo/delphi
>>> Unsubscribe: send an email to delphi-request at delphi.org.nz with 
>>> Subject: unsubscribe
>>>
>>>
>>>   
>>>       
>> _______________________________________________
>> NZ Borland Developers Group - Delphi mailing list
>> Post: delphi at delphi.org.nz
>> Admin: http://delphi.org.nz/mailman/listinfo/delphi
>> Unsubscribe: send an email to delphi-request at delphi.org.nz 
>> with Subject: unsubscribe
>>
>> No virus found in this incoming message.
>> Checked by AVG Free Edition. 
>> Version: 7.5.467 / Virus Database: 269.6.6/795 - Release 
>> Date: 9/05/2007 3:07 p.m.
>>  
>>
>>     
> _______________________________________________
> NZ Borland Developers Group - Delphi mailing list
> Post: delphi at delphi.org.nz
> Admin: http://delphi.org.nz/mailman/listinfo/delphi
> Unsubscribe: send an email to delphi-request at delphi.org.nz with Subject: unsubscribe
>
>
>   



More information about the Delphi mailing list