Services annoying chatters

To share three little funny thing.

    One day I went to a restaurant. After a single point I'm gonna serve in the seat. Waiting, waiting, suddenly the waiter ran and said: "Sorry, we just sold out of tomatoes trouble you to go Simon vegetable market, to buy two tomatoes come back, we can give you cook.."

    One day I went to a restaurant. After a single point I'm gonna serve in the seat. Waiting, waiting, suddenly the waiter ran and said: "I'm sorry, we would like you to try to eat the chef about his innovative new dishes but he has not tried, in case you have to get that thing to bear their own Oh. "

    One day I went to a restaurant. The first day to eat, when, as usual. The next day I went, and the first point of the same dish. Unexpectedly, the waiter suddenly threw me a plate, put my head smashed.

640?wx_fmt=jpeg&wxfrom=5&wx_lazy=1&wx_co=1



    Of course, in reality there is no such restaurant. Which restaurant dare to introduce such a "service", every minute is lift the table hit wherever he goes. However, our system, but there is so true there is such a "service."


    We took a system service. On one occasion, the internal data migration services to do, migrating from a file storage system to another set of file system. The person in charge of services presented to the caller to the service program is: they offer a new query interface. If the first caller to the service calls check once the old interface? If you can not find the data, and then call the new interface re-check again. This is the kitchen with no tomatoes, come back to buy their own customers, not the same?

640?wx_fmt=png&wxfrom=5&wx_lazy=1&wx_co=1


    Using this "Customers buy their own tomatoes," the program is a direct consequence had only need to modify the code in the service interface one can solve the problem, but needs to last caller made a comprehensive screening, modify the code for eighty-nine to complete. If the follow-up would go further modifications (for example, all the files migrated to the new file system, so that the old file system completely offline), you also need to do a full screening of the caller, and then modify the code to several places carry out.

    把服务内部的实现细节“扩散”到服务外部,这就是所谓的“低内聚”。很多服务——不仅是跨系统服务,还有系统内部通过interface来提供的服务——都有这样的问题。有的Excel解析服务要求调用方传入JXL组件中声明的类。这样一来,它就把内部的实现细节扩散到了调用方,从而使得调用方和解析服务自己都被绑定在了JXL组件上。结果,这个Excel解析服务就无法“顺滑”地切换到POI,也很难升级到Office 2007及以后的版本了。


    另外一个系统提供的“服务”更令人啼笑皆非。有一天那个服务的负责人突然找到我,说你们调我们的接口时加几个参数吧!我有点奇怪的反问他,没有接到新需求上线的通知,为什么要加参数?他回答说,他们做了一些优化和改进,但是测试测不过来,所以想让我们直接在线上帮他们测一下。我当时差点没背过气去:这厨师一口都没吃过的新菜,就敢端上来给顾客吃?咸了淡了还是小事,万一食物中毒把顾客吃死了,这责任谁担?

    

    上面那俩“服务”好歹最后还没出错。还有一个服务提供的查询接口直接引发了线上问题:这个服务接口居然不幂等。第一次查询时,接口还能正常返回数据;同样的数据再次调用时,接口居然给返回了一个异常。这不就是那个第二次点同样的菜就拿盘子扔我的服务员吗?

640?wx_fmt=png&wxfrom=5&wx_lazy=1&wx_co=1


    在没有其它操作的情况下,用同样的数据调用同样的接口,返回同样的结果,这就是幂等性。默认操作下,查询接口都应该是幂等的。我是真想不通这个查询操作是如何做到不幂等的——要让它不幂等,比让它保持幂等还更费精力。



    为什么会有这样的服务呢?因为这些系统提供的“服务”并不是面向它的用户、而是面向他们自己的:自己省心省力就万事大吉了,用户?管他呢!因为没有人去掀桌子砸场子,所以这样的劣币可以继续流通、甚至驱逐良币。

    What we have to do it service? Specific requirements - such as power, robust, stable, isolation, high internal cohesion and low coupling, maximum effort, high performance, and so on - not one to say. At least in attitude, we should open a restaurant when their own children, and the user as a customer: Do not let the customers to eat a meal also full stomach complaints. Poor, good attitude but also to develop; good ability, poor attitude is really difficult to guide in the IT industry in this ever-changing technology, it is easy to slip into poor poor attitude of garbage gone.


qrcode?scene=10000004&size=102&__biz=MzUzNzk0NjI1NQ==&mid=100000552&idx=1&sn=620b5f68cd1fc9bd00699da69813693c&send_time=1567089942


Guess you like

Origin blog.51cto.com/winters1224/2433792