官术网_书友最值得收藏!

Services

Why don't I like this approach?

I don't want the Controller making decisions on how to greet my users. First of all, because Controllers need to stay lean. I want my users to be greeted a bit more dynamically, depending on the time of day, and that will increase the complexity. Second of all, maybe I will want this greeting to be done elsewhere as well, and there is no way I am copying and pasting this logic somewhere else, nor am I going to misuse the Controller just to be able to call that method. The solution? We delegate the logic of constructing the greeting to a service and use that service in our Controller to output the greeting.

主站蜘蛛池模板: 泰安市| 泰和县| 二连浩特市| 双辽市| 嘉鱼县| 文安县| 萝北县| 藁城市| 河东区| 榆树市| 吉林省| 河西区| 罗甸县| 丰顺县| 西乌珠穆沁旗| 陆川县| 凤台县| 出国| 大英县| 新建县| 永和县| 礼泉县| 社旗县| 高邮市| 肥乡县| 湄潭县| 上杭县| 台湾省| 洛扎县| 阳城县| 玛多县| 枣强县| 仙居县| 远安县| 贡嘎县| 苗栗市| 林周县| 青龙| 贵港市| 雅江县| 宜兰市|