Take advantage compile time checking. Strong typecast check.

Regards
Leigh
http://www.smootharm.com

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of Nick
Sent: Thursday, May 10, 2007 10:49 AM
To: NZ Borland Developers Group - Delphi List
Subject: [DUG] Why use a set when a string will work OK (and less code)?


Why use a set when string work ok? (and I think it's a set)
Question: I have seen this quite a bit and apparently it's "good
practice" however to me it seems like more work.
Example

Whats the point in doing this
MyStatus = (Active, Pending, Ended, Paused, Deleted, Suspended););
type
  Something = class
  name : string;
  status : MyStatus;
end;

then example on create or something
  status := Active;

(yes, missed out lots of steps :P)
and now if I want to show the status, I have to do something like..
If status = MyStatus(Active) then showmessage('Active');
If status = MyStatus(Pending) then showmessage('Pending');  etc

Why go though all that hassle when just doing this is fine
 status : string;
 status := 'Active'
 showmessage(status);

so instead of using "MyStatus" types I just use a string - this means
when I want to output the status to the user I don't have to try and
convert it to string first.
So, why do it?

Hmmmm
Nick
_______________________________________________
NZ Borland Developers Group - Delphi mailing list
Post: delphi@delphi.org.nz
Admin: http://delphi.org.nz/mailman/listinfo/delphi
Unsubscribe: send an email to [EMAIL PROTECTED] with Subject:
unsubscribe


_______________________________________________
NZ Borland Developers Group - Delphi mailing list
Post: delphi@delphi.org.nz
Admin: http://delphi.org.nz/mailman/listinfo/delphi
Unsubscribe: send an email to [EMAIL PROTECTED] with Subject: unsubscribe

Reply via email to