Period: 7.13 - 7.20
2019 IEEE Jordan International Joint Conference on Electrical Engineering and Information Technology(JEEIT)
Hussam Hourani, Hiba Wasmi, Thamer Alrawashdeh
Abstract - The Code Complexity and Object Oriented Pragramming (OOP) is an import topic due to the role of OOP playing in most of the software design and architectures nowadays. In OOP there are key design concepts like Encapsulation, Polymorphisms and Inheritance that affect the coding design, structure and style. The challenge is how to minimize the Complexity in OOP and complying with the key conecpts of OOP design. This paper reviews the literature on current solutions for code complexity and proposes a new model for OOP code complexity. The new model has added into OOP complexity metrics the following characteristics: abstraction and class details complexity. The proposed model is based on the following attributes selection criteria: Readability, Understandability, Maintainability, Reusability, Extensibility and Consistency of the programming code.
Keywords - Code complexity, Object Oriented Programming, OOP, OOP Metrics, 2O2C Metrics.
Ⅰ. INTRODUCTION
IEEE는 복잡도를 아래와 같이 정의하였다.
- the degree to which a system's design or code is difficult to understand because of numerous component or relationships among components
- the degree to which a system or component has a design or implementation that is difficult to understand and verify[1]
코드 복잡도 측정은 프로그램 코드의 유지보수성, 확장 가능성, 이해력을 높여주고, 일관성을 가지며 가독성을 올려준다. 이를 통해 개발자들은 코드를 설계하는 과정에서 덜 복잡하게 작성할 수 있다. 결과적으로 복잡도를 낮춤으로써 개발과정에서 예기치못한 결함을 줄일 수 있으며 코드 재사용성을 높혀준다. 또, 테스트가 용이해지고 소프트웨어 품질을 높힐 수 있다. [그래서 목표는 코드의 Simplify!]
McCabe의 순환복잡도와 같이 전통적인 코드 복잡도 메트릭스는 함수나 메소드 내 코드의 path 갯수로 측정하였다. 그 외에 LOC(Line of Code), Halstead의 메트릭스가 있다.
- Encapsulation: "a software development technique that consists of isolating a system function or a set of data and operations on those data within a module and providing precise specifications for the module"[1]
- Inheritance(= generalization): "a semantic notion by which the responsibilities (properties and constraints) of a subclass are considered to include the responsibilities of a superclass, in addition to its own, specifically declared responsibilities"[1]
- Polymorphisms: 같은 메소드나 연산을 다양한 방법으로 구현
Ⅱ. LITERATURE REVIEW
OOP 사례에서 OO메트릭스를 사용하여 얻는 이점은 소프트웨어 품질을 향상시키고 강화시킬 수 있다는 것이다.
A. Chidamber and Kemmerer(CK) metric suite (1991)
- Weighted Method per Class(WMC): 클래스 내의 모든 메소드에 대한 복잡도의 합 또는 클래스 내의 메소드 갯수
- Depth of Inheritance Tree(DIT): 루트 클래스까지의 최대 상속 path
- Number of Children(NOC): 클래스의 직속 서브클래스 갯수
- Coupling between Objects(CBO): 결합되어 있는 클래스의 갯수
- Response for a Class(RFC): 메세지를 받았을때 반응하는 메소드 묶음
- Lack of Cohesion in Methods(LCOM): 클래스 내의 메소드끼리 얼마나 잘 연관되어있는지
CK 메트릭스는 Abstraction measurement를 고려하고 있지않다.
B. The R. C. Martins Metric (1994)
이 메트릭스는 클래스 설계에 영향을 끼치는 OOP 설계 복잡도의 유명한 메트릭스이다.
- Efferent Coupling(Ce): 다른 패키지에 있는 클래스를 접근하는 패키지 내의 전체 클래스 갯수
- Afferent Coupling(Ca): 패키지내에 있는 클래스를 접근하는 해당 패키지 밖에 있는 전체 클래스 갯수
- Instability: 패키지간의 coupling
- Abstractness: 추상 클래스 갯수
- Normalized Distance from Main Sequence(Dn): 추상, 안정성 측정
C. Other OOP metrics
MOOD, MOOD2 metric suite(Abreu, 1995), Lorenz and Kidd metric suite(Lorenz & Kidd, 1994), Design metrics for testing(Binder 1994), product metrics for object-oriented design(Purao&Vaishnavi 2003, Vaishnave et al 2007), Henderson-Sellers metrics(Henderson-Sellers 1996), etc.
Ⅲ. THE PROPOSED OOP METRICS MODEL
A. The proposed Model's Attributes
- Weighted Class Abstraction(WCA): 추상화를 많이할수록 복잡도가 낮아진다[다형성]
- Depth of Inheritance(DIT): 상속의 깊이가 깊어질수록 복잡도가 높아진다
- Number of Children(NOC): [설계관점에서 사용가능]
- Coupling between Objects(CBO): 높아질수록 복잡도가 높아진다[high-level coupling]
- Cohesion in Methods(COM): 높아질수록 복잡도가 낮아진다
- Detailed Class Complexity(DCC):
- Cyclomatic Complexity per Method(CCM): based on program control structure - statement, loop, branch, modulization
- Number of Lines per Method(NLM)
- Number of Variables per Method(NVM): 변수가 많을수록 복잡도가 높아진다
- Number of Parameters per Method(NPM): 파라미터가 많을수록 복잡도가 높아진다
- Number of Attribute per Class(NAC): attribute가 많을수록 복잡도가 높아진다
- Number of Methods per Class(NMC): 메소드가 많을수록 복잡도가 높아진다
- Class Comments Percentage(CCP): 주석이 많을수록 복잡도가 높아진다
B. The 2O2C suggested Measurement and KPIs
Ⅳ. CONCLUSION
"Measuring code complexity will structure how the developers design their code and how to make it less complex. Minimizing the code complexity will reduce the risks of introducing new defects in the development and the production environments and will have a great benefits for applications testability and robustness."
'Software Design > Paper' 카테고리의 다른 글
Software Functional Complexity Measurement with the Task Complexity Approach (1) | 2020.07.14 |
---|