So I have a doozie of a design issue in PHP. I have some CRUD interface but as PHP doesn't have method overloading, I have to make it sufficiently generic - no parameters. But then I also prefer to not have stateful operations such as
- assign object fields
- call object::add()
My workaround as far has been to add class-specific
addFoo( $param1, ... ) { 1. clone self 2. assign clone fields as necessary 3. call clone::add() }
This limits the state to the scope of the method call, but seems needlessly convoluted. Am I better off having an interface by convention, where there are no methods in the interface but semantically all implementing objects are expected to have the CRUD operations? Is there altogether a better approach?
Aucun commentaire:
Enregistrer un commentaire