Current location - Training Enrollment Network - Education and training - How to write the advanced route code of football team with java
How to write the advanced route code of football team with java
The advanced road of Java programmers

1. Introduction

The brothers who engage in Java definitely want to by going up one flight of stairs, solve more problems with less code, and prepare for possible inheritance and maintenance with clearer structure. Thinking about crossing the river by feeling the stones, I have also seen the learning route introduced by many people. After more than ten years, there are still some gains. Now I summarize an article through my own experience for brothers' reference.

2. Make good use of the framework being used

In the team that has joined, cooperate with everyone to use the framework chosen by the team. Whether the framework is good or not, there must be some truth in choosing it. And the framework that can be popular in the industry for a long time must have its own advantages.

The first step in using the framework is to get familiar with it. You can realize new functions or modify existing functions by copying and modifying predecessors' codes, and gradually get familiar with the use of the framework.

The second step is to learn more about it. After using it and using it for a variety of purposes, we can grasp its laws according to usage and phenomena, thus forming a guess on the internal structure and operation mechanism of the framework, most of which are definitely correct.

The third step is to make good use of it. After having a certain feeling of the internal mechanism of the framework, we can achieve the same goal by adopting simpler, clearer or more efficient methods, gradually summarizing and adopting better practices. You can refer to the "best practices" documents of the framework (such as the last chapter of the Hibernate reference manual). For those who do not provide the "best practices" documents, you can sum up some experiences and constantly improve them.

There is no absolute best practice, only the best practice suitable for a certain scene and the better implementation suitable for most occasions. Being able to choose different modes according to the scene is a sign of improving the level.

3. Understand standard class libraries, enterprise-level technologies and open source projects.

The existing accumulation in the Java world is already very rich. When a problem feels like a common problem, there are probably ready-made standard class libraries or open source projects there. Mastering standard class libraries and open source projects can reduce the workload and make the code structure clear and easy to understand. Enterprise-level technology refers to the technology in JavaEE platform, most of which are standards extracted from existing accumulation. For example, JPA is largely from Hibernate. The application of enterprise technology is very beneficial to the standardization of programs.

The understanding of standard class libraries and open source projects is in no particular order, and can be carried out alternately to see which one to use. You can also use your spare time to choose your favorite study and do experiments.

3. 1. standard class library

You can see a list of standard class libraries (and platform tools) and their relationships in the documentation that comes with Java. The following figure is a hierarchical diagram:

In order to pick the points that interest you, go in and learn more.

At first glance, there are many contents, but in fact, many of them may have been used. JDBC, for example, should be used by every Java programmer when he was young. JNDI should also be a must for WEB engineering. Maybe just a few APIs, but everything is three steps: understanding, proficiency and mastery. If you understand, it's not far away.

Among them, regular expression, XML processing, applet, concurrency (multithreading), network, IO and graphics are practical functions, so we can start with them first. Local interface (JNI), management extension (JMX), reflection, etc. It can be used in more advanced occasions, and more scene solutions can be provided after the meeting.

3.2. Enterprise Technology

Including JavaMail, JMS, EJB, JPA, JSF, web service, etc. The specific list can be found in JavaEE Technology official website. These technologies are not profound to use, and even more obvious than standard class libraries.

3.3. Open source projects

Frameworks are generally open source projects, and Apache is the organization with the most open source projects at present. You can learn open source projects through requirements. For example, if you need to deal with Excel documents, learn to use POI. To use web services, look at CXF;; If string processing is needed, it depends on whether it is implemented with Commons Lang; If IO operation is needed, it depends on whether it is implemented in Commons IO.

In addition to Apache, there are many open source organizations such as eclipse, springsource, Jboss, etc., which provide a lot of free good goods. It's a good way to get to know them when you have time. "Gentleman's nature is the same, good at personal leave"-a powerful guy doesn't necessarily write everything himself, but often uses various artifacts in combination.

By the way, many open source projects use unfamiliar English words or self-created words as their names. It's best to go to official website to confirm its pronunciation. Many people pronounce Struts (original meaning: swagger) as Struts, which is obviously confused with Struts (structure). That sounds really amateur. And PostgreSQL should be pronounced PostgreSQL, not PostgreSQL. Please respect the original intention of the author. Debian should be pronounced "Dai Bo Ian", which is a combination of the author's and his wife's names. It's a pity to pronounce it "shit" And don't watch Ubuntu.

4. Write the program better

4. 1. The code format is concise and elegant.

Try to follow official website's code format suggestions and make good use of Eclipse's automatic formatting function.

Complex conditions and circular nesting are refined into methods, and the names of methods are meaningful, so that future generations can see the program as if they were reading straightforward English sentences. Pursue code self-annotation. Attention should be paid to replacing Pinyin with words as much as possible, especially the interactive interface between modules (it is best to use it in a small range within the module). Mixing English words with Pinyin will confuse future generations. There are many kinds of electronic dictionaries now, all of which are very easy to use. Make good use of them, make the code elegant, and know more words at the same time.

4.2. Efficient code content

After using many frameworks and open source projects and writing many programs yourself, you can start thinking about practicing what is said in effective Java, and when, where and how to use appropriate technologies and mechanisms.

5. Understand the pattern through standard class libraries, enterprise-level technologies and open source projects.

When it comes to patterns, people may first think of "design patterns". Many beginners also read the book Design Patterns to make progress, but according to my experience, I didn't understand at that time, I didn't know why those patterns existed, and I didn't know when they could be used. In fact, the so-called "pattern" is just an idiom of predecessors, which is considered easy to use and widely circulated by later generations. The previous code was copied and changed, and such code can actually be said to be the realization of some kind of "mode".

With the use of standard class libraries, enterprise-level technologies and some open source projects, the feeling of patterns will be established in your mind. These class libraries, technologies and projects themselves have realized many patterns, and their use is also patterns. But the latter is often called actual combat, but it does not appear in the publication in the form of "model".

Patterns include design pattern, enterprise application architecture pattern and J2EE core pattern, and there may be many other patterns. Standard class libraries and open source projects (including many popular frameworks) make excellent use of them because of their flexibility, convenience and elegance.

Spring is the realization of factory pattern. JDBC and JMS are implementations of abstract factory method patterns.

Besides the well-known MVC, Struts actually implements several J2EE core patterns.

Hibernate uses the proxy mode internally, and the overall existence is the realization of "table data entry" under the enterprise application architecture mode. CMB in the old EJB2.0 is more like the implementation of "row data entry".

These models are directly studied as concepts. Without practical experience, we won't know why they exist, and we won't know how to use them, just like what I did at the beginning, with twice the result with half the effort.

Ready-made products will feel better if you use them more. Feel the convenience they bring, and compare with similar functions, we can see the existence and Excellence of various modes.

6. Understand the true meaning of object-oriented.

Knowing the patterns, we will find that the foundation of realizing these patterns is the encapsulation and polymorphism provided by object-oriented, which is also the significance of the emergence of object-oriented.

Eight principles of object-oriented are introduced in agile software development-principle, pattern and practice. Among them, I value the principle of "single responsibility" most, which is very helpful in the division of modules, and its idea can even be extended to the construction of organizational structure.

7.outlook- Architect

With the above steps, you should be able to exist as a qualified designer. To be an architect, a trainer once told us, "Learn the Linux kernel."

The big steps are: read 0.0 1 to understand its structure, 0. 10 to understand its progress, 0. 12 to understand its perfection, and the latest version to understand its current situation.

The learning method is to use UML tools to reverse engineer the downloaded Linux kernel source files. From the obtained class diagram, we can see the dependence of modules, and the module with the largest degree is the core of the system. From this module, we can see how it schedules other modules, and then see how each module realizes its own functions.

8. Conclusion

These steps have no strict boundaries and can be interspersed and iterated.

Learning is a process of divergence and then convergence. At first, it seemed to be directed at a fan. The more times you go out, the more you don't know and the more you need to learn. But later, you will find that what you have learned has a lot in common, and what you see can be understood quickly. You can even find that some things are just old wine in new bottles, and you can see them with your eyes.

Fools see different things, but wise people see the same thing. Fools find the world difficult to master when they see things different, while wise men are good at seeing similarities (laws) between things to achieve twice the result with half the effort. Since programmers can do it, don't treat yourself like a fool.