List:MySQL++« Previous MessageNext Message »
From:Warren Young Date:April 5 2005 6:23pm
Subject:Re: RFC: Row::operator[] change
View as plain text  
Earl Miles wrote:

> Warren Young wrote:
> 
>> But recently, it came to me that the integer overloads were probably 
>> the least useful of the bunch in real-world code.  Intelligent 
>> database design doesn't make the client code dependent on the number 
>> or order of database columns.  So, I wonder if it would have been 
>> better to keep operator[](const char*) instead.
> 
> 
> This depends a lot on how important lookup speed is. The integer lookup
> is bound to be faster than the string lookup. Though there's already
> enough of a speed hit in the mysqlpp::Row stuff that it may not matter.
> 
> However, I can say that my code currently does use the numeric index 
> lookup, because it knows what order the fields are in (they match
> another list it's keeping). So there's at least one instance of real
> world code that uses it.

Noted, but study the patch a little more carefully: it still provides 
Row::col_num() to get a field by column number.

The question ultimately is, which of the two methods of access should be 
given the more convenient array index access method?

Code like in lib/custom.h isn't meant to be read very often.  Code like 
in the MySQL++ examples is definitely intended to be read, often: it 
must be as clear as possible.  Considering just these two examples, it 
would seem logical that it's okay for custom.h to use col_num() lookups 
because clarity isn't as valuable as speed here, while the examples 
should do lookups by column name, in the interest of maximum code clarity.
Thread
RFC: Row::operator[] changeWarren Young5 Apr
  • Re: RFC: Row::operator[] changeEarl Miles5 Apr
    • Re: RFC: Row::operator[] changeWarren Young5 Apr
  • Re: RFC: Row::operator[] changeChris Frey5 Apr
    • Re: RFC: Row::operator[] changeWarren Young22 Jun
  • Re: RFC: Row::operator[] changeWarren Young22 Jun
    • Re: RFC: Row::operator[] changeWarren Young25 Jun
Re: RFC: Row::operator[] changeBruce Keats11 Apr