How to prepare for viewing the code

As I prepare to review the code, I begin to learn as much as possible about the classes that I changed. If I just added an extra parameter to the method / class, I will try to explain why I added this parameter.

During the code review demo, I constantly switch between files trying to explain my code additions / deletions and using the file history to explain how it changed. I think this is a bad approach, like other developers that I demonstrate code that seems to get lost in the code as I jump between methods / class trying to explain what I changed.

Is there a better methodology for code analysis? Using charts?

Or I just need to work on how I explain my changes.

+6
source share
4 answers

UML diagrams are a good way to present changes. Another way I found useful is to use an IDE, you can collapse the methods and parts of the code. I have only those parts that I want to present open to view. This makes the job easier.

+1
source

What you did is absolutely not necessary, more than inadequate comments can add noise to the code stream. If the reviewer wants to see what has been done, he will use the VCS history to compare with the original version. But your requirement is to create clean and simple code that works correctly. You must follow the Java naming conventions in order to use consistent names for your variables and objects, the comments should be about what the code is doing, not what you did in the code, format the code, so it correctly deviates from the lines. Writing Javadoc comments on public methods is mandatory; comments on private and protected methods are optional. The quality of comments on valuable information in it multiplies the importance of the code by at least ten, remember this. It is better if you use some checks or error tracking tools to report all possible errors even in compiled and verified working code. These tools are capable of finding hidden errors that you do not see in the code with the naked eye.

0
source

The code representation must be performed before the changes are transferred to version control, otherwise it will be too late, and then, if something is not right / not optimal, you will have to cancel the changes and perform another command action that could have been avoided earlier .

First you need to find a suitable regter reviewer. There are two aspects to consider when choosing your reviewer.

  • He knows about the business logic for which you changed the code, so he can also focus on it, in addition to the technical part (resource management / scalability / performance / style and style of design in your company / formation).
  • He has no idea about this / or the changes are purely technical, and he can focus only on this part, so in the end he can say: "I don’t know what the code does, but it looks normal to me."

Secondly, it is not realistic if you change the business logic, and everyone should be able to perform the technical part.

Then create a set of changes in which you can easily see the changes made to each file (using diff), an explanation of why you changed each part (change / reorganization / optimization / method signature / field, method or class added or deleted, etc. .d ..)

A good strategy to go through all the changes is to start where the actual processing begins and go to the end.

If you have created some new module, it is always a good idea to have diagrams (class diagram, activity, sequence, etc.).

0
source

I prefer git or svn commit history. It is easy to analyze what exactly and in what order someone did.

-1
source

Source: https://habr.com/ru/post/957592/


All Articles