Program The beauty of the program should be tasteful from two aspects: one is the beauty of the overall architecture of the program; the other is the beauty of the program Code The beauty of implementation.
Code beauty:
Programming is to write a specific program implementation to solve the problem that a computer can solve.
At the beginning, people always start from discovering the beauty of code, writing code into the main method, and writing some code fragments with independent meanings into different methods; I never know how to reuse code, and abstract reusable code into different places for reuse. There is no organizational structure between classes, at the beginning, classes in the program are organized into different directory structures, so that different classes have different responsibilities. This is the first time that I am confused with OO ideas. From seeing classes as the largest organizational form of a program, to designing programs into different modules, I never knew what the interface was useful, and I found that I would not write programs when I got away from the interface. These are different stages of my programming, and I believe most people will go through different stages. The beauty of the Code is also very specific, to achieve the same function, some people can not do it, some people use one day to write a one thousand-line implementation solution, need to run 1 s to solve the problem, someone wrote a 10 thousand-line implementation solution in 10 days, and the problem could be solved by running 0.01s. Generally, to solve a problem, the more people do, the less computers do. The more careful they think, the less bugs they encounter, the longer the code is. The program with 10 thousand rows is not necessarily slower than the program with one thousand rows. Speaking of the beauty of code, I think of a small question I have seen before: Use the shortest and most efficient code to implement a method, judge whether a 32-bit int number num is a power of 2 (whether there is a n that is multiplied by N 2 to obtain num). If yes, 0 is returned. If no, non-zero is returned.
The best implementation I have ever seen:
Public int count (INT num ){
Return X & (x-1 );
}
The beauty of code is still in many places, such as excellentAlgorithm, Naming conventions, code formats, and so on.
Architecture beauty:
A good architecture is more than half of the system's success. With a good architecture, there are only good or bad implementations, And there is basically no doubt about whether the system can be implemented. The process of constructing a system is the process of abstracting things and processes in the real world. The closer the abstraction is to the nature of facts, the stronger the adaptability, and the stronger the vitality of the system. As a college student who has not yet graduated, I dare not say that I have some unique insights into the architecture of a system. The only decent architecture program is the project. The overall architecture is still successful and the plug-in design is adopted. This idea makes the coupling between modules of the entire program very low, almost completely interface-oriented programming. The first thing about system architecture is to learn theoretical knowledge, learn successful cases, think about what you will do, and have the opportunity to practice more. linking theory with practice is the most important thing. At the same time, we need to think more about the world, think about the relationship between things, and abstract them into a model that can be processed by computers. The smaller the system, the more important the encoding is. The larger the system, the more important the architecture is. However, the architecture of a half-way project I have received is relatively good and can fully meet the actual needs of the application. However, the code implementation is very poor, leading to a serious reduction in the quality of the entire project, this is also very helpless. ReadBeautiful code, elegant architecture, the beauty of a kind of thinking can never stop coming up from the heart, just like a storm.