Advice from a Java Architect: 12 Ways to Learn Java
Beginners learning Java and mastering some precautions can help programmers to get familiar with learning methods faster, avoid detours in the learning process, learn the most core technologies, and get an ideal salary. In this article, Qianfeng Guangzhou Java teacher has sorted out some points to pay attention to when learning Java, and summarized some points that need attention in Java development, testing, deployment, and engineering. I believe it will be helpful to everyone.
1. Simulate the online environment as much as possible during the test
A typical scenario in production is to use only 1 to 3 accounts for testing when there should be 1000 to 2000 accounts.
When doing performance testing, the data used must be real and uncropped. Performance tests that are not close to the real environment may bring unpredictable performance, scaling and multi-threading problems.
2. Write some configuration that needs to be changed in the properties file
For example, the number of threads used when some require concurrent execution is not set to be configurable in the properties file. Then your program can run smoothly no matter in the DEV environment or the TEST environment, but once deployed on PROD, when it is used as a multi-threaded program to process a larger data set, an IOException will be thrown, the reason Maybe it's caused by the concurrency of the online environment, maybe it's something else.
If the number of threads can be configured in the properties file, then making it a single-threaded application becomes very easy. We no longer need to deploy and test applications repeatedly to solve problems. This method also works for configuring URLs, server and port numbers, etc.
It is recommended to use property files to externalize these configurations. The file formats can use properties, yaml, hocon, or json.
3. The security design of the previous system should follow the principle of least privilege
Web services are available everywhere, making it easy for hackers to use them for denial of service attacks.
Therefore, when designing the system, it is necessary to follow the principle of "least privilege" and adopt methods such as whitelisting.
4. Fault tolerance for all external calls and internal services
Whether it is an RPC call or a call to a third-party service, it cannot be taken for granted that the availability is 100%.
Not allowing service call timeouts and retries will adversely affect application stability and performance.
5. Do a good job in monitoring, error recovery, backup, etc. of key system functions
For some vital functional modules of the system, it is necessary to do a good job of monitoring them to prevent them from affecting the operation of the system and causing incalculable losses.
In addition, if possible, try to recover after monitoring the failure, and send an alarm if the recovery fails. For some very important data files, redundant backups are also required to prevent data loss due to some sudden failures.
6. The following documents are required
Document unit tests and have good code coverage.
High-level design diagram: describes all components, interactions and structures.
Detailed design drawings: Design specific to the code level
System map (similar to site map): Describes all the constituent files, configuration files, etc. of the system.
7. Develop a project rollback plan
When a new feature goes live, if there is a failure and there is no rollback plan, it can be frustrating. Having a good review and planning will allow you to methodically execute the relevant actions to restore the system to a working state.
8. When designing the database, design some columns that are easy to track history and organize
For example, created_time and update_time can indicate the creation and update time of the record. ;created_by, updated_by can indicate who created and updated the record.
In addition, delete records are sometimes not really deleted. In this case, you need to design a column that represents the status of this record, such as the 'deleted' column that can take 'Y' or 'N' or the 'status' column that can take 'Active' or 'Inactive' 'List.
9. Develop a system deployment plan
The platform on which the system is deployed is a crucial part. The description of the platform cannot be limited to the level of one server and two databases, but at least includes:
The specific version of the OS, JVM, etc.
How much memory (including physical memory, JVM heap memory, JVM stack memory and JVM permanent generation space).
CPU (number of cores).
Load balancer, the number of nodes required, and the node type, such as Active-Standby or Active-Active.
File system requirements, for example, your application may collect generated logs and keep them for long periods of time before archiving them. In this case, you need to have enough hard disk space.
10. Quantitative analysis should be done before the project is launched
For the memory, database, file, cache, etc. used in the project, quantitative analysis should be done. Estimate the space occupation for a period of time in the future, and use it as a reference when allocating machines for operation and maintenance. To prevent, due to the rapid growth of data volume, resulting in insufficient storage.
11. Have sufficient knowledge in some key technical fields.
Design Patterns
JVM tuning
Multithreading "concurrency issues"
Transactional issues, including distributed transactions
Performance issues, including GC, computation, etc.
cache
12. Choose the most appropriate tool/technique
In many cases, developers use a language or a tool they want to learn in a production system. Usually this is not the best option. For example, use a NoSQL database for data that is already actually relational. Whether it is a language or a tool, it has its applicable scenarios. Similar to "PHP" is the best language, it can only mean huh.
The above are the 12 points of attention for learning Java organized by Qianfeng Guangzhou Java teacher, hoping to make everyone learn Java faster.