In this article, the author tries to define transparency and controllability. The author believes that transparency is a passive quality. If you can predict all or most of the program behavior and establish a simple psychological model, this program is transparent. On the other hand, if the software system contains functions designed to help people establish a correct "what to do, how to do" psychological model for the software, This software system is visible. After defining these two properties, the article describes the necessity of software design to meet these two properties. The author first explains this from an aesthetic point of view. The beauty of software lies in its combination of power and conciseness. This combination can also be seen as an elegance (elegance) . From the user's point of view, elegant software means simple and direct Gui Interface, gentle learning curve. From the software developer's point of view, the elegant code means that not only the algorithm is passed to the computer, but also the confidence and insights are passed to the person who reads the code, Elegant Code also brings stability and maintainability to the software system. In section 2, the author describes the principles of transparency and explicit encoding, including eight principles: 1 > Generally, the maximum static depth in the Program Invocation layer is no more than four. 2 > The Code has a powerful and obvious immutable nature (invariable) , Which is implemented by prefix and suffix assertions During encoding. 3 > API Function calls meet the requirements of orthogonal and compact. 4 > Some handy key data structures or globally unique recorders capture the high-level state of the system. 5 > There is a clear one-to-one ing between the data structure and the external entities they represent. 6 > Functions and modules are easy to understand. 7 > Minimize conflicts between special situations and implied situations. 8 > Magic number of code ( Ambiguous constants) Too many, the limit (such as the size of the key buffer) is too obvious. In the last few sections, This article summarizes some design methods that are transparent and explicit, including the following: 1 > Do not stack too many abstraction layers on the code for specific operations. 2 > Data regionalization makes it easier to read and maintain data. 3 > Data (policy) and engine (mechanism) are separated from freeciv. Summary in the software instance. |