Thursday, January 11, 2007 1:10 AM
kkchan
NULL is really painful!
Frankly, I really don't like NULL. Therefore, I never use NULL in my code if possible. It always give me a lot of problems. Luckily, VFP is more friendly with NULL value. Why do I say so?
- If I add numeric/character data type value with NULL. VFP just return result as .NULL.
- If I compare NULL with other data type value. VFP always "treat" it as true.
- VFP database/table would default field value according to its field type for unspecified field value, for example, ZERO for number and empty string for character field. Unlike other database, NULL is the default.
Well, the "pros" mentioned as above may also be "cons" since these mistakes could be difficult to found out. But at least I like this because it doesn't thrown exception in front of my customers.
May be some of you may feel I am die hard VFP programmer, always live in VFP world. Most of the programming languages thrown exception and default data as NULL in scenario mentioned above. Yes, I agree. But don't you feel that NULL always "crash" your application?
I am exploring .NET recently. I stuck on the problem of .NET complaint unable to cast my field value to a enum. It stuck me for two days. The cause is because default value for integer field value when add new empty record is always NULL so exception thrown. Really frustrated!
Beside of this bad experience, one of my company web product written in Java keep return HTTP 505 error with debug info NULL reference something something. I don't have source code, so I can't investigate on it. But I know, it is caused by some necessary record/field value not filled.