C ++: code cleaning

I'm going to restart work on a project that I paused several months ago.

The overall design is not so bad, you don’t need to rewrite it from scratch, but there are many things that I don’t like, this is mainly because I wrote it in a hurry (without comments and magic numbers everywhere ...), and therefore, that by the way I use C ++ tools, I changed (I would say, improved) in the meantime (I tend to use a lot more links, smart pointers, STL, boost, ...).

I think this is the perfect time to clear this code: it will help me get back into it.


I have two questions about cleaning:

  • What needs to be done to improve the code written in a hurry?
    Things like deleting magic numbers, adding comments, dividing too large functions into smaller ones and replacing the original pointers / array with intelligent objects ...

  • Is there any tool that can help me detect such (and other) dirty pieces?

+3
source share
4 answers

CPD, copy-paste detector: http://pmd.sourceforge.net/cpd.html

I use this to find duplicate code, so I can clear it. It helps to follow the DRY principle - do not repeat yourself.

+2
source

. , .

+2

, IDE . VS SKU , Style FxCop. Eclipse Idea.

+1

, , .

, , . 100% - , . , 50-60%, .

, .

0

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


All Articles