Several points of attention in Java development

Source: Internet
Author: User
Tags least privilege

Source: Back-end technology

1. Write some configurations that need to be changed in the properties file

For example, the number of threads that need to be used concurrently for execution is not set to be configurable in the properties file. Then your program can run smoothly, both in the dev environment and in the test environment, but once deployed on PROD, it will throw ioexception when it is processed as a multithreaded program for larger datasets, perhaps due to concurrency on the online environment. If the number of threads can be configured in a property file, making it a single-threaded application becomes very easy. We no longer need to deploy and test the application repeatedly in order to solve the problem. This approach also applies to configuration URLs, servers, port numbers, and so on.

It is recommended to use the properties file to hocon these configurations, and the file format can be used by the property, Yaml, and JSON. The following classes implement spring injection support for files in these formats, including placeholder support.

https://github.com/superhj1987/awesome-libs/blob/master/src/main/java/me/rowkey/libs/spring/config/ Awesomepropertyplaceholderconfigurer.java

2. Simulate the online environment as much as possible in the test

A typical scenario in the production process is testing with only 1 to 3 accounts, which should be 1000 to 2000. When performing a performance test, the data used must be real and not cropped. Performance testing that is not close to the real world can lead to unpredictable performance, expansion, and multithreading issues. It is also possible to take a pre-release environment to solve some of the problems.

3. Fault-tolerant handling for all external calls and internal services

Whether it is an RPC call or a call to a third-party service, it is not assumed that availability is 100%. Service call timeouts and retries are not allowed and will adversely affect the stability and performance of the application.

4. Security design on a system to follow the principle of least privilege

Network services are ubiquitous, making it easy for hackers to use it for denial-of-service attacks. Therefore, when designing the system, it is necessary to follow the principle of "least privilege" and adopt the White list method.

5. You need to provide the following documents
    1. Write a unit test document and make it good code coverage.
    2. High-level design diagram: Describes all the components, interactions and structures.
    3. Detailed design: Specific to the code level of the design, as well as some key logic of the process.
    4. System Composition Document: Describes the system's constituent files, configuration files and so on.
    5. Database-level DML and DDL documents, especially SQL query statements, need to be review by DBAs or core developers to get online.

Not only for the traditional development process, even for agile development, these documents are essential, otherwise in the subsequent maintenance, handover will bring great inconvenience.

6. Do the key functions of the system monitoring, error recovery, backup, etc.

For some of the critical functions of the system, it is necessary to monitor and prevent the system from affecting the operation, resulting in the non-estimated loss. In addition, if it is possible to monitor the failure to try to recover, the recovery fails to send an alarm. For some very important data files, you also need to do redundant backup to prevent some sudden failure caused data loss.

7. Design a database design to facilitate the tracking of history, organized columns

For example, Create_time, Update_time can explain the record creation and update time. Create_by, Update_by can explain who created and updated the record.

In addition, deleting a record is sometimes not a real deletion, and you need to design a column that represents the status of this record, such as the ' status ' column that can take ' Active ' or ' Inactive '.

8. Prepare a project rollback plan

When new features go online, if there is a failure and there is no rollback plan, you may be scrambling to make the online service unavailable for some time. There is a good rollback plan that allows you to methodically perform related operations and restore the system to a functioning state within a manageable time.

9. Do a quantitative analysis before the project goes live

For the use of the project memory, database, file, cache, etc., to do a quantitative analysis. Estimate the space occupancy for a certain period of time, a reference for the operation and distribution of the machine. Prevent, because the volume of data growth too fast, resulting in insufficient storage. This is very important, otherwise it is easy to make the online service unavailable.

10. Develop a good system deployment plan.

The Platform for system deployment is a vital part. The description of the deployment platform should not be limited to a single server, two databases, at a minimum, including

    • Specific version of the operating system, JVM, and so on.
    • How much memory is available (including physical memory, JVM heap memory, JVM stack memory, and the JVM's permanent generation of space).
    • CPU (number of cores).
    • Load balancer, the number of nodes required, the type of node, such as the Active-standby type or the active-active type.
    • File system requirements, for example, your application may collect generated logs and save them for a long period before archiving. In this case, you will need to have enough hard disk space.
11. Select the most appropriate tool/technology

In many cases, developers will use a language or a tool in the production system that they want to learn. Usually this is not the best choice. For example, use a NoSQL database for data that is already actually relational . Whether it is a language or a tool, there is a scenario for it. Can not be a novelty, nor the "ego" as the standard.

12. There is an adequate knowledge pool in a number of key technology areas.
    • Design Patterns
    • JVM Tuning
    • Multithreading "Concurrency Issues"
    • Transactional issues, including distributed transactions
    • Performance issues, including GC, COMPUTE, etc.
    • Cache

Several points of attention in Java development

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.