angularjs - Controller and model/service separation of logic -
i understand business logic belongs in model , application logic belongs in controller. please clarify business logic , not include , application logic , doesn't include. giving consideration things redirects, confirmation dialogs etc
e.g.
/** * removes product * @param product */ _this.remove = function(product){ if(confirm('are sure want remove "' + product.product_name + '"?')){ var idx = _this.currentproductsordered.indexof(product); _this.currentproductsordered.splice(idx, 1); } }; or should have confirm dialog box in controller , call remove method?
"unfortunately, pragmatic answer is: 'it depends.'" mvc model not "all it's cracked-up be."
nevertheless, suggest can meaningfully divide problem along line: "'user interface' ... versus ... 'not'"
for instance: "the entire exchange gentle user, no matter is, , no matter sort of technical machinations might involved executing it," falls under auspices of "user interface == controller."
eventually, user commit action. "okay, user wants product go away. it."
now engaging model layer, , telling him, "be so!" instruction being given model layer is, @ point, "an imperative command."
(of course, model might reply: "no! refuse!" in case have go user interface.)
basically, see it, "controller == user interface," , "model == affecting data." but: "it's guideline." it's not set in stone.
Comments
Post a Comment