In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article introduces the relevant knowledge of "what is Hiram's Law". In the operation of actual cases, many people will encounter such a dilemma. Then let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
01 Hellham's law
In programming, interface and implementation are two very important parts. Usually in a system, the interface is an abstraction that interacts with the system, such as the steering wheel and throttle of the car, the brakes (which we use to control the car and interact with the car), and implementation is a way for the system to work, such as the wheels and engines of the car (through which the car actually works). The benefits of distinguishing interfaces from implementation are very obvious, and abstraction can help us manage these complexities very well when a system iterates quickly and becomes more and more complex and difficult to understand.
It can be seen that an interface in theory needs to clearly separate the users of the system from the implementation of the system. This is true of car systems, and so are other systems. Although the designers work hard, the reality is often cruel. When the system begins to expand gradually, some users begin to rely on some internal implementation details exposed through the interface.
A few years ago, Hyrum, an engineer at Google, observed that:
When API has enough users, your commitment in the contract doesn't matter: all the observable behavior of your system will be relied on by someone.
This is also called "implicit interface law".
In other words, when your API has enough users, all of API's actions (including those that are not included in the public description) will eventually be relied on by others. A simple example is the non-functional factor of API's response time; a more subtle example is that users use regular expressions to match error prompts to determine the type of error in API, even if there is nothing about the error prompt in the API document, but instructs the user to use the appropriate error code. Some users still use error messages (rather than error codes), and changing API error messages in this case actually destroys the use of API.
It is commonly known as: do not follow the routine to play cards.
02 the embodiment of this law in Go
As more and more people use Go, they go beyond the Go specification, are not satisfied with Go's public API, and are "involved" in its internal implementation. You can write Go code, it may not be enough to write large projects, you have to comply with the "Hiram Law" and dig up a lot of runtime implementation details such as GMP, GC, etc.
Although Go officials have been trying to prevent people from getting caught up in implementation details and relying on implementation details, they still can't stop people who love to learn. For example, the map in Go is unordered, but for a certain version of the implementation, the user tests the output. Hey, it is found to be orderly. And rely on it. Go officials "in a fit of anger" deliberately upset the order.
Another example is the initialization order of multiple files in a package, which is not stipulated in the specification. But at present, the official implementation is initialized in the order of file names, so there are likely to be interview questions, and most of the answers are in the order of file names, because it is now implemented, and the source code is there. No, no, no. no, no, no.
For example, the expansion of slice in Go, too many articles explain, what are the rules of expansion, 1.5x? 2x? The specification does not agree on this. And the implementation of different versions of Go often changes. It seems that a good use of slice can not meet the requirements. You have to know how it expands, and how much does it increase each time? It doesn't seem to be any different from driving to know the principle of the engine.
There are many examples, welcome to leave a message!
03 what is the inspiration for us?
In practical work, on the one hand, we should try our best to design the interface and isolate the interface from the implementation, but at the same time we should pay attention to the problem of implicit interface. In particular, the provision of external services (including the basic departments of the company, services to other departments) requires us to think more comprehensively when building and maintaining complex systems. We need to realize that implicit interfaces will limit the design and development of our systems. Although the implicit interface is not theoretically your pot, users will not think so.
Therefore, the "volume" has a theoretical basis. Google proved the ubiquity of "volume" with theory many years ago, and the volume is justified, can you still be tireless?
This is the end of the content of "what is Hiram's Law". Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.