question archive Question 5 (15 marks) This question is about measuring the complexity of code

Question 5 (15 marks) This question is about measuring the complexity of code

Subject:Computer SciencePrice: Bought3

Question 5 (15 marks) This question is about measuring the complexity of code. You are asked to come up with two code samples of your own. and then compare them using two simple metrics for code complexity: o lines-of-code (LOC} - cyclomatic-complexity. Although relatively simple, these metrics have stood the test of time, and are widely used. because they are easily understood and applied. Your two code samples should each be equivalent to a Java method of moderate complexity. involving some control sthctures such as conditions and loops, and should not be too similar to one another. For example, you might look for one sample that had several control structures, but was relativer short, and another with more lines of code, but simpler control sthctures. Your code samples do not necessarily have to be in Java. The two metrics we ask you to use are not language-speci?c. and following the details of the calculation is quite easy, even in a programming language with which one is unfamiliar. Each sample should, however, represent a well-de?ned unit of code, such as a complete method or a function. Your samples can come from your work or your study, from your reading, or from an intemet search. If necessary, you could invent your own examples. although it will obviously be more interesting ifyou are measuring the complexity of existing examples. Note that this question is not concerned with the quality of the code examples you use. The only thing that is important is to choose examples that allow you to show that you understand how to use the two metrics, and how to use the results to draw simple conclusions. Unless you have written the examples yourself. you should provide a reference for them. The standard for referencing computer software is given in the DlGlTAL & lN'lERNE'l: Computerprograms page of Cite them right. If the program is not available via a public URL. instead of 'Available at.. .' and the URL. you should write 'No public URL available'. but still give the date on which you accessed the code. a. Choose your two code samples and copy them into your solution document, labelling them Sample Aand Sample B. brie?y indicating their source(s). If from an external source, i.e. from outside Open University modules, you should give a full reference. [4 marks] b. For each of Sample A and Sample B, calculate the value of: The LOC metric The cyclomatic—complexity metric. Calculation of LOC is self-explanatory, but for the cyclomatic-complexity. you should show enough working for your tutor to understand how you arrived at the answer. [6 marks] c. Brie?y comment on your results from Part (b) in a similar way to the answer given for SAC} 15 of Unit 11. [3 marks] d. Do your ?ndings suggest that either of your samples would bene?t from restructuring into smaller units? Briefly explain your answer. [2 marks]

pur-new-sol

Purchase A New Answer

Custom new solution created by our subject matter experts

GET A QUOTE

Related Questions