I compared the good code (refactored or rewritten code) with the bad code (original code) on a minimap.
--Source is Python 2.7 --Display minimap with PyCharm's CodeGlance plugin --Color theme: Darcula --The minimap is 110 digits wide and the height of one line is 1 pixel and 3 pixels
Which is better code, A or B, and which is worse?
A
B
A is the impression that the letters are packed tightly as a whole. This is because there are few blank lines and the number of characters in one line is large.
B has a neat impression because it contains a moderate amount of blank lines.
A has a lot of blank space on the left side and unevenness is conspicuous. This is because the nesting of for and if is deep, and there are many places where processing is written in a sloppy manner.
B has a shallow nest and the left side is flat overall.
A has many characters on the right side, and lines with characters all the way to the right end stand out. This is because there are many places where calls to functions with many arguments are written on one line without line breaks.
In B, long lines are properly line-breaked, so whitespace is noticeable on the right side.
The color of ■■■ </ font> represents a string literal, which is very common in A. This is because we use dict to store data.
Since B uses classes to store data, it has fewer string literals.
--Good code is beautiful even if you look at the minimap --Bad code is oozing dirty even if you look at the minimap
Recommended Posts