language agnostic - When using an ORM to represent a table, is it wise to have non-table specific functions? -
for example (not verbatim)
/** @entity */ class event { /** @column */ protected $time_start; /** .. */ protected $time_end; /** getters, setters, etc */ /** @return duration of event string, non-table function */ public function getduration() { ... } } or should orm table, , nothing more?
this subjective view, has own opinions, in programming there , things , things shouldn't do. wondering if 1 of cases.
not, not idea. if nothing else, violating single responsibility principle.
if making orm, instances should deal data storage/retrieval. in example getduration() part of domain business logic , should reside within domain objects.
basically, dealing here difference between data mapper , active record patterns. and, if trying write code adheres solid principles, 1 consider active record antipatter, in long term causes unmitigated technical debt.
Comments
Post a Comment