php - Making classes focus on doing one thing - practically -


this again, more of conceptual question (see previous post is there difference between object , models in php/codeigniter?)

this codeigniter (an mvc framework) on php.

i'm trying work out best ( = practical, , sound principles) way implement example.

in example, in database schema, since using tank_auth on codeigniter, table called "users" has been created automatically me (by tank_auth). 1 user table represents users in whatever role in book lending library application.

a person fill numerous roles simultaneously (lender, author, librarian, manager, etc). had started out thinking should have "people_model" (as m in mvc) wondering if not better this:

there should "lender" model , "author" model , "librarian" model etc. i'm hard pressed explain why make sense, because of oop principle "make classes focus on doing 1 thing (single responsibility)".

so example principle refers to? "librarian" class (model) should have librarian functions. more 1 step far removed, , having "people" class in general done "real person" abstract?... on right track here? i'll have bit of re-engineering... that's learning curve.

this depends on users do, , how different roles are. chances users have more things in common things differentiate them.

you should start single model deals basic user functions. if there bunch of specific db calls need make different users can build out additional, user type specific models. not start since path having write , maintain more code (and duplicate code) rather less.


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -