Name: Haisum Bhatti Registration# 0812155 SQA Assignment

FOG INDEX
The Fog Index is a proven method of analyzing written material to see how easy it is to read and understand. The steps you can use to calculate the Fog Index are outlined below. The numbers in the right column are based on this paragraph. When using these steps to analyze your writing, choose a sample that contains at least one hundred words. The "ideal" Fog Index level is 7 or 8. A level above 12 indicates the writing sample is too hard for most people to read. Following are steps involved in calculating fog index: 1. 2. 3. 4. 5. 6. 7. Example:
1. 2. 3. 4. 5. 6. 7. Count the number of words in the sample Count the number of sentences Count the number of big words (3 or more syllables) Calculate the average sentence length. Divide the number of sentences into the number of words Calculate the percentage of big words. Divide the number of words into the number of big words Add the average sentence length to the % of big words Multiply the result by .4 Fog Index 88 6 6 88/6 = 14 6/88 = 7% 7 + 14 = 21 21 x .4 = 8.4

Count the number of words in the sample Count the number of sentences Count the number of big words (3 or more syllables) Calculate the average sentence length. Divide the number of sentences into the number of words Calculate the percentage of big words. Divide the number of words into the number of big words Add the average sentence length to the % of big words Multiply the result by .4

Cyclomatic Complexity
This non-OO metric, introduced by Thomas McCabe, measures the structural complexity of a method. For easy understanding, take a look at this definition: Cyclomatic Complexity (CC) = number of decision points +1 Decision points are conditional statements such as if/else, while etc. Consider the following example:
public void isValidSearchCriteria(SearchCriteria s){ if(s!=null) { return true; }else{ return false; } }

In the above example, CC=2+1=3 (one if +one else +1). Cyclomatic complexity has enormous impact on the testability and maintainability of code. As the example shows, if you want to test theisValidSearchCriteria() method, you have to write three tests to verify it: one for the method itself and two for the decision points within the method. Clearly, if the CC value increases, and there is an increasing number of decision points within any method, it means more effort to test the method. The following table summarizes the impact of CC values in terms of testing and maintenance of the code: CC Value 1-10 11-20 21-50 >50 Risk Low risk program Moderate risk High risk Most complex and highly unstable method

From the complexity perspective of a program, decision points such as if-else, etc. are not the only factor to consider. Logical operations such as AND, OR, etc. also impact the complexity of the program. Consider the following example:
public void findApplications(String id, String name){ if(id!=null && name!=null) { //do something }else{ //do something } }

Using this example, you will need to perform three. Two for the normal if-else decision points and one for the logical AND operation. Thus, in another version of cyclomatic complexity: CC = no of decision points + no of logical operations +1 Following this version of cyclomatic complexity, the CC for the above sample code will be counted as: CC = 2+1+1 = 4 Note that the number of tests you have to write for a specific method is equal to the CC measure of the method. Thus, a high CC value means more testing effort, which then means that the program itself is more complex to maintain.

References
http://www.essociatesgroup.com/enformation_central/tools/FOG%20INDEX%20References.doc http://javaboutique.internet.com/tutorials/metrics/

Sign up to vote on this title
UsefulNot useful