Java geek


Related reading:

JAVA programming ideas (1) Increase extensibility through dependency injection (2) How to program for interface (3) Remove the ugly if, self-registration strategy mode elegant meet the open and close principle (4) JAVA programming ideas (Builder mode) classical paradigm and factory mode how to choose? Java Programming Ideas (5) Event Notification Decoupling Process (6) Event Notification Decoupling Process (7) Scenarios using Composition and Inheritance Java Basics (1) Simple and thorough understanding of inner classes and static inner classes Java basics (2) Memory optimization – Using Java references for caching JAVA foundation (3) ClassLoader implementation hot loading JAVA foundation (4) enumeration (enum) and constant definition, factory class use contrast JAVA foundation (5) functional interface – reuse, The sword of decoupling HikariPool source code (2) Design idea borrowed from JetCache source code (1) beginning JetCache source code (2) Top view people in the workplace (1) IT big factory survival rules


1. Should we learn Spring

1. If you’re on the Java technology stack. 2. If you are going to develop a Web application, you are selecting it.

Spring is an awesome, great open source framework that is well worth learning!

2. Why do you want to learn Spring

Spring’s official website

Spring makes programming Java quicker, easier, and safer for everybody. Spring’s focus on speed, simplicity, and productivity has made it the world’s most popular Java framework.

The advantages of Spring

– Strong and sound basic capabilities to provide one-stop technical solutions

Such as exception handling, internationalization, resource management, database access, MVC framework, integration testing framework, multi-language support, all kinds of network communication support WebFlux, WebClient, WebSocket.

– Perfect ecology and community, easy for developers to learn and get started quickly.

The official website information is detailed, combined with so many years of development, a variety of web articles, books, many training courses.

– Developing applications is fast, simple and efficient

For example, to build a Restful interface:

@SpringBootApplication
@RestController
public class StartUpApplication {
    public static void main(String[] args) {
        new SpringApplicationBuilder(StartUpApplication.class).run(args);
    }

    @GetMapping("/addNewBook")   / / Resuful interface
    public String addNewBook(@RequestBody Book book) {
        // Todo adds books to database...
        returnbook.toString(); }}Copy the code

This code starts a Web application that listens on port 8080 and provides a Restful interface.

For example, the Java singleton pattern is implemented as follows:

Public final class SingletonDemo {// static instance variable; Private static volatile SingletonDemo SingletonDemo = null; Private SingletonDemo() {} private SingletonDemo() {} public static SingletonDemo getInstance() {} Synchronized (singletondemo.class) {if (singletonDemo == null) {// Synchronized (singletondemo.class) { If (SingletonDemo == null) {SingletonDemo = new SingletonDemo(); } } } return singletonDemo; }}Copy the code

By default, Spring is a singleton. You just need to:

Public class UseSingletonDemo {} public class UseSingletonDemo {@autowired // Inject SingletonDemo with this annotation singletonDemo; }Copy the code

Like the two examples above, Spring encapsulates common capabilities and exposes only the changes to the developer. This is also an embodiment of Demeter’s rule (least know rule) that developers should not worry about implementation, but only how to use it.

– Integrate various mainstream open source frameworks in the industry to form end-to-end solutions

Spring integrates task scheduling, database access, caching, batch processing, messaging, security…….

Spring can integrate everything that enterprise applications can use.

– Keep pace with The Times and follow new technology

Spring will introduce new technologies and excellent software in the industry, which is equivalent to helping you to do a technology selection. You don’t have to spend energy on research, but you only need to know how to use it.

For example, database connection pool HikariPool, log LogBack, unit testing framework, Web Reactive technology and so on, all of which can be learned in the process of learning Spring.

Spring serves as a learning portal that expands to a variety of developing technologies and open source frameworks.

– Strong scalability

It is embodied in: 1, its own core ideas, interface oriented programming; 2, Bean lifecycle management; 3, inversion of control and dependency injection mechanism; 4, AOP mechanism; 5, easy to integrate with third-party open source software

3. How to learn

Not just for learning Spring, but for learning any open source framework.

3.1 Learning Resources

1, website, more comprehensive, can speak principle, for many English reading speed is slow, affect the learning progress 2, books/pamphlets, Chinese, learn fast, since the update quickly, become obsolete, find time recently published by word of mouth good to double 3, training video, not quick read, can double speed playback, learning up slowly, Video effect to achieve the best is to be able to interact, explain the time to answer questions in real time 4, web articles, uneven, a running account, eight-part essay, need to screen

It is suggested that the main learning method is the official website + books + web articles

The official website can let you know what specific knowledge points, full coverage, for most knowledge points to browse, do not need to pay too much attention to details, the actual use of time to spend effort to learn.

Books are more systematic, there are many Chinese versions, you can quickly browse knowledge points, learn faster, at the same time, combined with the official website to check deficiencies.

Web articles are used to find knowledge points and details not explained in books, as well as demo examples.

3.2 Learning Focus

The emphasis is different for different groups.

1, beginners above hand and landing application first, learn how to use, such as how to access the database, how to use MVC, how to handle exceptions, internationalization….

Spring programming ideas, common features, new technical features such as Web sockets, Web Reactive, and application scenarios, etc., can be expanded to explain the advantages and disadvantages of spring programming ideas, common features, new technical features such as Web Sockets, Web Reactive, and application scenarios.

Must have the practical operation experience, so to master the firm, such as their own starter, according to the SPI principle of their own implementation, dynamic proxy, AOP and so on.

3. At this level, experts have their own learning methods and theories.

1) I have a good understanding of Spring features, core ideas and mechanisms, and am proficient in using them. 3) Decoupling ability, expansion ability, separation of concerns ability, product and customization ability. 4) Not limited to Spring, capable of providing overall solutions and technology selection

3.3 Learning Methods

1. Necessity -> breadth -> depth

Start with necessity. If it’s a project, choose what you can use in the project. If it’s an interview, choose what you’ll be asking for in the interview.

Breadth allows you to know what features a product has and what scenarios it applies to. When you really encounter specific scenarios, you know that there are solutions, and you can find and quickly provide solutions. From the perspective of breadth, many features do not require a lot of investment.

Depth is to have a deep understanding and solid learning of key areas, such as Sprign’s core programming ideas, key features, security, bean lifecycle, etc. Knowledge that requires depth is either very important, such as security, performance, or useful for extension, decoupling, etc.

2. Scope of study

There are so many Spring projects that it is not possible or necessary to learn them all. Unless you are a Spring professional and want to become an expert on Spring, such as a spring project participant, or a professional Spring instructor, it is not necessary because most of the features you will not be able to use in real projects. (In fact, the lecturer has a choice, not commonly used features will not have many audience, there is no application, can not get positive feedback)

3. Learning attitude

Not impatient, don’t expect everything immediately, especially the website information, are in English, many students look slowly, no sense of achievement and can combine the website article at this moment, the other for temporary work in less than, and non-core, also need not worry really hold, scanning again and can, also don’t have to remember, remember how much how much, Go back and watch it a few times, you will get familiar with it. Each time you watch it, you will get more understanding. (At most 4 times, you will get almost all the points.)

4. Personal positioning

Position yourself a little higher than the organization position you to learn, for example, as a general developer, you should position yourself as a senior developer, take the initiative to learn and solve the problems to be solved by senior developers, or even the problems to be solved by architects, so as to quickly improve your personal ability.

5, myth

1) big and complete, determined to do ox X, god no matter who, do not need to be big and complete, knowledge too much, not all necessary to master, otherwise the time is not enough, and a long time can not end, but hit the enthusiasm.

Do not set a flag, have to learn, feel the plenary session only cattle X, a framework, can master 30%, 40% of the essence is very good, the other only need to understand, met the learning.

2) In detail to practice, organize the demo set to grasp the key points, some small functions can be practiced at the beginning of learning, such as Hello World, printing banner information, after the actual business is not important to look at things, do not need to spend time to practice, and when really used to spend time, simple things, it is easy to copy, There’s no need to waste time.

end.


<– Read the mark, left like!