One of the devs that works with me is following the Open/Closed Principle to add functionality to a Model by extending from our framework ORM.
class BaseModel extends ORM {
...
}
All our models are now inheriting BaseModel
, and this model works well in the context of our application.
class Product extends BaseModel {
...
}
The problem comes when we tried to use the models as if they where extending directly from the ORM, use some of the most basic functionality:
$product = Product::factory();
$product->name = 'foo';
$product->price = 9.99;
$product->save();
This code should have worked well but it failed because now the factory method requires a list of parameters.
I think that as long as the models works well within the context of our product we are good; but I also have mixed feelings about not supporting some of the basic core functionality of the parent class.
Thoughts?