[Courses] [C] Writing a spam filter in C, part 0

Kai MacTane kmactane at GothPunk.com
Wed Mar 27 12:24:16 EST 2002


At 3/27/02 10:59 AM , Akkana wrote:

>So I wrote a program called isenglish.c to try to detect these messages.
>(Note: at this point it actually can't tell English from Spanish from
>French; mostly it just filters out asian languages that ought to have
>been in other charsets but aren't.  So the name is slightly misleading.)

Suggestion: change the name to isroman.c, or even isromanalphabet.c, if you 
don't mind long names. (In general, what I'm suggesting here is that, 
rather than adjust the program's functionality to match its name, you 
instead just rename the program to more accurately describe what it does.)

Much less work that way!

I definitely like the fact that it gives you back an essentially Boolean 
error code, as well. That way, you can use it in shell scripting, like:

returncode=`generate-stuff | isroman >/dev/null`

For years now, I've been naming my Boolean variables things beginning with 
"is" and "does", so that it's clear that they're meant to take Boolean 
values. (Note: I usually write in Perl, so I can't just declare them 
Boolean.) Faced with a bunch of Perl scalars:

$TimeOfDay
$DayOfWeek
$IsDaylightSavings
$CPU_Speed
$BusSpeed
$HasEthernet
$IsModemActive
$UserName
$UserAge
$IsUserAMoron

... I can easily tell at a glance which ones should get Boolean values. So 
it's cool to me that your program has the same style.

                                                 --Kai MacTane
----------------------------------------------------------------------
"Three o'clock in the morning/It's quiet and there's no-one around,
  Just the bang and the clatter/As an angel runs to ground,
  Just the bang and the clatter/As an angel hits the ground."
                                                 --U2,
                                                  "Stay (Faraway, So
                                                   Close)"




More information about the Courses mailing list