I kind of agree with the delegation (and the blackbird metaphor :), but I'm looking for a way to push common columns down into base classes. So from these classes I would extend, say, Expirable into a user account (let's call the class User and the table user):
Code:
CREATE TABLE user (
user_id VARCHAR(30) PRIMARY KEY,
user_name VARCHAR(60),
valid_from DATE NOT NULL,
valid_to DATE,
modify_time DATE,
modify_user_id DATE
);
and then
Code:
public class User extends Expirable
{
private String id;
private String name;
// all other properties in the base class
}
So I'd like to be able to push the valid_from/valid_to/modify_time/modify_user_id columns down into base classes. Am I still approaching it the right way, or is delegation still the best way? I'd rather not have separate tables for the auditable and expirable interfaces/classes, as while they
are properties, they're ones that all the tables and classes share, hence the base classes.
It's all about how you design your class hierarchy (or lack thereof ;)