In memory database vendor promotes “self-diagnostic” software APIs
Apr 5, 2004 — by LinuxDevices Staff — from the LinuxDevices Archive — viewsLinux Journal has published an article on self-diagnostic APIs. Commercial software application programming interfaces (APIs) are a major source of costly bugs, according to author Steve Graves, CEO of McObjects. Too often, Graves writes, these APIs are data structure ignorant — they handle data without knowing its type. This limits the compiler's and middleware runtime's abilities to perform any validation, boosting the chance that programming mistakes will go undetected.
Using database APIs as an example, the article acknowledges benefits — including convenience, portability and productivity — afforded by widely used interfaces.
The downside of pre-defined database APIs is that for an interface library to be able to manage data of any database definition, it must have a programming interface that ignores the type of all data. It must treat the data as un-typed, or opaque.
“To accomplish this,” Graves writes, “databases use void pointers to pass data between the database library and the application program. A void pointer is a C/C++ language variable that legally can point to any type of data. With no type, neither the C/C++ compiler nor the database runtime can perform any validation on them.”
Graves suggests verifying functions using function prototypes — the signatures of functions, introduced in the 1980s. If a function's use doesn't match its signature, the compiler flashes an error message, and the offending code must be corrected before the program can be successfully compiled.
Implementing a self-diagnostic API that harnesses the ANSI C compiler's function prototyping in order to catch programming errors means abandoning the old idea of an API as a static library of functions, but would result in a more intuitive, easier-to-learn programming interface, according to Graves.
Graves argues, carries the added benefit of creating a more intuitive, easier-to-learn programming interface. Self-diagnostic APIs can also be more readable and self-documenting than are functions from a static interface designed for use with an infinite variety of database designs. The article's ample code illustrations, drawing from popular Linux data management platforms, give readers the chance to start deciding for themselves.
This article was originally published on LinuxDevices.com and has been donated to the open source community by QuinStreet Inc. Please visit LinuxToday.com for up-to-date news and articles about Linux and open source.