Skip to content
Conference

CWC: A Cognitive Weighted Complexity Metric for Object-Oriented Programming

Aug 2026 · Moratuwa Engineering Research Conference · pp. 736-741 · 0 citations · 22 references

Abstract

Software complexity remains a major challenge in software engineering because it directly affects program comprehension, maintainability, reliability, and long-term evolution. Although established metrics such as Cyclomatic Complexity are widely used to measure decision-path complexity, they may assign similar scores to programs that differ substantially in cognitive burden, particularly when object-oriented code includes nested control structures, exception handling, thread-related operations, or dynamic memory access. To address this limitation, this paper proposes the Cognitive Weighted Complexity (CWC) metric, a statement-level complexity measure for object-oriented programs. CWC integrates five complexity-contributing factors: nesting level of control structures, type of control structures, try-catch blocks, threads, and dynamic memory access. The metric assigns weights to these factors and computes a total weighted complexity score that reflects both structural and cognitively relevant aspects of code. A preliminary validation was conducted using eight Java methods selected from open-source projects, with Cyclomatic Complexity used as the baseline metric. The results show that CWC differentiates methods that receive identical Cyclomatic Complexity scores by capturing additional complexity introduced by threading, dynamic memory access, exception handling, and deep nesting. The observed positive correlation between Cyclomatic Complexity and CWC further suggests that the proposed metric remains aligned with established complexity principles while providing additional explanatory detail. These findings indicate that CWC is a promising basis for maintainability assessment, code review support, and future automated complexity analysis tools.

View source

We use cookies to run the site and, with your consent, for analytics and to show ads. See our Cookie Policy.