I want to write a wrapper around MySQL but I will in future extend it to support other databases. I will cover only nasic useful features (commons) but it should be extensible in future with minimal change. I want to write an interface but I cannot get good tutorial to glean wisdom from.

I will be glad to hear your comments and pointers. Don't worry about re inventing the wheel, much of the time is funny way of learning ;)

There's not always going to be a tutorial. Design the interface to suit your needs, and if it doesn't work out, throw it away and start over.

There's not always going to be a tutorial. Design the interface to suit your needs, and if it doesn't work out, throw it away and start over.

Thanks for a comments. I will try it!

Don't underestimate the amount of work it will take to do this. I have written SQL databases from scratch in the past, as well as C++ libraries to "wrap" SQL databases, used in major application software systems that run manufacturing operations all over the world. The database wrapper library was designed so that only parts of one class needed to be re-implemented to support different dbms's, and then loaded as a shared library, allowing the same code base to support Oracle, Sybase, Ingres, and Informix rdbms products without change or even recompiling at the application layer. This was done to replace a commercial library with similar functionality (Rogue-Wave's DBTools) because of licensing and performance needs. I forget how long it took to implement, but it was probably 6 months to a first commercial release, and I had years of experience writing similar code in C already, and years writing complex C++ application support libraries, so I knew what problems were likely to occur before I started.

In any case, Narue's suggestion about design first, and redesign when necessary, is so true! I always start with a design first using UML to model the system. That lets me look at the entities (classes, structures, etc), their relationships, and their behaviors in a consistent and visual fashion. Good UML modeling tools will also let you simulate the system as you design it, and in many cases today support round-trip engineering where it will actually generate code from the model, and vice-versa. The tool I use does that so when I change the model, the code changes, and if I am fixing code or modifying class structures in the code (usually done when doing early functional or unit testing), then the model will reflect those changes. These sort of tools can be very expensive (thousands of $$), but the one I use has an academic license for $105 USD, which is peanuts for an enterprise-class software engineering tool.

Don't underestimate the amount of work it will take to do this. I have written SQL databases from scratch in the past, as well as C++ libraries to "wrap" SQL databases, used in major application software systems that run manufacturing operations all over the world. The database wrapper library was designed so that only parts of one class needed to be re-implemented to support different dbms's, and then loaded as a shared library, allowing the same code base to support Oracle, Sybase, Ingres, and Informix rdbms products without change or even recompiling at the application layer. This was done to replace a commercial library with similar functionality (Rogue-Wave's DBTools) because of licensing and performance needs. I forget how long it took to implement, but it was probably 6 months to a first commercial release, and I had years of experience writing similar code in C already, and years writing complex C++ application support libraries, so I knew what problems were likely to occur before I started.

In any case, Narue's suggestion about design first, and redesign when necessary, is so true! I always start with a design first using UML to model the system. That lets me look at the entities (classes, structures, etc), their relationships, and their behaviors in a consistent and visual fashion. Good UML modeling tools will also let you simulate the system as you design it, and in many cases today support round-trip engineering where it will actually generate code from the model, and vice-versa. The tool I use does that so when I change the model, the code changes, and if I am fixing code or modifying class structures in the code (usually done when doing early functional or unit testing), then the model will reflect those changes. These sort of tools can be very expensive (thousands of $$), but the one I use has an academic license for $105 USD, which is peanuts for an enterprise-class software engineering tool.

Actually I want to write the DB connector to Add DB plugin to my "in house" PHP editor. So it is supposed to be just simple. I'm looking at JDBC to strip down to my need!

This article has been dead for over six months. Start a new discussion instead.