Re: Level Code Blocks

From: Daniel A. Koepke (dkoepke@circlemud.org)
Date: 01/13/01


On Sat, 13 Jan 2001, Brandon Allen wrote:

> as i look at mod docs for circle i see blocks of code such as this
> that are now WAY diffrent
>
> [snip]
>
> may i ask why the this wqas changed ... ?

For a variety of reasons, a few of which I can think of immediately:

  1. It paves the way for people to use algorithms rather than a set of
     values.  If tables were still used, they would have to go through and
     and modify the code that calls upon the tables to make this change;
     now, they need only change the function to what they want.  Users
     gain flexibility at no tangible expense.

  2. Error reporting or returning of a default value for out-of-range
     levels.  Sometimes people up the levels without checking for side
     effects or other requirements.  Using a function, you can report the
     out-of-range errors or simply return a default value.  Users gain an
     error-check or fallback at no tangible expense.

  3. The table entries eventually get out of hand.  If someone adds enough
     levels, enough classes, it quickly becomes a mess of numbers.  While
     the switch/case is going to be longer, it retains readability.  Users
     gain cleanliness at no tangible expense.

As for the WTFAQ, send them to the author.  See:

  http://developer.circlemud.org/documentation/wtfaq/

-dak

--
   +---------------------------------------------------------------+
   | FAQ: http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html |
   | Archives: http://post.queensu.ca/listserv/wwwarch/circle.html |
   +---------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/03/01 PST