If I went back in time, I would learn Java like this

Looking back, it has been almost 15 years since I entered the Java field. Although I have learned a lot, sharing my experience will probably help you avoid detours.

[getting Started]

Before 2001, I was in the C/C++ camp, with C and object-oriented foundation. Later, I switched to Java and found that Java without pointers is really simple. In addition, Java's class library is so easy to use that it makes people cry.

Later, I read "Thinking in Java" and "Java Core Technology", and I didn't feel too tired.

If I hadn't learned any other language before, or turned into the computer industry halfway through, I wouldn't read the above two books first, but I would choose "Head First Java". This book is very suitable for beginners with zero basic knowledge. Easy and funny, if you don't believe me, look at the first page

But just reading the book is quite boring. You might as well watch it in combination with the video. I think the Java basics video of Chuanzhi Podcast is very good (sigh, there is an advertisement for Chuanzhi), you can find it on the Internet, if you can't find it, come here Get my official account (Java head)

Note: The advantage of the video is that you can see the process of typing the code. The code is alive, which is very cool. If the video is just programming according to PPT, throw it away decisively.

Books also have the benefits of books. What can be written into a book must be formed by the author after systematic thinking and sorting out, so the system is relatively strong.

Books also have other advantages, such as being able to flip through them casually, to find the key points and read them over and over again.

So a mix of classic books + excellent videos should be the best way to get started.

Getting started with Java, I won't go to a training class, it's a waste of money, self-study is enough.

In the process of self-study, if someone with rich practical experience guides me, draws a route map for me, points out the direction of climbing, where there are traps, and where time should not be wasted, my self-study can reduce fumbling and detours.

Unfortunately, I didn't meet one back then, and if I went back in time, I'd find a way to find one to guide me.

[practice]

One of the major features of the software industry is that you can never learn if you don't see it or do it, and you are embarrassed to go out and say hello if you code less than 100,000 lines.

So practice, practice, practice!

During school, I will try my best to find projects to do (see my other article "Enrich your resume from now on", and reply to "Resume" to check), but if you really can't find it, you can lay the foundation first.

When I was in college, I used Yan Weimin's "Data Structure". I also did all the exercises at that time. When I took the senior programmer test, my grades were very good.

Later, I came to know a better algorithm introductory book "Algorithms". If time can go back, I will still implement all the data structures and algorithms mentioned in this book in Java, and try to do all the homework after class. again.

This is a very important training, because I know that if I do it, I will find that as long as I don't design the algorithm, the basic data structure can't stumped me.

SE Java SE】

For the Java collection framework, not only have to learn to use it, but I will also try to implement it, List, ArrayList, Set, HashSet, Map, HashSet, etc. If you don't know how to write it, just look at the JDK source code, there are the most good teacher.

After implementing it once, you can better understand object-oriented design, interface, abstract class, concrete class relationship, how to separate responsibilities, and you will learn template methods in design patterns, Iterator, etc.

It is worth mentioning the Iterator, which is very interesting. I still clearly remember the excitement when I implemented the Iterator in the collection framework that year :-)

When implementing the Java collection framework, you can also learn generics by the way.

In the Java world, everything is an object, and everyone knows about encapsulation, inheritance, and polymorphism, but just understanding these is just an entry, and it is impossible to make a real object-oriented program.

There is a classic book "Agile Software Development, Principles, Patterns, Practice", which explains in detail a salary payment case, which is by far the best example of object-oriented design

I will use Java to implement it again, really experience OOD, understand how to assign the right responsibility to the right class, what is interface-oriented rather than implementation-oriented programming, and what is the priority to use composition instead of inheritance.

For Java threads, the key is to understand the concept, because I know that in my future work (unless I am engaged in system-level programming), the opportunity to write threads/thread pools by myself is very rare, and they are all encapsulated by class libraries and frameworks. So the point is to understand,

If you read the book, of course, it is "Java Concurrent Programming Practice", written by a large group of big cows.

For Java IO, I think the architecture design is very elegant, typical academic, but it is not very practical. To open and read a file, you have to wrap it in the decorator pattern, which is too tiring.

In the actual combat of the project, that is to read a property file and an xml file. I'll focus on understanding the concept and design.

But it would be nice to write a simple xml parser yourself.

As for AWT and Swing, just take a look at it. I won't go into it. Java is a typical server-side language. Very few client-side programs are developed. Think about it, you can use Swing/AWT to create a desktop program. Is it a bit too much to ask the client to install a JRE to run it? As far as I know, that is, some applications of the bank are using Swing and AWT. Some people might say that Applet, it used to be popular, is no longer used.

So I won't waste time with Swing and AWT.

Java Reflection does not seem to be as dazzling as collection frameworks, threads, OO, etc., but it is the foundation of many frameworks (SSH) (reply to "Reflection" to see related articles), learn the basics first, and Java EE will use it later.

If you want to really learn Java well, how can you not understand the Java virtual machine? "In-depth understanding of the Java virtual machine" must be read, the goal of reading is to write a simple Java decompiler.

[Be a literate Java code farmer]

I remember in 2008, my IBM manager said that design patterns are a must-have skill, and we can't have them if we don't understand design patterns.

Therefore, design patterns must be learned. In fact, there are a lot of them used in Java. They are simply living teaching materials for design patterns. Factory methods, singletons, template methods, decorators, and chains of responsibility are all reflected.

Of course, I will take a look at the light "Head First Design" first, which is highly recommended by Eric Gamma, one of the authors of "Design Patterns", which is definitely not to be missed.

A few years later, my IBM manager said again, now that we all know design patterns by default, agile practices are a must-have skill!

Therefore, I have to know JUnit, I have to know about refactoring, TDD, and continuous integration, the most basic agile practices, have to know, otherwise, they will be despised.

As an aspiring Java coder, I have to follow Java coding standards when writing code, such as uppercase class names, lowercase registrations, and lowercase method names...etc.

As a code cleanser, I can't stand dirty code, I will keep polishing my code until it looks like a handicraft.

How can you miss "effective java", the best practice of Java? It is full of the best usage of java programming summed up by the authors of JDK.

However, the translation is really not good, many sentences have to be carefully pondered to know what they mean, so I plan to record a series of videos to explain, so stay tuned.

【Java EE】

After walking so far, I finally came to Java EE. Isn't Java just for writing server-side web applications?

I will write a Web program myself, and I can consider transforming the classic salary payment case mentioned above into a Web version, using the most basic technology Servlet/jsp/jdbc.

Then study struts, write a simple mvc framework by yourself, and use it in your own Web program. This is called eating your own dog food.

Then study Hibenete, write a simple OR mapping framework by yourself, and eat your own dog food again.

Then read the classic book "J2EE development without EJB". Yes, it was written by Rod Johnson, the author of spring. It subverted everyone's understanding of heavyweight EJB and opened a new era.

With the foreshadowing of this book, it is not difficult to write a simplified dependency injection by yourself. After writing it, you can still use it in your own web program, and eat your own dog food for the last time.

You'll know when you're done, all of which rely on Java Reflection.

Going further, you should be looking for a real project to do, or looking for an internship. That is another topic, and we will talk about it later.

【Read the code】

Familiar with 300 Tang poems

Imitation is the best learning! Take a look at how the big cows write the code, subtly, and your martial arts can also be improved.

If I have a good teacher by my side, follow him and watch him program, how fast should I improve.

While learning Java SE and Java EE, I read these source codes:

Java Collection source code in JDK: The old ancestors are absolutely classic

JUnit source code: see how Eric Gamma and Kent beck create systems through patterns (reply to "JUnit" to view)

SpringSide : The Pragmatic-style JavaEE application reference example with Spring Framework as the core is the mainstream technology selection in the JavaEE world, and the summary and demonstration of best practices.

Developed by the Chinese, I strongly recommend it.

In addition, I will still study the famous Jive forum at the beginning of this century. Although it is very old, although the source code is very academic, it is simply the base of design patterns, and they are all examples of living applications.

There is a use of proxy mode to achieve permission control, which I remember freshly.

In addition, if you have spare time and are interested, you can of course read the source code of Struts, Spring, and hibernate, and even participate in the development.

How to learn Java, this is how I feel for so many years, and it's just my family's talk. Welcome to communicate with me.

Learning programming has never been easy. It is impossible to watch videos or read books to learn. It requires a lot of programming and practice. Although programming is extremely hard mental and physical work, the joy of creation contained in it is also unparalleled. Hope everyone can enjoy this process and have fun.

I have a WeChat public account, and I often share some dry goods related to Java technology. If you like my sharing, you can use WeChat to search for "Java Head" or "javatuanzhang" to follow.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325483388&siteId=291194637