Python Service Layer -


i using python 2.7.2 , sqlalchemy 0.9.3. department has many groups.

class department(base):     id = column(integer, primary_key=true)     groups = relationship("group", backref="department")     ...  class group(base):     id = column(integer, primary_key=true)     department_id = column(integer, foreignkey('departments.id'))     ... 

where get_groups , add_group methods belong? in departmentservice or groupservice?

class departmentservice(object):     def get_groups(self, dept_id):         ...     def add_group(self, dept_id, group):         ...  class groupservice(object):      def get_groups(self, dept_id):         ...       def add_group(self, dept_id, group):         ... 

or call groupservice departmentservice ?

this answer purely personal opinion. there may better technical reason i'm not aware of.

how both? great backref feature keep database in sync you:

class departmentservice(object):     def get_groups_by_department(self, dept_id):         ...     def add_group_to_department(self, dept_id, group):         ...  class groupservice(object):      def get_department(self, dept_id):         ...       def add_to_department(self, dept_id, group):         ... 

if had choose one, i'd put in groupservice, because wording of functions more natural, means better fit ;-)


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -