Comments on: Designing a database interface for programmers http://www.xaprb.com/blog/2012/10/22/designing-a-database-interface-for-programmers/ Stay curious! Thu, 02 May 2013 12:36:53 +0000 hourly 1 http://wordpress.org/?v=3.5.1 By: Xaprb http://www.xaprb.com/blog/2012/10/22/designing-a-database-interface-for-programmers/#comment-20359 Xaprb Wed, 24 Oct 2012 12:05:47 +0000 http://www.xaprb.com/blog/?p=2918#comment-20359 I’ve explored The Go Way a bit now. It’s rather low-level and has some abstractions I think are arranged wrongly. I’ll write something about it later.

]]>
By: Perrin Harkins http://www.xaprb.com/blog/2012/10/22/designing-a-database-interface-for-programmers/#comment-20358 Perrin Harkins Tue, 23 Oct 2012 15:11:54 +0000 http://www.xaprb.com/blog/?p=2918#comment-20358 I like DBI a lot, much more than the Python MySQL library. The design of DBI is influenced by the time it was created and the desire to keep the overhead of OO programming to a minimum. That’s less of a concern now, and most people use Rose::DB::Object or DBIx::Class as an ORM on top of DBI these days.

When discussing a next generation of DBI, Tim Bunce has said he intendeds to copy the JDBC interface, since it is widely known.

]]>
By: Shlomi Noach http://www.xaprb.com/blog/2012/10/22/designing-a-database-interface-for-programmers/#comment-20357 Shlomi Noach Tue, 23 Oct 2012 09:09:46 +0000 http://www.xaprb.com/blog/?p=2918#comment-20357 When I started talking to databases, it was with Java. There weren’t any fancy frameworks back then (or none that I was aware of) – you programmed with plain JDBC.

So you had a DriverManager, a Driver, a Connection, a Statement (or a PreparedStatement), and a ResultSet (later on you also got DataSource. I date back to java 1.1).

It actually still works like that today, only you get so many abstraction frameworks like Hibernate and Mybatis (formerly Ibatis), Spring-JDBC and apache-commons (db).

My experience: due to some legacy code I still have to struggle with Connection/Statement/ResultSet etc. It is ugly programming. And it gets you tired and unwatchful. I mean, the only thing on your mind is: “I want to abstract this and get it over with”. At the very best, you may want to throw some _hint_ about what kind of connection you want to get (read/write, read-only, OK for lagging connection, etc.). Otherwise at all managing connections and statements and results sets is plain beurocracy.

Let me give an example: you can use the same statement to execute more than one query. Or you can choose to create a new query by creating a new statement within the same connection. Or, you could ask for a new connection, new statement, new query. How many programmers out there know the difference between the three? How many know the difference between just the first couple? How many want to know?

This hierarchy means more API to manage. You need to pass a special flag so as to get the AUTO_INCREMENT number. You must invoke another method to learn the names of column returned by the ResultSet. And, you only do that on first iteration, since they’re all the same. And this pattern emerges: the pattern of beurocracy programming.

It’s good that there’s a clear hierarchy on the low level; but as it is, there’s a good reason why everyone’s writing frameworks: they are letting you just write code!

Sometimes it goes too far, and complex ORMs can make a programmer loose hair; but the simple abstractions, e.g. Spring-JDBC, or PHP’s CondeIgniter ActiveRecord (not a real ActiveRecord implementation), can make SQLing and coding ever so simple.

The way the language wants you to talk to databases is irrelevant. Someone will write a good framework, that opens and releases connections for you, auto-detects column names on your result-set, auto-detects columns types and applies those types to your variables, pools your connections etc. Or you will write it. You will have your own interface to databases, and you will send queries and get results.

]]>
By: Daniël van Eeden http://www.xaprb.com/blog/2012/10/22/designing-a-database-interface-for-programmers/#comment-20356 Daniël van Eeden Tue, 23 Oct 2012 07:28:34 +0000 http://www.xaprb.com/blog/?p=2918#comment-20356 The “execute Statement to get a Result” sounds simple. But how does that work if the API support asynchronous access?

And please blog about your experiences with Go

]]>