--- Bradley Hegel <[EMAIL PROTECTED]> wrote:
>     Was just wondering if there is any advantages over the way I did it and
> the way you would have.  I'm still a semi-new coder and don't really see
> that there is one way or the other, but more than likely I'm missing
> something important there.  Anyways just wondering.

There are 3 immediate advantages to doing it the way I suggested. 

The first is readablilty. The code is clearer and more concise, so it's much
easier to look at later on and figure out what is being done. 

The second is maintainability. Your previous method had each speak type using
their own calls to sprintf, send_to_char, etc. This means that if you decide to
use a different function, or want to alter the messages you'll have to go
through each condition, and modify the messages. This retyping then leads to
typos or small bugs (where you might forget to put in an act message for
example).

The third is expandability. If you want to add a new speak type, you can simply
add a new case, and assign the speak_verb to the new value. No other code needs
to be altered, or added. Much less work to add new features then.


~Kender

P.S. There is also a minor performance gain when using a switch statement over
an if-else if-else construct, though this should be the least of your concerns
when designing new code. It will typically not affect performance all that much
and should only be done if profiling your code shows that there is significant
time spent in an if-else if-else block.

=====
-----BEGIN GEEK CODE BLOCK-----
Version 3.1
GCS/L/C/O d-(+) s++: a-- C+++$>++++ UBLS++++$ 
P+++(--)$ L+++>++++ E--- W+>++$ N !o K? w(--) !O 
M- !V PS+ PE(++) Y+ PGP->+ t+ 5 X+() R(+) tv+@ 
b++(+++) !DI+++ D G(-) e>+++$ h---() r+++ y+++
------END GEEK CODE BLOCK------

__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com

Reply via email to