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

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.

主站蜘蛛池模板: 湾仔区| 隆回县| 凤庆县| 阿拉善右旗| 郸城县| 鸡东县| 新河县| 梅州市| 于田县| 茂名市| 垣曲县| 蕉岭县| 大石桥市| 甘孜| 安岳县| 新竹县| 利川市| 东港市| 阜宁县| 鄄城县| 涞水县| 城市| 象山县| 郓城县| 遂川县| 宣恩县| 宁远县| 峨眉山市| 合水县| 错那县| 习水县| 东方市| 梁河县| 堆龙德庆县| 洛浦县| 富平县| 原阳县| 敦煌市| 清远市| 夏津县| 荆门市|