design patterns - In proper MVC, does everything have to be a model, view, or controller? -
something have been wondering embarrassed ask until now: in "proper" mvc (strictly adhering pattern), have model, view, or controller? if not, can provide example of when breaking pattern advisable or necessary? finally, role of class (or static) methods in mvc?
concrete example: have models onemodel
, twomodel
. there no natural reason think of them being inherited superclass. both have different properties share emailaddress
field , want validateemailaddress()
each model sometimes. don't want copy on validation code in each model make validationhelper
class class method validateemailaddress(string emailaddress)
call in each of onemodel
, twomodel
.
have broken pattern? how can fix it?
if see model, view , controller layers of application , not components of presentation layer, email validation class part of model layer because contains business logic. don't see break pattern, not every model class has data object.
the problem "strictly adhering pattern" pattern has evolved on time. original pattern intended guis of single user applications. later adapted web different interpretations, regarding responsibilities between model , controller , between client , server. prepare different answers without single "true" one.
Comments
Post a Comment