added a comment - - edited
Hi,
apart from the upper/lower thing (I agree we must change to xmldb_table and so on). Some comments:
1) XMLDB objects have that name because of one simple reason. They are JUST some objects, usually read from XML files (install.xml), able to represent one neutral DB structure (tables, fields, indexes...). And they only have a bunch of methods, mainly setters and getters, readers and writers, to be able to represent that structure from php files (upgrade.php). And they don't know anything about DBs nor managers nor generators. Because of that, I really don't understand why we want a new way to instantiate them (from the manager).
2) The example above... keeping XMLDB objects separated (and not mixed with manager) would be:
2A)
$dbman = $DB->get_manager();
$table = new xmldb_table('grade_letters'); // explicity instantiates XMLDB objects
$index = new xmldb_index('contextid-lowerboundary');
$index->set_attributes(XMLDB_INDEX_NOTUNIQUE, array('contextid', 'lowerboundary'));
$dbman->drop_index($table, $index);
oki, I know it's one more line, lets add some more parameters to the index constructor (badly PHP doesn't support multiple constructors), so we can make:
2B)
$dbman = $DB->get_manager();
$table = new xmldb_table('grade_letters'); // explicity instantiates XMLDB objects
$index = new xmldb_index('contextid-lowerboundary', XMLDB_INDEX_NOTUNIQUE, array('contextid', 'lowerboundary'));
$dbman->drop_index($table, $index);
IMO this code is pretty equivalent (in complexity and readability) to the one proposed above. Plus, we are keeping the xmldb stuff definition out from the manager (point 1 above).
Uhm... is really so important the difference between 2A and 2B? IMO complexity of both are 100% the same (the developer has to remember exactly the same things no matter if he/she uses 2A, 2B or the prev. comment proposal.
Also, note that this "reduced" syntax only can will save one line when used with individual fields, indexes (and keys), but haven't too much sense when fields, indexes (and keys) are added to one table (to create it), we'll continue having the same number of lines here (one for each field/index/key to be added). How would you implement this in the above suggestion? You'll need to mix manager and xmldb methods to do so, for example, adding one table, with your alternative:
$dbmanager = $DB->get_manager();
$table = $dbmanager->get_table_object('grade_letters'); // internally instantiates XMLDB objects
$field = dbmanager->get_table_object('id', REST, OF, FIELD, ATTRIBUTES, TO SPECIFY, HERE);
$table->add_field($field);
$field2 = dbmanager->get_table_object('id', REST, OF, FIELD, ATTRIBUTES, TO SPECIFY, HERE);
$table->add_field($field2);
$index1 = $dbmanager->get_index_object('contextid-lowerboundary'', XMLDB_INDEX_NOTUNIQUE, array('contextid', 'lowerboundary'));
$table->add_index($index1);
$dbmanager->crete_table($table);
(looks really horrible, requiring 2 lines per element and mixing manager and xmldb code. -1 here. The "pure" xmldb alternative is only 1 line per element.)
Just IMO... ciao 
This came from some discussion in the Moodle HQ chat where I was getting a bit concerned about the overall db API for developers.
Currently in HEAD upgrade.php files we have stuff like this (comments, $result etc removed)
$dbman = $DB->get_manager();
$table = new XMLDBTable('grade_letters');
$index = new XMLDBIndex('contextid-lowerboundary');
$index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('contextid', 'lowerboundary'));
$dbman->drop_index($table, $index);
A cleaner-looking alternative (from Penny's suggestion, extended by me) could PERHAPS be:
$dbmanager = $DB->get_manager();
$table = $dbmanager->get_table_object('grade_letters'); // internally instantiates XMLDB objects
$index = $dbmanager->get_index_object('contextid-lowerboundary'', XMLDB_INDEX_NOTUNIQUE, array('contextid', 'lowerboundary'));
$dbmanager->drop_index($table, $index);
Something like this could easily be a layer on top of the existing tables (retaining backward compatibility). The get_xxx_object calls just instantiate the XMLDB functions internally, and also call setAttribute as required.