Refactoring is the process of improving the source by removing redundant code or rewriting it into versatile and efficient coding.
** if / else order ** It is recommended to write the formula of "survey target" whose value changes on the left side and the formula of "comparison target" whose value does not change on the right side.
sample
if value >= 5
#Processing content
end
** for if / else **
# bad
if a && b == 0
if c
#processing
end
end
# good
if c
if a && b == 0
#processing
end
end
Nesting is a nested structure There are cases where the if statement is embedded in the if statement to create a nested structure, but the deeper the nesting, the harder it is to read the code, so it is important to try to make it as shallow as possible.
Recommended Posts