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

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c++ - Using OpenSSL in a multi-threaded application -

All overlapping substrings matching a java regex -