Look at the following code snippet. Can you spot the error? (yes, there's an error).
result.rankingValue = phraseValue( result, queryData ) +
noSpacesPhraseValue( result, queryData ) +
keywordInResultValue( result, queryData ) +
hiddenKeywordInResultValue( result, queryData ) +
keywordPositionValue( result, queryData ) +
isDomainRootValue( result, queryData )
urlStartWithWWWValue( result, queryData ) +
urlLengthValue( result, queryData ) +
pathElementsValue( result, queryData ) +
backLinksValue( result, queryData ) +
domainRankValue( result, queryData );
In the middle, right after the line with isDomainRootValue
it's missing a plus sign. The application won't break, but the rest of the expression won't be concatenated and will be ignored.
A simple way to make this kind of issue more evident is to use the operator first and use tabular align:
result.rankingValue = phraseValue( result, queryData )
+ noSpacesPhraseValue( result, queryData )
+ keywordInResultValue( result, queryData )
+ hiddenKeywordInResultValue( result, queryData )
+ keywordPositionValue( result, queryData )
+ isDomainRootValue( result, queryData )
urlStartWithWWWValue( result, queryData )
+ urlLengthValue( result, queryData )
+ pathElementsValue( result queryData )
+ backLinksValue( result, queryData )
+ domainRankValue( result, queryData );
Now it's obvious where's the problem right?
There's another problem in the above code. Can you spot what it? let's make it obvious:
result.rankingValue = phraseValue ( result , queryData )
+ noSpacesPhraseValue ( result , queryData )
+ keywordInResultValue ( result , queryData )
+ hiddenKeywordInResultValue( result , queryData )
+ keywordPositionValue ( result , queryData )
+ isDomainRootValue ( result , queryData )
urlStartWithWWWValue ( result , queryData )
+ urlLengthValue ( result , queryData )
+ pathElementsValue ( result queryData )
+ backLinksValue ( result , queryData )
+ domainRankValue ( result , queryData );
The argument list of pathElementsValue
is missing a comma.
Here's the code corrected:
result.rankingValue = phraseValue ( result , queryData )
+ noSpacesPhraseValue ( result , queryData )
+ keywordInResultValue ( result , queryData )
+ hiddenKeywordInResultValue( result , queryData )
+ keywordPositionValue ( result , queryData )
+ isDomainRootValue ( result , queryData )
+ urlStartWithWWWValue ( result , queryData )
+ urlLengthValue ( result , queryData )
+ pathElementsValue ( result , queryData )
+ backLinksValue ( result , queryData )
+ domainRankValue ( result , queryData );
Source code is highly regular. We should explore these regularities and make it visually regular as well.
Human eyes are good to identify discontinuities in regularity like lines, not in random patterns. Compare the above code with a worse version of the first snippet of this text:
result.rankingValue = phraseValue( result, queryData ) +
noSpacesPhraseValue( result, queryData ) + keywordInResultValue( result, queryData )
+ hiddenKeywordInResultValue( result, queryData ) +
keywordPositionValue( result, queryData ) + isDomainRootValue( result, queryData )
+ urlStartWithWWWValue( result, queryData ) + urlLengthValue( result, queryData ) +
pathElementsValue( result, queryData ) + backLinksValue( result, queryData ) +
domainRankValue( result, queryData );