Question: How do you know when a language’s OO/class/inheritance design is horrible?
Answer: when you have to write THE SAME METHOD in every single extension class:
[php]
public static function tableHeader(){
return parent::tableHeaderMaker(self::ColumnSpecs());
}
[/php]
PHP does not allow a parent class access to an extension class’ static methods (or members).
Or maybe this isn’t so strange? Can Smalltalk, Objective-C, Java, Ruby, or Python do this? I’m very interested…. if you are reading this and know one of these languages, please chime in.
Another gripe: see how I am calling self::ColumnSpecs()? I originally wanted to make ColumnSpecs a static member, but static members can’t have instantiated Classes (or an array of instantiated classes, in my case) assigned to them. So I have to use a static method to generate this array with each call. It works okay in this case, but it’s ugly, and incurrs a performance hit.
[php]
public static function ColumnSpecs(){
return array(
new ColumnSpec(‘shirt’, ‘Shirt’),
new ColumnSpec(‘mailingaddress’, ‘Address’),
new ColumnSpec(‘billingaddress’, ‘Address’),
new ColumnSpec(‘price’));
}
[/php]
1 Comment