So I've finally gotten around to checking out how we've migrated Tags into the new Vocabulary / Terms structure and I've got to say... I'm confused. Every vocabulary and term is going to function exactly the same way, why do we have these massive wrapper classes for them? Tags is 240 lines of code and Tag clocks in at 280. They're seriously not doing anything special, why is there so much code?
The way I envisioned these classes to work, all the logic would be in the
Vocabulary and Term classes. You're getting all / some / one of the Terms in a
Vocabulary, you're getting all / some / one of the objects a Term is associated
with... None of this is any different for any Term. If a plugin is trying to
create a new vocabulary and new terms, they should be able to throw together a
couple of lines for a class for each and be done with it.
When you're defining, say, Tags as the Vocabulary and Tag as the Term, you
should have something like:
class Tags extends Vocabulary {
// this is the information that you'd have passed manually to
Vocabulary::create() before
public $name = 'tags';
public $description = 'Tags, yay!';
// create and return objects of this type when we get lists
public $term_class = 'Tag';
// and what kind of object to terms in this vocabulary get linked to?
we do this as well, although we should improve it - why can't i use a
vocabulary to link against multiple types of objects?
public $object_type = 'post';
}
class Tag extends Term {
// indicate which vocabulary we belong to - this is the same as it's
currently done, should link up with Vocabulary::$name
public $vocabulary = 'tags';
}
The base Vocabulary and Term classes should contain all the logic for getting
and creating their respected objects, returning a tree of terms, etc. Unless
there is something incredibly specific, there should be no code in any of the
child classes. Think of it like SQLiteConnection, where we only have to alter
things that don't correspond with the "standard", like sql_t(). Right now we
have Term and Vocabulary classes that are manually called for every operation
in Tags and Tag, while they should be extending them instead.
Rick and Mike were talking about a related topic on IRC, so I brought this up
with them. Rick said this was really the way he'd originally envisioned things
working but had somehow been talked out of it by Owen and the Aussie... I'm
curious as to why, since he didn't remember anything more than something to do
with "inheritance" and QueryRecord.
The Vocabulary and Term classes could still extend QueryRecord, allowing you to
use ->insert() and ->delete(), just as you normally would, so I'm not sure what
argument there could be there. Perhaps I'm misunderstanding everything and we
just need to do some cleanup on the duplicate code we've got between our
classes and extend them but it seems like we're teetering on the edge of what
I'm looking for yet deliberately staying away for some reason.
smime.p7s
Description: S/MIME cryptographic signature
