2016 Summary-Java programmer

Source: Internet
Author: User
Tags connection pooling

One. Technology accumulation

(1) Code specification

1.1.1, normal module distribution: Generally if you want to implement a Web application, you from the background to show the data to the front page, in a larger company, you need to intersect with other projects (you call his interface, he relies on your interface), so down, the whole company has a lot of modules, how to do a good connection. Back to just the module distribution, one of your Web applications should be divided into three modules: Core module, Service module, Web module. Web module is to display the page, the background code mainly on the controller layer, the other logic is basically put in the core, service module is some interface class and parameter Dto and so on, the implementation of the interface class in the core module. In this way, the Web module only needs to rely on the service module, the same other systems rely on your interface is simply dependent on the service module, and then use the remote calling way to consume your interface services.

1.1.2, code hierarchy: For background service projects, generally divided into external interface layer, service layer, DAO layer. DAO layer is the interface layer with the database handover, the service layer calls the interface of DAO or external system, the complex logic is basically put on the service layer, and some methods need to be provided to the other module when it is encapsulated in the external interface layer, only the external interface layer is exposed. This is all about hierarchies, and hierarchies that are unrelated to the hierarchy and that need to be categorized, such as the External System interface method encapsulation we put in a directory, some constants and tool classes and so we placed under the common directory. Of course, there are other considerations, try to make the whole module has a sense of hierarchy, the code will not be too messy, better maintenance.

1.1.3, summed up two points above: maybe a lot of ape friends think above and not like code specifications, in fact, this two is also part of the code specification, the main guide to the structure of clear and good maintenance of the thinking direction to go, think more about it.

1.1.4, for some asynchronous processing, do not directly new thread, you should use the thread pool. Thread pool should be used when the number of threads reasonable set, the general maximum not more than 50, of course, you need to consider your IO and CPU, how to analyze the Internet search it.

1.1.5, container class variables, if the change is relatively large and frequent, as far as possible to define the initial capacity to set the size, reduce the consumption of expansion.

When 1.1.6 and branches Judge If...else, the most commonly-used conditional processing is in front.

1.1.7, object comparison when the constant put in front, develop good habits, reduce the appearance of empty pointers.

1.1.8, reduce the synchronized waiting for processing code, can be placed outside as far as possible on the outside.

1.1.9, down to the database, I think it is here to say better, the general query is relatively slow, it is possible that there is no index or index is useless, to check more.

1.1.10, two large tables of the association query, you can use two access to the database instead, first to find out the data of a table, using related fields and then check B table. Don't just think of a SQL to do the best.

1.1.11, resolutely avoid, check the whole table data or a large amount of data, return to the list loaded into memory, accidentally checked 100w data, and check more frequently, the memory burst. There is this risk of changing the composition page query.

1.1.12, do not select *, take columns on demand.

1.1.13, consider avoiding transactions that have long connections or long transactions, which can affect performance if there are a large number of situations that consume data connections. Some unnecessary logic can be placed outside of the transaction execution.

1.1.14, subtraction processing of fields into SQL, strictly avoid first get processing, and then operation in the set to the database, concurrency is very prone to distortion.

1.1.15, method inside code not too long, note encapsulation, naming semantics, code neat. Often hanging on the mouth, do not rest assured on, as always, to bury himself, as a blogger, the recent example of our leader does not write code, a code review I was afraid, to examine the code of the problem, graduates say this code was written before, the problem will eventually fall on my body, and now feel the code is their children, can only be free to secretly optimize, afraid of the problem is very careful.

(2) about the database connection pool.

Maybe some ape friends are less attention. First of all to look at some parameters, here is only a list of bloggers more concerned about, more can self-check the configuration.

InitialSize: The default value is 0, the number of initial connections that connection pooling creates connections.
Minidle: The default is 0, the minimum number of idle connections in the number of connections.
Maxidle: The default is 8, the maximum number of idle connections in the connection pool.
Maxactive: The default value is 8, the maximum number of active connections that can be dispatched at the same time in the connection pool.
Maxwait: The default value is infinite, the maximum number of milliseconds to wait to establish a new connection (before throwing an exception) when the connection in the connection pool is exhausted.

Validationquery: An SQL statement to verify that the database connection is healthy. This statement must be a query pattern and return at least one piece of data. "Select 1" is generally used.

Minevictableidletimemilis: The default value is 1000 * 60 * 30 (30 minutes) units are also milliseconds, connection pool connections can be idle time.

Timebetweenevictionrunsmilis: The default value is-1, which runs the thread that recycles the idle thread once every few milliseconds.

For Minevictableidletimemilis, Timebetweenevictionrunsmilis these two parameters, Timebetweenevictionrunsmilis must be greater than 1 and less than Minevictableidletimemilis, it is recommended to be Minevictableidletimemilis one-fifth or one-tenth.

(3)

A few suggestions for the front end.

1.7.1, some pictures compression and then use, performance improvement is not small (can use Panda image compression). Although the front-end comparison dishes, but it is estimated that a lot of ape friends and I occasionally need to balance the front-end bar.


On the technical accumulation of this piece, the outline of the previous list is quite many, write to the back feel no energy, some few words seems to say not clear AH.

Second, work experience

(1) Communication and collaboration first:

Work will inevitably involve teamwork, active to communicate people always more reliable. We all know the truth. But we need to put the problem of ideas, concise and clear expression to each other. In addition, always face the problem with a communication mentality, not complain. If you feel that the task assigned by the superior is too difficult, you can try to communicate with him and get him a good suggestion or solution.

(2) careful record and drain:

Often open one or two meeting, test at the same time occasionally to find you to check the environmental problems, one day down actually write generation
The code is not much time. Some key points, it is recommended to record in advance, to facilitate the idea of interruption, while avoiding some of the logic or function points omission.

(3) Clear thinking and efficiency:

Recommended to write code before, it is recommended to clear the idea, the key logic, the requirements of details, so that the code behind the high efficiency, and better quality.

(4) Active and nosy:

Clear their scope of work, there is a boundary in their own mind, some belong to other people's work scope of things, you can put forward the proposal is good, but it is best to put forward in the appropriate scene and timing.

(5) State of mind and work:

Programmers, there will always be a pit, or when it is not satisfactory, try to control their own mentality.

(6) The concept of sustainable development view technology and business:

This is what I want to do. For a sense of responsibility, or to say a good programmer. A lot of the time is not the need to complete the product to be good. Much for its sake, code maintainability and scalability is not high. Some function points can also put forward their own ideas, do not always passively accept the demand for products, business functions, the expansion of good words, can reduce the need for product changes.

Iii. direction of study and career development

(1) The first wide after deep or deep after the broad:

Personal character, more inclined to the practical drive, if the actual use of the scene useful to further study, so that learning to use in order to focus more attention. Like some colleagues, they like to study the same thing very deeply.

(2) Business experience should also focus on:

Technical personnel must be technology first, but you have to work for a certain period of time, in fact, the business experience is very important, recruit senior engineer when the business experience is also very valued, whether have their own unique views. Believe that the truth we all understand, but usually there is no such consciousness, there is no way to do is another aspect. At ordinary times can also learn more about business knowledge.

(3) The same working years why people who have been project managers are more popular:

Because they understand the business more deeply, the problem of code quality falls on his head, the project personnel coordination and scheduling planning, the greater the responsibility, the more the problem of thinking, the more problems encountered in dealing with the more experienced. The ability to control is also relatively strong.

(4) How to enter the learning state, and adhere to:

To focus attention on learning technology, need a quiet environment, need to withstand loneliness, so you need no one to disturb the environment, such as in a collective living environment, a few friends live together, the general majority of memories of where to play, friends playing games, it is also a temptation to you. You can go to the office early or study for some time before going back. Or choose to live alone.

(5) How to seize the time of study:

The most important thing to learn is to have a strong curiosity and thirst for knowledge. So in general some technical sharing or the old staff to discuss the problem, perhaps a lot of conceptual knowledge you do not understand, this time you can learn to understand this knowledge. Or your work encountered problems, as far as possible to find out what the cause of the problem, not some old driver to help solve it. Or if you have problems with other colleagues, you can get to know them.

(6) You are more suited to take a career path:

Just graduated from the ape friends, generally will be more impatient gas manic, the technical curiosity is strong, especially some tall technology, what big data, cloud computing, architecture, and so on, some biased to technical research, some biased in business. Most programmers may choose to be biased in favor of technical research, so they are less likely to be interested in business, and therefore feel that doing it every day is no fun. At this time, calm down to analyze what kind of direction you are. Can you calm down to the technical research is deep, can withstand loneliness.

2016 Summary-Java programmer

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.