Skip to main content

Unit 9

ePortfolio Activities

Activity 1

Assignment

How relevant is the cyclomatic complexity in object-oriented systems? Which alternative metrics do you consider to be more reflective of the complexity of a piece of code, in comparison to the number of independent paths through a program? Support your response using reference to the related academic literature.

Cyclomatic complexity described by McCabe (1976) shows the number of independent execution paths in a program. While still useful, it does not provide instruments that can measure the complexity of an object-oriented system. Therefore, there have been multiple proposals on how to evaluate such systems and provide actionable metrics for them.

Abreu and Carapuça (1994) propose the Metrics for Object Oriented Design (MOOD) that lay a foundation for object-oriented systems’ analysis which focus on the architectural structure of a piece of software, the composition of its components, interaction, and dependencies between them. Chidamber and Kemerer (1994) describe a similar metrics suite that allows to quantify the properties of classes in an object-oriented setting.

Both suits provide various metrics, not all of which can be useful in different settings. For example, metrics for the depth of inheritance tree can be useful when analyzing an application complexity, but are hardly actionable in a business setting. However, the metrics measuring the proper and effective application of the OOP principles such as coupling factor that measures how interdependent different classes are or lack of cohesion in methods highlight the issues in classes’ design and can be useful when considering a solution’s refactoring.

References

Abreu, F.B. and Carapuça, R. (1994) ‘Object-oriented software engineering: Measuring and controlling the development process’, in Proceedings of the 4th international conference on software quality, pp. 1–8.

Chidamber, S.R. and Kemerer, C.F. (1994) ‘A metrics suite for object oriented design’, IEEE Transactions on Software Engineering, 20(6), pp. 476–493. Available at: https://doi.org/10.1109/32.295895.

Lebedev, S. (2025) OOP_PCOM7E January 2025: Quantifying software reusability: What actually matters? | UoEO. Available at: https://www.my-course.co.uk/mod/forum/discuss.php?d=276737 (Accessed: 7 April 2025).

McCabe, T.J. (1976) ‘A Complexity Measure’, IEEE Transactions on Software Engineering, SE-2(4), pp. 308–320. Available at: https://doi.org/10.1109/TSE.1976.233837.

Activity 4

Assignment

Extend the following program to test accuracy of operations using the assert statement.

# Python String Operations
str1 = 'Hello'
str2 ='World!'

# using +
print('str1 + str2 = ', str1 + str2)

# using *
print('str1 * 3 =', str1 * 3)

Source: Progamiz. (n.d.) Python Strings.

Assert statements are used to verify proper execution of string operations
# Python String Operations
str1 = 'Hello'
str2 = 'World!'

# using +
result_concat = str1 + str2
print('str1 + str2 = ', result_concat)

# Test accuracy of concatenation
assert result_concat == 'HelloWorld!', \
f"Concatenation failed: Expected 'HelloWorld!', got '{result_concat}'"

# using *
result_repeat = str1 * 3
print('str1 * 3 = ', result_repeat)

# Test accuracy of repetition
assert result_repeat == 'HelloHelloHello', \
f"Repetition failed: Expected 'HelloHelloHello', got '{result_repeat}'"