Tips for programmers to develop large applications _ PHP Tutorial

Source: Internet
Author: User
Skills for programmers to develop large applications. Assume that you are a Java developer and are developing and maintaining applications that contain 2000 classes and use many frameworks. How do you understand the code? In a typical Java enterprise project team, if you are a Java developer, you are developing and maintaining applications that contain 2000 classes and use many frameworks. How do you understand the code? In a typical Java enterprise project team, most of the senior engineers who can help you seem very busy and have very few documents. You need to deliver the results as soon as possible and prove your abilities to the project team. How do you deal with this situation? This article provides some suggestions for Java developers who start to develop new projects.

1. do not try to understand the entire project

After careful consideration, why do you want to understand the project code first? In most cases, someone asks you to fix a bug or enhance the existing functions of the system. The first thing you need to do is not to understand the architecture of the entire project. When maintaining a project, doing so (understanding the entire project architecture) may put a lot of pressure on you.

Even Java developers with 10 years of programming experience cannot understand the core working mechanism of the project, although they may have been working in this project for more than a year (assuming they are not the original developers ). For example, there is still a lack of accurate understanding of the authentication mechanism or transaction management mechanism.

How did they do it? They are very familiar with what they are responsible for and can deliver value to the group. The value of delivery every day is far more important than knowing something you are not sure about in the future.

2. focus on delivering value as soon as possible

So I want to dispel your enthusiasm for understanding the project architecture? No. I just want you to deliver value as soon as possible. once you start a project and build a development environment, you should not spend a week or two to deliver the content, regardless of its size. If you are an experienced programmer but haven't delivered anything for two weeks, how can your manager know whether you are working or reading news ?.

Therefore, delivery can simplify things. Do not think that you must understand the entire project before doing valuable delivery. This is totally wrong. Adding a piece of Javascript verification code is very valuable to the business, and the manager can trust you more through your delivery. This will prove your contribution and employee value to the superior.

Day after day, you can gradually understand the project architecture after fixing bugs and enhancing features. Do not underestimate the time required to understand all aspects of the system. It takes 3 to 4 days to understand the authentication mechanism and 2 to 3 days to understand transaction management. These are based on the experiences of similar projects, but it takes time to fully understand them. To squeeze out time in daily work, do not ask the manager for specific time to do this.

Check whether the project has some unit test cases that are effectively maintained. Effective unit test cases are a good way to understand the code of large projects. Unit testing helps you understand code snippets, including an external interface of a unit (how a unit is called and returned content) and its internal implementation (debugging unit testing is much easier than debugging the entire use case ).

If you can understand some content well, you can take some notes, or draw some class diagrams, sequence diagrams, data model diagrams, etc., so that you or other developers can maintain them in the future.

3. skills required to maintain large-scale projects

If you can do your current job, you must already have good Java technology. Let's talk about other skills that enable you to perform well in your new project. Most of the time, your task in the project is to fix bugs and enhance features.

There are two important skills that can help you maintain large project code.

3. 1. quickly discover required classes

In any maintenance activity, whether it is bug fixing or enhancement, the first thing is to identify the class called in the current repair or enhancement case. When you locate the class/method that needs to be repaired or enhanced, it is half done.

Able to analyze the impact of changes

After you complete the necessary modifications or enhancements, make sure that your modifications do not break other parts of the code. You need to use your Java technology and understanding of other frameworks to find out the potential impact of changes. The following two simple examples describe the situation mentioned at the end:

  • When the equals () method of Class A is changed, the contains () method that stores the List of instance A is called. If the Java knowledge is insufficient, it is difficult to consider this impact.
  • In a web project, we assume that the "user id" is stored in the session. New programmers may add some information in "user id" to fix bugs, but they do not know that it will affect the use cases associated with "user id.

Therefore, you must gain an in-depth understanding of the Java language and the framework you use in your application, so that you can analyze the impact of a change.

When you improve the above two skills, although you are not very familiar with the project, most maintenance tasks will become much simpler. If you want to fix a bug, you will locate and fix it, and ensure that the change will not damage other parts of the project. If you want to enhance or add features, you basically only need to imitate existing features and use similar designs.

Why is the design of "view account summary" and "View transaction history" significantly different in an online banking project? If you understand the design of "view account summary", you can simulate the function of "view transaction history.

For bug fixes and enhancements, you do not have to fully understand the working content of all 2000 classes and how code-driven systems run. As long as you have the above skills, you can quickly locate the code to be modified, use good Java and framework skills to fix it, ensure that the change will not damage other parts of the project, and then deliver, although you may only know the design of a small part of the project.

4. use tools to find the required change content and the impact of the change

To continue with the theme of our delivery as soon as possible, you should look for tools to help you implement delivery as soon as possible, with little understanding of the project.

4. 1. tools for rapid discovery of required changes

To fix bugs or enhance the system, you must first find the classes and methods that need to be modified to call this case. There are basically two ways to understand how the use case works, static code analysis and runtime analysis.

Source Code Analysis statistics scan all code and show the relationships between classes. There are many tools on the market. For example, Architexa, AgileJ, UModel, and Poseidon.

The disadvantage of all static code analysis tools is that they cannot accurately display the runtime calls of classes or methods in use cases. Therefore, Java has added some new features, such as the callback mechanism (callback patterns ). For example, the static analysis tool cannot infer which Servlet will be called when the submit button of the current page is clicked.

The runtime analysis tool displays the status of classes and methods during use cases. Such tools include MaintainJ, Diver, jSonde, and Java Call Tracer. These tools can capture the stack status at run time and generate sequence and class diagrams for the use case.

The sequence diagram shows all the calling methods of this use case at runtime. If you are fixing a bug, it is probably one of these called methods.

If you are enhancing existing functions, such as adding verification and modifying DAO, you can use the sequence diagram to understand the call process and then modify it.

If you are adding new features, you can find some similar features, use the sequence diagram to understand the call process, and then develop new features.

You must carefully select the runtime analysis tool. Too much information is a major problem with such tools. You can select some tools to provide simple information, filter out invalid information, and view various views conveniently.

4. 2 tools for rapid discovery of required changes

If the unit test is effective, you can run the unit test to find whether the change has damaged other test cases. There are still few unit tests that effectively maintain and cover large enterprise applications. The following are some tools for this situation.

Here, there are two technologies available: static code analysis and runtime analysis. Many static code analysis tools are available in the market. Such as Lattix, Structure101, Coverity, nWire, and IntelliJ's DSM.

For changed classes, the above tools can identify the set of classes dependent on the class. Developers need to "guess" the use cases that may have an impact based on the information, because these tools cannot demonstrate the call relationship between Runtime classes.

There are not many tools available for impact analysis during runtime on the market, and only MaintainJ may be available. MaintainJ first captures all classes and methods called in the use case. When the above information of all use cases is captured, it is easy to find the impact of class changes on use cases. The precondition for MaintainJ to work effectively is that all use cases of the project should be run first, so as to obtain the dependency between runtime.

In short, you can still get limited help from tools to quickly and accurately analyze the impact of changes. First, conduct some impact analysis as needed, and then judge the impact of the change based on the review by yourself or other senior members of the group. You may need to use the above tools to repeat your judgment.

5. two suggestions for the above content

Do not reduce code quality

For fast delivery, you can not fully understand the architecture, but you must not reduce the quality of the code. Below are some code quality problems that you may only consider fast delivery.

Because code modification involves many dependencies, it is relatively less risky to add code. For example, five use cases call a method. To improve a use case, you need to modify the implementation of this method. The simplest way is to copy this method, rename it, and then call the new method in the improved use case. Never do this. Code redundancy is absolutely harmful. It is a good way to wrap or rewrite the method, or even modify it directly, and then test all the cases again. it is usually a good way to stop and think about it and then implement it with your own hands.

Another example is to change the "private" method to "public" so that other classes can also be called. Do not expose unnecessary parts. If reconstruction is required for better design, we should proceed.

Most applications have fixed structures and patterns for implementation. When fixing or enhancing programs, make sure they do not deviate from this pattern. If you are not sure about the protocol, ask other senior developers to review your changes. If you have to do something against the conventions, try to place it in a small class (private functions in a 200-line code class should not affect the overall design of the application)

Do not stop understanding the Project Architecture

According to the method listed in the article, if you can deliver a project with less understanding of the project and continue to do so, you may stop having a deep understanding of the project architecture. This will not help your career in the long run. When your experience increases, you will undertake relatively large module tasks. Such as building a complete new feature, or modifying some basic designs of the project and other major improvements. When you can make these improvements, you should have a good understanding of the overall architecture of the project. The methods listed in this article only allow you to improve yourself in the shortest time, rather than preventing you from fully understanding the entire project.

6. Conclusion

The focus of the entire article is to understand the project and then deliver it quickly. You can do this without degrading the code quality.

If you want to fix the bug, quickly locate and fix it. You can use the runtime analysis tool when necessary. If you want to add features, you can look for similar features, understand the process (use tools when necessary), and write.

Maybe it sounds simple, but is it practical? Of course. The premise is that you have good Java technology and a good understanding of the framework before you can modify the code and analyze the impact of the change. Analyzing the impact of changes requires more skills than implementing changes. You may need assistance from senior developers to analyze the impact of changes.

About 50% of IT budget is available for simple bug fixes and feature enhancements. The suggestions in this article should be helpful for saving money in maintenance activities.

Articles you may be interested in
  • A classic dialogue between programmers and testers. These are shared by foreign programmers, who say they are used globally?
  • SEO issues that programmers should pay attention to when developing websites
  • Why are there always errors between the programmer's estimated time and the actual project completion time?
  • Eight typical Linux operating system applications
  • Php programmer interview questions-common basic questions and answers (1)
  • Js address bar special effects (display the size of all images with links on the page and view the height of the current browser)
  • Transformation of PHP programmers: now I resign and are selling fruit
  • Principles of exchanging friend links with a php programmer's note website

Bytes. How do you understand the code? In a typical Java enterprise project team...

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.