Tuesday, October 9, 2007

Integrity is a Virtue

I've finally accepted that I'm kind of obsessive/anal when it comes to programming and that's probably why I'm so fascinated by C++ instead of all of the other crazy languages out there. But I've started playing around with SQLite and it really bothered me that it didn't enforce foreign key constraints. So I did some digging and found this. It's a description of how you can use triggers to enforce foreign keys. It's actually a pretty slick idea and allows people that want/need them to turn them on without the unnecessary overhead for those that don't care (but it would still be nice if this was just added as a code thing that could be taken out with conditional compilation). But the little online tool is pretty handy and I'd definitely recommend it to anyone that's using SQLite.

Sunday, October 7, 2007

static Initialization Order Fiasco

So I haven't posted on here in quite some time, but I wanted to post about something I learned this week. It's called the "static initialization order fiasco" and it's pretty crazy. First off I always remember that "static is evil" and try to avoid it, but I was helping someone else try and debug a problem and they had used a bunch of C++ fanciness (returning references to static variables inside a static member function) to "hide" the use of global variables and it was coming back to bite them. At first I thought that it must have been some memory problem that they were incorrectly using/overwriting memory, but it ended up being this. It's pretty crazy what types of messes that people can get themselves into when they're trying to be "fancy" but real don't know what they're doing.

Also, I love that "lite" FAQ by the way. It's always got GREAT information and it's usually very well written and very clear. Anytime I have a question about C++, syntax, or odd problems that's the first place I look.