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

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.

主站蜘蛛池模板: 茂名市| 双城市| 五台县| 简阳市| 专栏| 兰西县| 博兴县| 中山市| 遂宁市| 大姚县| 左贡县| 安龙县| 马龙县| 浦县| 丰城市| 睢宁县| 武清区| 萨迦县| 赣州市| 麦盖提县| 武威市| 岑溪市| 慈溪市| 绿春县| 平遥县| 泌阳县| 新和县| 娱乐| 济宁市| 大埔区| 望江县| 拉孜县| 桦南县| 南江县| 英超| 鄂托克旗| 新龙县| 宝坻区| 利辛县| 永修县| 雷波县|