How do you revise your code?

I find that I am revising the areas of my project and refining them again. This usually happens when I start something from scratch, and as I understand it, my code and methods get better, so I go back to what I did and make it stronger. Is this normal or am I just inexperienced? How often do you review your code? do good programmers once and do not need to change something?

+3
source share
4 answers

I agree with the other answers, but it also depends on why you are writing the code. If this is a specific project for the deadline, you may not have much chance. If it is likely to be reused by others, make sure that refactoring does not violate anything that they use. If this is a long-term project, especially a communal one, then he is almost certain that he will need extensive refactoring.

I wrote the community library for about 13 years and went through 5 and a half revisions (the one I'm going through). In many cases, this is due to the fact that the technology has improved, and what I have done for myself, now I can do with standard libraries. And over the years I have learned many better strategies.

In general, good refactoring often means dumping old code.

UPDATE (, , ). , , , , , . , , , . , () , (b), . , , . , , , API, . , ,

Date date = getLastUpdate();

( ), java.util.Date . Joda DateTime, . , , . API

DateTime date = getLastUpdate();

,

DateTime date = getLastDateTimeUpdate();

@Deprecated

, ( API- )

+6

, , , . , , - .

, , , .

+3

... , , ( ).

, , , (, , ).

? - ( )

? - , ,

- ? - , .

+1
source

I would say that it is great and would consider it a good practice. Refactoring is crucial for a good code base if your tests are good.

In the TDD loop:

  • Red
  • Green
  • Refactor
+1
source

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


All Articles