Home  >  Article  >  Java  >  Experience in learning Java

Experience in learning Java

巴扎黑
巴扎黑Original
2017-07-22 14:28:361937browse

1. How to learn programming?

Java is a platform and a programming language. How to learn programming well is not only applicable to JAVA, but also to other programming languages ​​such as C++. Some programming experts believe that there is no difference between JAVA and C, just use them. Why can they reach such a state? I think it’s because there are similarities between programming languages. Once you understand the essence of programming, you can naturally understand everything. Of course, there are many things in common about how to learn programming.

1.1 Cultivate interest

Interest is the motivation that keeps you going. If you only use writing programs as a means of making a living, you will live a very tired life and be very sorry for yourself. Pay more attention to interesting industry stories and think more about Gates. I’m not advocating daydreaming every day, but if people don’t have dreams, do you think it tastes good? Maybe like many local farmers in Shenzhen, they play mahjong, drink Kung Fu tea, and pay homage to the God of Wealth; they earn tens of thousands or even more every month, creating a "rentier class" out of thin air. Do you think this tastes good? If you have time, go to some programmer forums, and you will find that they are actually very optimistic and humorous, and sparks of wisdom will appear from time to time.

1.2 Choose programming languages ​​carefully

Men are afraid of entering the wrong profession, and women are afraid of marrying the wrong man. Beginners need to be careful when choosing a programming language. Software development is not just about mastering a programming language, it also requires background knowledge in many other aspects. Software development is not limited to a few fields, but has penetrated into almost every corner of all walks of life.

If you are interested in hardware, you can learn C language/assembly language and enter the field of hardware development. If you are familiar with telecommunications industry knowledge and networks, you can spend more time on C/C++, etc., with a view to entering the field of telecommunications software development. If you are familiar with operating systems, you can learn C/Linux, etc., to lay the foundation for Linux kernel development/driver development/embedded development. If you want to get involved in the development of application software with the widest range of applications (including e-commerce and e-government systems), you can choose J2EE or .NET, or even a LAMP combination. Each field requires different background knowledge. Making application software requires familiarity with databases, etc. In short, you need to choose a programming language that suits you based on your own characteristics.

1.3 Be down-to-earth, fast food style learning is not advisable

Share a story first.

There is a child who likes to study biology very much. He wants to know how those butterflies come out of the pupa shell and turn into butterflies and fly. Once, he walked to the grassland and saw a pupa, so he took it home and looked at it. After a few days, a crack appeared in the pupa, and he saw the butterfly inside began to struggle, trying to break the pupa shell and fly out. This process lasts for several hours. The butterfly struggles very hard inside the pupa and cannot get out. The child couldn't bear to look at it, so he thought it would be better for me to help it, so he picked up the scissors and cut open the pupa, so that the butterfly could emerge from the pupa. But after the butterfly came out, because its wings were not strong enough, it became very bloated and could not fly.

The lesson this story gives us is: haste makes waste.

Impetuousness is the most common mentality among modern people. Who can blame it? Maybe it’s because we have been poor and backward for so many years, just like the Great Leap Forward, we all want to stride into a communist society. Today's software companies, customers, governments, schools, training institutions, etc. are filled with impetuousness. Take the IT training industry in Shenzhen, which the author is familiar with, as an example. Some actually advertise that "participate in training, and you will be 100% employed." There are actually many students who sign up, which is simply contempt for programmers in the world. The social environment is like this, we cannot change it, we can only change ourselves. Peace in the busy city is extremely precious. Many beginners have not started learning C++/JAVA and immediately use VC/JBuilder. If they can use VC/JBuilder to develop a HelloWorld program, they hurriedly declare to the world, "I know how to develop software", and they also write "Proficient" on their resumes. VC/JAVA". As a result, when I went to the software company for an interview, I was either sent away in a few seconds, or was refuted so badly that I felt ashamed. After hitting a wall everywhere, I learned to pick up "C++ Programming Thoughts" and "JAVA Programming Thoughts" and study them carefully. If I had known this, why bother in the first place.

"If you pay attention to simplicity and convenience now, your road will be long in the future." It seems to be an admonition in the Buddhist scriptures.

1.4 Practice more, practice quickly

There is a story about a poor monk and a rich monk in Peng Duanshu's "A Poetry for Learning".

Once upon a time, there were two monks on the border of Sichuan, one was poor and the other was rich. One day, the poor monk said to the rich monk, "I plan to go on a pilgrimage to the South China Sea. What do you think?" The rich monk said, "This place is thousands of miles away from the South China Sea. How can you go there?" The poor monk said, "I just want to go there." A water bowl and a rice bowl are enough. "The rich monk said awkwardly: "I planned to buy a boat to go to the South China Sea a few years ago, but I haven't been able to go there yet, so you better not go." A year later, the rich monk said: While raising money for renting the boat, the poor monk had already returned from his pilgrimage to the South China Sea.

This story can be interpreted as: Once you have considered anything, you must get on the road immediately. Don’t wait until you are fully prepared before doing things. If everything is carefully considered before setting out on the road, others may be the first to get there. Software development is an engineering discipline that focuses on practice. "A gentleman talks but does not use his hands" is simply wrong for software developers. They advocate "hands on", but don't be afraid. Most of them are gentle and have no violent tendencies. Although sometimes he looks unkempt and looks like "Bill Gates". Some senior experts believe that the secret to learning programming is: programming, programming, and reprogramming. The author deeply agrees. Not only do you need to practice more, but you also need to practice quickly. When we are reading a book, we should not wait until you fully understand it before typing the code. Instead, you should type the code while reading the book. The various situations in which the program runs can help you grasp the knowledge points faster and more firmly.

1.5 Multi-reference program code

Program code is one of the most important results of software development, which permeates the mind and soul of programmers. Many people were moved by the poignant love story in "Legend of Sword and Fairy", and the tragic ending has a kind of imperfect beauty. Why does it end in tragedy? It is said that the programmer who wrote "Legend of Sword and Fairy" arranged such an ending because he was heartbroken. He incorporated his own feelings into the game, but many fans of Sword and Fairy sighed.

There are many reference code examples. For JAVA, there is reference [4.3], there is the source code of the API class (src.zip file in the JDK installation directory), and you can also study some open source software or frameworks.

1.6 Strengthen English reading ability

For learning programming, English is not required, but it is not required to be proficient in English. At the very least, things like the JAVA API documentation (reference [4.4]) must be understandable, and you can even guess and be confused; open a "Kingsoft PowerWord" next to it. The more you watch it, the better you will become. Learning English while learning JAVA is a great way to kill two birds with one stone. In addition, many software need to be downloaded from English websites. You must be able to find them. These are the most basic requirements. Being good at English will be of great help to your study. If you speak well, you will have a better chance of entering management, and then you can become a "weekly boss" who exploits programmers.

1.7 Only ask others for advice as a last resort

When the author solved students' problems in the online tutoring system of ChinaITLab online school, I found that most of the problems can be solved by students with a little thinking. Before asking others for advice, you should answer the following questions.

Have you searched for the solution to the problem in google?

Have you checked the JAVAAPI documentation?

Have you searched for related books?

Have you written the code and tested it?

If the answer is "yes" and you haven't found a solution yet, it's not too late to ask others. Know that the ability to think independently is important to you. You must know that a programmer's time is precious.

1.8 Read more good books

There are beautiful faces in books. Bill Gates is a well-read man. Although he has not finished college, Bill Gates has read all the encyclopedias when he was nine years old, so he is proficient in astronomy, history, geography and other subjects. It can be said that Bill Gates is not only the money man in the world today The richest man in the world, and can also be called a rich man of knowledge.

The author often recommends books to students when I teach them. Later, the students can't bear it anymore and start complaining, "Oh my god, when will I finish reading all these books?" "Learning software development feels like A pirate ship". At this time, my answer is usually, "Don't worry, I will take you to see my study sometime. I spend 400 yuan a month on technical books, which is only average among software developers." ", the student fainted on the spot. (Note: This group of students are new to software development)

I will specifically comment on good books in the field of JAVA development in another article by the author. This article can serve as a companion article to this article.

1.9 Use appropriate tools

If a worker wants to do his job well, he must first sharpen his tools. Software development includes a variety of activities, including requirement collection and analysis, building use case models, establishing analysis and design models, programming implementation, debugging programs, automated testing, continuous integration, etc. It can be said that it is difficult to do without the help of tools. Tools can improve development efficiency and make software of higher quality with fewer bugs. A combination of weapons. The level where flying flowers and picking leaves can hurt people is very high. There is no way to win but there is a way. There is no sword in the hand but a sword in the heart. This level is almost unattainable. The author will specifically explain how to choose the right tool in another article (this article can also be used as a companion article to this article).

2. Software development learning route

The two thousand years of Confucianism and the way of Confucius and Mencius, the idea of ​​the mean penetrates into the bone marrow. Neither being aggressive nor conservative is not the golden mean, but finding the correct route for learning software development and law.

From the perspective of career planning for software developers, we can roughly divide it into three stages, software engineer → software designer → architecture designer or project manager. A soldier who doesn't want to be a marshal is not a good soldier, and a programmer who doesn't want to be an architect or project manager is not a good programmer. We should try to move up. Let's first sort out the main technologies you need to learn to develop application software.

A. Basic theoretical knowledge, such as operating systems, compilation principles, data structures and algorithms, computer principles, etc., are not unimportant. If you don't want to become a computer scientist, you can adopt the "learn it when you use it" principle.

B. A programming language is now basically an object-oriented language, such as JAVA/C++/C# and so on. If you do WEB development, you also need to learn HTML/Jav**ript and so on.

C. A methodology or idea is now basically object-oriented thinking (OOA/OOD/design pattern). Derived from this are component-based development CBD/aspect-oriented programming AOP and so on.

D. A relational database, Oracle/SqlServer/DB2/MySQL, etc.

E. An IDE integrated development environment that improves productivity JBuilder/Eclipse/VS.NET, etc.

F. A UML modeling tool for modeling with ROSE/VISIO/Pen.

G. A software process, RUP/XP/CMM, etc., organizes many activities of software development through software process to professionalize and standardize the development process. Of course, there are other software engineering knowledge.

H. Project management, architecture, framework knowledge.

The correct route should be: B→C→E→F→G→H.

A few more points need to be added:

1). What should be added to A and C is that we should gradually understand programming theory and programming ideas in practice. Although new technologies continue to emerge, and the update speed is dizzying, but everything remains the same, and programming theory and programming ideas change very slowly. Once you master programming theory and programming ideas, you will feel like you can see the sun through the clouds. Object-oriented thinking is very critical at present. It is one of the strong technologies. You need to invest more time in it, and the rewards will surprise you.

2). For databases, learning is independent, and the timing is up to you.

3). Programming language serves as the main line of learning software development, while the rest serve as auxiliary lines.

4). Software engineers focus on B, C, E, and D; software designers focus on B, C, E, D, and F; architects focus on C, F, and H.

3. How to learn JAVA?

3.1 JAVA learning route

3.1.1 Basic grammar and JAVA principles

Basic grammar and JAVA principles are the foundation, and the foundation is not solid, just like Building skyscrapers on sand is quite dangerous. The same is true for learning JAVA. You must have a solid foundation so that you can operate with ease in the J2EE and J2ME fields. Taking the SCJP (SUN Certified JAVA Programmer) exam is a good way. One of the reasons is that in order to be worthy of the 1,200 ocean exam fee you pay, you will study harder. The second reason is that the SCJP exam allows you to master the basics. It is very reliable, and it requires you to be as familiar with the basic knowledge of JAVA as JDK; but you must not think that just because you have passed SCJP, you will be great, you will be favored by software companies, and you will be able to get high salaries. This idea is also very dangerous. Obtaining a "real" SCJP can only prove that your foundation is passable, but it is still a long way from actual development.

3.1.2 Comprehension of OO ideas

After mastering the basic syntax and JAVA program operating principles, we can use JAVA language to implement object-oriented ideas. Object-oriented is a methodology; it is a programming idea that is independent of language; it is the basis of component-based development of CBD; it is one of the strong technologies. When you need to switch to another object-oriented language for work in the future, you will feel particularly familiar and friendly, and learning it is as easy as drinking cold water.

The basic process of development using object-oriented thinking is:

●Investigate and collect requirements.

●Establish a use case model.

●Identify analysis classes and static and dynamic relationships between classes from the use case model to establish an analysis model.

●Refine the analysis model to the design model.

● Use specific technology to achieve it.

●Test, deploy, summarize.

3.1.3 Learning of Basic API

When developing software, not all functions need to be implemented, which is what the classic saying goes, "There is no need to reinvent the wheel." We can use ready-made classes, components, and frameworks to build our applications. For example, SUN has written many classes to implement some underlying functions, and for the classes contained in the JAR files we downloaded, we can call methods in the classes to complete Some functionality or inherit it. So what methods are provided in these classes for us to use? What are the number and types of parameters of the method? Does the class constructor require parameters? It is impossible for an engineer from SUN to make an international long distance call or even cross the ocean to tell you how to use the class he wrote. They can only provide documents for us to view. The JAVADOC document (Reference 4.4) is such a document. It can be said to be a document for programmers to communicate with programmers.

Basic API refers to classes that implement some underlying functions and highly versatile APIs, such as string processing/input and output, etc. We call it a class library again. The first way to become familiar with the API is to check the JAVADOC documentation (reference 4.4), and the second way is to use the code prompt function of IDEs such as JBuilder/Eclipse.

3.1.4 Learning of specific API

JAVA is involved in a wide range of fields, and different fields have different APIs. No one is familiar with all APIs. Most people are only familiar with the APIs used in work. If you do interface development, then you need to learn APIs such as Swing/AWT/SWT; if you develop online games, you need to have an in-depth understanding of network APIs/multimedia APIs/2D3D, etc.; if you do WEB development, you need to be familiar with APIs such as Servlet La. In short, you need to choose to learn a specific API based on your work needs or the direction of your interest.

3.1.5 Usage of development tools

When learning basic grammar and basic object-oriented concepts, from the perspective of training language proficiency, the tool we recommend is Editplus/JCreator+ JDK, don’t rush to get started with integrated development environments such as JBuilder/Eclipse at this time, so as not to focus too much on the powerful functions of the IDE and distract from the JAVA technology itself. After this stage you can start to become familiar with the IDE.

A programmer’s daily work includes many activities, including editing, compiling and building, debugging, unit testing, version control, maintaining model and code synchronization, document updates, etc. Almost every activity has specialized tools. , if you use these tools independently, you will be very painful. You need to constantly switch on the taskbar full of tools, which is very inefficient and easy to make mistakes. IDEs such as JBuilder and Eclipse have automatically integrated editors, compilers, debuggers, unit testing tools JUnit, automatic build tools ANT, version control tools CVS, DOC document generation and updates, etc., and even UML modeling tools can be integrated Integrated in, it also provides a wealth of wizards to help generate framework code, making our development easier. It should be said that the development trend of IDE is to integrate almost all tools used in software development.

From the perspective of development efficiency, using IDE is the only way to go, and it is also a milestone in the transition from a student to a professional programmer.

The IDEs used in JAVA development mainly include Eclipse, JBuilder, JDeveloper, NetBeans, etc.; Eclipse and JBuilder have the largest market share. JBuilder has been the dominant player in the JAVA integrated development environment in recent years. It was developed by Borland, a company highly respected by programmers. In the smoke-filled JAVAIDE war, it defeated IBM's Visual Age for JAVA and so on with its rapid version updates and became a leader. A great achievement. Since IBM was no longer profitable with Visual Age for JAVA, it simply contributed it to the open source community and became the predecessor of Eclipse. The reborn Eclipse has won the favor of the majority of programmers (including almost all hardcore programmers) with its open plug-in extension mechanism and free open source, and has great development potential.

3.1.6 Learning Software Engineering

For small projects, you may think that software engineering is not necessary. As projects become more complex, the need for software engineering becomes apparent. See the "Software Development Learning Route" section.

3.2 Learning Points

After establishing the learning route, we also need to summarize the learning points of JAVA. These points have been mentioned more or less in the previous article, but the author feels that these points should be paid special attention to. I just summarized them, don’t blame my mother-in-law.

3.2.1 Check the API documentation diligently

When programmers write certain classes, they feel a sense of accomplishment and want to contribute it to all the suffering colleagues. At this time, you need to use the "javadoc" tool (included in the JDK) to generate standard JAVADOC documents for use by peers. The DOC document of J2SE/J2EE/J2ME is a tool for programmers to communicate with each other. Almost everyone has a copy, except for novices. The official download address of the J2SEDOC document: You can go to Google to search for the CHM version to download. Also view online: .

Treat DOC documents like Chairman Mao’s quotations, read them once when you get up in the morning, and read them again before eating and going to bed.

When you need a certain function, you should first check the corresponding DOC document to see if there is a ready-made implementation. If there is, you don’t need to bother and just use it. If you can’t find it, just use it. Consider implementing it yourself. The usage steps are generally as follows:

●Find a specific package. Packages are generally organized according to functions.

●You need to use a class. If the class naming convention is standardized, we can guess a thing or two from the name of the class.

●Choose the constructor. Most of the ways to use classes are to create objects.

●Choose the method you need.

3.2.2 Search/google->Write code test->View source code->Ask others

How to solve problems when we encounter them?

Don’t rush to ask others at this time. If you ask too simple questions or questions without thinking, others will look down on you. You can first look for books or search on Google, and most of the problems will be basically solved. For questions like "how to use certain classes/methods", DOC documents are the answer. If you have doubts about certain knowledge points, write code and test it, it will leave a deep impression on you. For some problems, you may need to directly look at the source code of the API to verify your ideas. Only ask others for advice as a last resort.

3.2.3 Learn the design ideas of open source software

There are many open source tools, components, and frameworks in the JAVA field, including JUnit, ANT, Tomcat, Struts, spring, Jive forum, PetStore pet store, and so on. These are the treasures left by our predecessors. Are you willing to enter the Treasure Mountain and return empty-handed? Analyze these tools and frameworks and understand the design ideas. Maybe one day you can write an XXX framework or something, which will be a great success. Analyzing open source software is actually a convenient way for you to improve your technology and improve your practical capabilities.

3.2.4 The Importance of Standards

No rules, no rules. The specification here has two meanings. The first level of meaning is technical specifications, which include downloading JSRXXX specifications and reading more specifications. This is the most authoritative, accurate and up-to-date teaching material. The second meaning is programming standards. If you use a large number of unique algorithms, unique naming of variables and methods; and at the same time, do not comment on the program to show how deep your programming skills are. Such code looks like a bible to others. It is not easy to understand, let alone maintain, and it will inevitably be ruthlessly swept into the garbage. JAVA coding specifications can be viewed or downloaded here. They are also available in Chinese. Ah, if you want to ask me where I am, please refer to Section 3.2.2.

3.2.5 Not limited to JAVA

Unfortunately, fortunately, there are still many things to learn. Unfortunately, because there are too many and ever-changing things to learn, I don’t have time to spend with my wife, family or girlfriend, which leads to physical and mental exhaustion, and in severe cases, even depression. Fortunately, it is not easy for others to take your job. They or they need to pay a lot to achieve their wishes.

Don’t learn JAVA in isolation. You need to comprehensively learn data structure, OOP, software engineering, UML, network programming, database technology and other knowledge. It will be more effective to learn in a horizontal and vertical comparative associative way. For example, when learning JAVA collections, look for books on data structures; when learning JDBC, review database technology; the principle of "learn when needed" is still adopted.

Attention, students learning Java! ! !

If you encounter any problems during the learning process or want to obtain learning resources, you are welcome to join the Java learning exchange group: 299541275 Let’s learn Java together!

The above is the detailed content of Experience in learning Java. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn