SlideShare a Scribd company logo
Design and Evolution Group
http://aside.dcc.ufba.br
Software Engineering Lab
http://les.dcc.ufba.br
By Ticino Turismo Byline: swiss-image.ch
Federal University
of Bahia, Brazil
2
An Empirical Study on How Developers Reason about Module Cohesion
It has been recognized as an important quality
attribute of software design.
[W. Stevens, Myers & Constantine, 1974], [Bieman & Kang, 1995], [Fenton & Pfleger,
1998], [R. Martin, 2003] …
The degree to which a module is
focused on a single concern of the
software
4
Strong related to modularity.
Highly cohesive modules are claimed to be:
easier to understand
easier to maintain
less likely to undergo changes and faults
5
Structural cohesion measurement
Conceptual cohesion measurement
6
7
8
9
Methods accessing
the same attributes
10
Methods accessing
the same attributes
For structural
cohesion
metrics, it is
highly cohesive
11
How many
concerns does
this class
address?
12
For conceptual
cohesion
metrics, it is
not highly
cohesive
How many
concerns does
this class
address?
It is still unaddressed to what extent
structural and conceptual cohesion
measurements reflect developer’s
perception of module cohesion.
13
RQ1: How do developers perceive module cohesion?
How do they reason about it?
RQ2: To what extent do structural cohesion and
conceptual cohesion measurements relate with how
developers rate cohesion of modules?
14
RQ1: How do developers perceive module cohesion?
How do they reason about it?
RQ2: To what extent do structural cohesion and
conceptual cohesion measurements relate with how
developers rate cohesion of modules?
15
Goal: Collect developers’ opinion about
module cohesion.
16
Goal: Collect developers’ opinion about
module cohesion.
228 invitations sent to software developers.
80 full responses (35%).
From different countries: Canada, Germany, Chile, Japan, USA,
Iran, Poland, Spain, Portugal and Brazil.
17
18
1.1 “Are you familiar with the concept
of cohesion in the context of software
development?”
1.2 “How would you explain
to someone else what a
highly cohesive class is?”
1.3 Providing cohesion
definition to participants
[YES]
[NO]
2.0 Questions for comparing class
cohesion (in pairs of classes)
3.0 Questions for collecting
participat's profile
19
1.1 “Are you familiar with the concept
of cohesion in the context of software
development?”
1.2 “How would you explain
to someone else what a
highly cohesive class is?”
1.3 Providing cohesion
definition to participants
[YES]
[NO]
2.0 Questions for comparing class
cohesion (in pairs of classes)
3.0 Questions for collecting
participat's profile
Participants’
profile
Academic degree
and Occupation
20
0
5
10
15
20
25
30
35
40
Occupation
2 (2%)
25 (31%)
11 (14%)
33 (41%)
9 (11%)
0
0
5
10
15
20
25
30
35
Undergraduate Graduate Graduate
(Certified
expert)
Graduate
(Master)
Graduate (PhD) No academic
degree
Academic degree
Years of
programming
21
22
1.1 “Are you familiar with the
concept of cohesion in the context
of software development?”
1.2 “How would you explain
to someone else what a
highly cohesive class is?”
1.3 Providing cohesion
definition to participants
[YES]
[NO]
2.0 Questions for comparing class
cohesion (in pairs of classes)
3.0 Questions for collecting
participat's profile
Cohesion
familiarity
question
71 –YES (89%)
9 – NO (11%)
Most of the participants are familiar with cohesion.
These 9 who are not familiar with cohesion have little
experience.
23
Coding on 71 respones.
11 topics coded.
78% related to the “class responsibilities” topic.
“It is a class with a well defined scope of responsibilities”;
“(...) When it performs a well-defined role”;
“Singular in purpose. It does one thing, and only one thing”;
7% related to class internal structure.
“Methods of this class implement features by calling each other”;
24
25
2.0 Questions for comparing
class cohesion (in pairs of
classes)
Cohesion ratings
and reasoning
1.1 “Are you familiar with the concept
of cohesion in the context of software
development?”
1.2 “How would you explain
to someone else what a
highly cohesive class is?”
1.3 Providing cohesion
definition to participants
[YES]
[NO]
3.0 Questions for collecting
participat's profile
26
“Which class is more cohesive?”
 “A”
 “B”
 “Quite similar cohesion”
 “I don’t know”
“What was your rationale?”
Cohesion ratings and reasoning
A Bvs.
Comparison
scenarios
27
A Bvs.
1st scenario
- Structural cohesion +
= Conceptual cohesion =
DB_Backend.java DB_InsertUpdate.java
A Bvs.
2nd scenario
- Structural cohesion +
+ Conceptual cohesion -
Main_Config2.java DB_Helpers.java
A Bvs.
3rd scenario
= Structural cohesion =
- Conceptual cohesion +
RelationSpouse.java RelationParentChild.java
Structural cohesion => LCOM5
[Henderson-Sellers, 1996]
Conceptual cohesion => LCbC
[Silva, 2012]
28
A Bvs.
- Structural cohesion +
= Conceptual cohesion =
DB_Backend.java DB_InsertUpdate.java
Their explanation showed that none of them applied the structural cohesion perception.
29
A Bvs.
- Structural cohesion +
= Conceptual cohesion =
DB_Backend.java DB_InsertUpdate.java
Our coding analysis confirmed that most of them used the conceptual cohesion perception.
30
A Bvs.
- Structural cohesion +
= Conceptual cohesion =
DB_Backend.java DB_InsertUpdate.java
Why?
31
A Bvs.
- Structural cohesion +
= Conceptual cohesion =
DB_Backend.java DB_InsertUpdate.java
41 had the conceptual cohesion perception by identifying less responsibilities in (A) class.
32
A Bvs.
- Structural cohesion +
+ Conceptual cohesion -
Main_Config2.java DB_Helpers.java
33
A Bvs.
- Structural cohesion +
+ Conceptual cohesion -
Main_Config2.java DB_Helpers.java
45 mentioned the class single behavior.
6 mentioned the structural relatedness of class internal members.
34
A Bvs.
- Structural cohesion +
+ Conceptual cohesion -
Main_Config2.java DB_Helpers.java
They did not use structural cohesion perception in their
explanation.
35
A Bvs.
- Structural cohesion +
+ Conceptual cohesion -
Main_Config2.java DB_Helpers.java
12 justified their answers by mentioning class
responsibilities.
36
A Bvs.
= Structural cohesion =
- Conceptual cohesion +
RelationSpouse.java RelationParentChild.java
37
A Bvs.
= Structural cohesion =
- Conceptual cohesion +
RelationSpouse.java RelationParentChild.java
“Class responsibilities” topic in all of them.
38
A Bvs.
= Structural cohesion =
- Conceptual cohesion +
RelationSpouse.java RelationParentChild.java
4 of them seem to had done that by mistake. Their explanations match with the
opposite.
39
A Bvs.
= Structural cohesion =
- Conceptual cohesion +
RelationSpouse.java RelationParentChild.java
2 explanations were actually related to structural cohesion
perception, whereas 24 were related to conceptual cohesion.
40
scenarios
41
Most of the developers were
familiar with cohesion.
Experience may influence
Perception of conceptual cohesion
was predominant.
Regardless experience
Conceptual cohesion seems to be
more intuitive and closer to the
human-oriented view of cohesion.
Conceptual cohesion
measurement captures better the
real notion of cohesion
Implementation of conceptual cohesion metrics in
software measurement tools
take advantage of evolving concern mining techniques
Investigation on how developers maintain high (low)
cohesive modules
46
goo.gl/DmE6Is
brunocs@dcc.ufba.br
47
Design and Evolution Group
http://aside.dcc.ufba.br
Software Engineering Lab
http://les.dcc.ufba.br
Federal University
of Bahia, Brazil
49
LCOM – Lack of Cohesion in Methods
[Chidamber & Kemerer, 1994]
50
Counts the number of pairs of methods
that access (Q) and do not access (P)
attributes in common.
Q = 1
P = 1 + 1 = 2
LCOM = P – Q = 2 -1 = 1
Rely on text mining techniques and/or
identification of pieces of code
implementing the concerns.
C3
 [Marcus & Poshyvanyk, 2005]
MWE
 [Y. Liu et al., 2009]
LCbC
 [B. Silva et al., 2012]
51
LCbC – Lack of Concern-based Cohesion
[B. Silva, C. Sant’Anna, C. Chavez, A. Garcia, 2012]
52
Counts the number of concerns implemented
by a class.
Relies on a concerns-to-code mapping.
Concerns:
Business rule
Persistence
Exception handling
LCbC = 3
 “it is a class with a well defined scope of responsibilities”;
 “(...) It should not take responsibility for functions other than its own”;
 “(...) When it performs a well- defined role”;
 “Singular in purpose. It does one thing, and only one thing”;
 “All the included functionalities are conceptually highly related”;
 “(…) If you think of a Def-Use-Graph almost all nodes should be connected to
achieve high cohesion”;
 “Methods of this class implement features by calling each other”;
 “Its members are concerned mostly with themselves and other members of the
same class”. 53
The term cohesion was first introduced in 1974 by Stevens and colleagues in the
context of structured design and defined as a measure of the degree to which the
internal elements* of a module* belong together. Accordingly, in a highly
cohesive module, all the elements are related to the performance of a single
behavior of the software.
Martin (2003) defined that a highly cohesive class should have a single
responsibility. Bieman and Kang (1995) stated that a highly cohesive class should
be dificult to split.
* A module can be considered as a class in object-oriented programming. Accordingly, the internal
elements are its fields and methods.
54
55
• Size
• Context
• Naming conventions
• Source code comments

More Related Content

PPTX
Understanding Software Cohesion Metrics: Experimental Assessment of Conceptua...
DOC
CSE333 project initial spec: Learning agents
PDF
Distributed Agile Development: Practices for building trust in team through E...
PPTX
Final sdp ppt
PPTX
Esprit Rugby et Pilotage d'Equipes - Cercle de Discussion - PMI Branche Midi-...
PDF
A Coach's Guide to Team Cohesion
PDF
International Journal of Computational Engineering Research(IJCER)
PPTX
Software Quality Assessment Practices
Understanding Software Cohesion Metrics: Experimental Assessment of Conceptua...
CSE333 project initial spec: Learning agents
Distributed Agile Development: Practices for building trust in team through E...
Final sdp ppt
Esprit Rugby et Pilotage d'Equipes - Cercle de Discussion - PMI Branche Midi-...
A Coach's Guide to Team Cohesion
International Journal of Computational Engineering Research(IJCER)
Software Quality Assessment Practices

Similar to An Empirical Study on How Developers Reason about Module Cohesion (20)

ODP
Software quality - Connascence
PDF
Cohesion and Coupling - The Keys To Changing Your Code With Confidence
PPTX
Effective Software Design
PPTX
Code metrics
PPT
Writing Quality Code
ODP
Software Quality Assurance
PPTX
Se 381 - lec 23 - 28 - 12 may16 - modularity - ii - cohesion
PPTX
Software Design 1: Coupling & cohesion
PPTX
Cohesion And It's Type Vardan Nikhil.pptx
PPTX
Comfortable code
PDF
Identifying Thresholds for Distance Design-based Direct Class Cohesion (D3C2)...
PPTX
Software Design And ArchitectureLecture-3.pptx
PPT
Mvc grasp
PPTX
SQA - Lecturhvvvvvvvvvvvvvvvvvvvve 07.pptx
PPT
Slides chapter 11
PPT
NDepend Public PPT (2008)
PPTX
Seminar presentation by geethu..Software engineering .pptx
PPTX
SOFTWARE DESIGN_Module_1_Module_2_3.pptx
PPTX
An Information Retrieval Based Approach for Measuring Service Conceptual Cohe...
PPT
Software Design (Lectu. re 4).ppt
Software quality - Connascence
Cohesion and Coupling - The Keys To Changing Your Code With Confidence
Effective Software Design
Code metrics
Writing Quality Code
Software Quality Assurance
Se 381 - lec 23 - 28 - 12 may16 - modularity - ii - cohesion
Software Design 1: Coupling & cohesion
Cohesion And It's Type Vardan Nikhil.pptx
Comfortable code
Identifying Thresholds for Distance Design-based Direct Class Cohesion (D3C2)...
Software Design And ArchitectureLecture-3.pptx
Mvc grasp
SQA - Lecturhvvvvvvvvvvvvvvvvvvvve 07.pptx
Slides chapter 11
NDepend Public PPT (2008)
Seminar presentation by geethu..Software engineering .pptx
SOFTWARE DESIGN_Module_1_Module_2_3.pptx
An Information Retrieval Based Approach for Measuring Service Conceptual Cohe...
Software Design (Lectu. re 4).ppt
Ad

Recently uploaded (20)

PDF
AI Guide for Business Growth - Arna Softech
PPTX
CNN LeNet5 Architecture: Neural Networks
PDF
Salesforce Agentforce AI Implementation.pdf
PDF
iTop VPN Crack Latest Version Full Key 2025
PDF
Cost to Outsource Software Development in 2025
PDF
How Tridens DevSecOps Ensures Compliance, Security, and Agility
PDF
DNT Brochure 2025 – ISV Solutions @ D365
PPTX
Oracle Fusion HCM Cloud Demo for Beginners
DOCX
How to Use SharePoint as an ISO-Compliant Document Management System
DOCX
Modern SharePoint Intranet Templates That Boost Employee Engagement in 2025.docx
PPTX
Log360_SIEM_Solutions Overview PPT_Feb 2020.pptx
PDF
Multiverse AI Review 2025: Access All TOP AI Model-Versions!
PPTX
Monitoring Stack: Grafana, Loki & Promtail
PDF
AI/ML Infra Meetup | LLM Agents and Implementation Challenges
PPTX
Introduction to Windows Operating System
PDF
The Dynamic Duo Transforming Financial Accounting Systems Through Modern Expe...
PDF
MCP Security Tutorial - Beginner to Advanced
PDF
Ableton Live Suite for MacOS Crack Full Download (Latest 2025)
PDF
Top 10 Software Development Trends to Watch in 2025 🚀.pdf
PPTX
assetexplorer- product-overview - presentation
AI Guide for Business Growth - Arna Softech
CNN LeNet5 Architecture: Neural Networks
Salesforce Agentforce AI Implementation.pdf
iTop VPN Crack Latest Version Full Key 2025
Cost to Outsource Software Development in 2025
How Tridens DevSecOps Ensures Compliance, Security, and Agility
DNT Brochure 2025 – ISV Solutions @ D365
Oracle Fusion HCM Cloud Demo for Beginners
How to Use SharePoint as an ISO-Compliant Document Management System
Modern SharePoint Intranet Templates That Boost Employee Engagement in 2025.docx
Log360_SIEM_Solutions Overview PPT_Feb 2020.pptx
Multiverse AI Review 2025: Access All TOP AI Model-Versions!
Monitoring Stack: Grafana, Loki & Promtail
AI/ML Infra Meetup | LLM Agents and Implementation Challenges
Introduction to Windows Operating System
The Dynamic Duo Transforming Financial Accounting Systems Through Modern Expe...
MCP Security Tutorial - Beginner to Advanced
Ableton Live Suite for MacOS Crack Full Download (Latest 2025)
Top 10 Software Development Trends to Watch in 2025 🚀.pdf
assetexplorer- product-overview - presentation
Ad

An Empirical Study on How Developers Reason about Module Cohesion

  • 1. Design and Evolution Group http://aside.dcc.ufba.br Software Engineering Lab http://les.dcc.ufba.br By Ticino Turismo Byline: swiss-image.ch Federal University of Bahia, Brazil
  • 2. 2
  • 4. It has been recognized as an important quality attribute of software design. [W. Stevens, Myers & Constantine, 1974], [Bieman & Kang, 1995], [Fenton & Pfleger, 1998], [R. Martin, 2003] … The degree to which a module is focused on a single concern of the software 4
  • 5. Strong related to modularity. Highly cohesive modules are claimed to be: easier to understand easier to maintain less likely to undergo changes and faults 5
  • 7. 7
  • 8. 8
  • 10. 10 Methods accessing the same attributes For structural cohesion metrics, it is highly cohesive
  • 12. 12 For conceptual cohesion metrics, it is not highly cohesive How many concerns does this class address?
  • 13. It is still unaddressed to what extent structural and conceptual cohesion measurements reflect developer’s perception of module cohesion. 13
  • 14. RQ1: How do developers perceive module cohesion? How do they reason about it? RQ2: To what extent do structural cohesion and conceptual cohesion measurements relate with how developers rate cohesion of modules? 14
  • 15. RQ1: How do developers perceive module cohesion? How do they reason about it? RQ2: To what extent do structural cohesion and conceptual cohesion measurements relate with how developers rate cohesion of modules? 15
  • 16. Goal: Collect developers’ opinion about module cohesion. 16
  • 17. Goal: Collect developers’ opinion about module cohesion. 228 invitations sent to software developers. 80 full responses (35%). From different countries: Canada, Germany, Chile, Japan, USA, Iran, Poland, Spain, Portugal and Brazil. 17
  • 18. 18 1.1 “Are you familiar with the concept of cohesion in the context of software development?” 1.2 “How would you explain to someone else what a highly cohesive class is?” 1.3 Providing cohesion definition to participants [YES] [NO] 2.0 Questions for comparing class cohesion (in pairs of classes) 3.0 Questions for collecting participat's profile
  • 19. 19 1.1 “Are you familiar with the concept of cohesion in the context of software development?” 1.2 “How would you explain to someone else what a highly cohesive class is?” 1.3 Providing cohesion definition to participants [YES] [NO] 2.0 Questions for comparing class cohesion (in pairs of classes) 3.0 Questions for collecting participat's profile Participants’ profile
  • 20. Academic degree and Occupation 20 0 5 10 15 20 25 30 35 40 Occupation 2 (2%) 25 (31%) 11 (14%) 33 (41%) 9 (11%) 0 0 5 10 15 20 25 30 35 Undergraduate Graduate Graduate (Certified expert) Graduate (Master) Graduate (PhD) No academic degree Academic degree
  • 22. 22 1.1 “Are you familiar with the concept of cohesion in the context of software development?” 1.2 “How would you explain to someone else what a highly cohesive class is?” 1.3 Providing cohesion definition to participants [YES] [NO] 2.0 Questions for comparing class cohesion (in pairs of classes) 3.0 Questions for collecting participat's profile Cohesion familiarity question
  • 23. 71 –YES (89%) 9 – NO (11%) Most of the participants are familiar with cohesion. These 9 who are not familiar with cohesion have little experience. 23
  • 24. Coding on 71 respones. 11 topics coded. 78% related to the “class responsibilities” topic. “It is a class with a well defined scope of responsibilities”; “(...) When it performs a well-defined role”; “Singular in purpose. It does one thing, and only one thing”; 7% related to class internal structure. “Methods of this class implement features by calling each other”; 24
  • 25. 25 2.0 Questions for comparing class cohesion (in pairs of classes) Cohesion ratings and reasoning 1.1 “Are you familiar with the concept of cohesion in the context of software development?” 1.2 “How would you explain to someone else what a highly cohesive class is?” 1.3 Providing cohesion definition to participants [YES] [NO] 3.0 Questions for collecting participat's profile
  • 26. 26 “Which class is more cohesive?”  “A”  “B”  “Quite similar cohesion”  “I don’t know” “What was your rationale?” Cohesion ratings and reasoning A Bvs.
  • 27. Comparison scenarios 27 A Bvs. 1st scenario - Structural cohesion + = Conceptual cohesion = DB_Backend.java DB_InsertUpdate.java A Bvs. 2nd scenario - Structural cohesion + + Conceptual cohesion - Main_Config2.java DB_Helpers.java A Bvs. 3rd scenario = Structural cohesion = - Conceptual cohesion + RelationSpouse.java RelationParentChild.java Structural cohesion => LCOM5 [Henderson-Sellers, 1996] Conceptual cohesion => LCbC [Silva, 2012]
  • 28. 28 A Bvs. - Structural cohesion + = Conceptual cohesion = DB_Backend.java DB_InsertUpdate.java Their explanation showed that none of them applied the structural cohesion perception.
  • 29. 29 A Bvs. - Structural cohesion + = Conceptual cohesion = DB_Backend.java DB_InsertUpdate.java Our coding analysis confirmed that most of them used the conceptual cohesion perception.
  • 30. 30 A Bvs. - Structural cohesion + = Conceptual cohesion = DB_Backend.java DB_InsertUpdate.java Why?
  • 31. 31 A Bvs. - Structural cohesion + = Conceptual cohesion = DB_Backend.java DB_InsertUpdate.java 41 had the conceptual cohesion perception by identifying less responsibilities in (A) class.
  • 32. 32 A Bvs. - Structural cohesion + + Conceptual cohesion - Main_Config2.java DB_Helpers.java
  • 33. 33 A Bvs. - Structural cohesion + + Conceptual cohesion - Main_Config2.java DB_Helpers.java 45 mentioned the class single behavior. 6 mentioned the structural relatedness of class internal members.
  • 34. 34 A Bvs. - Structural cohesion + + Conceptual cohesion - Main_Config2.java DB_Helpers.java They did not use structural cohesion perception in their explanation.
  • 35. 35 A Bvs. - Structural cohesion + + Conceptual cohesion - Main_Config2.java DB_Helpers.java 12 justified their answers by mentioning class responsibilities.
  • 36. 36 A Bvs. = Structural cohesion = - Conceptual cohesion + RelationSpouse.java RelationParentChild.java
  • 37. 37 A Bvs. = Structural cohesion = - Conceptual cohesion + RelationSpouse.java RelationParentChild.java “Class responsibilities” topic in all of them.
  • 38. 38 A Bvs. = Structural cohesion = - Conceptual cohesion + RelationSpouse.java RelationParentChild.java 4 of them seem to had done that by mistake. Their explanations match with the opposite.
  • 39. 39 A Bvs. = Structural cohesion = - Conceptual cohesion + RelationSpouse.java RelationParentChild.java 2 explanations were actually related to structural cohesion perception, whereas 24 were related to conceptual cohesion.
  • 41. 41
  • 42. Most of the developers were familiar with cohesion. Experience may influence
  • 43. Perception of conceptual cohesion was predominant. Regardless experience
  • 44. Conceptual cohesion seems to be more intuitive and closer to the human-oriented view of cohesion.
  • 45. Conceptual cohesion measurement captures better the real notion of cohesion
  • 46. Implementation of conceptual cohesion metrics in software measurement tools take advantage of evolving concern mining techniques Investigation on how developers maintain high (low) cohesive modules 46
  • 48. Design and Evolution Group http://aside.dcc.ufba.br Software Engineering Lab http://les.dcc.ufba.br Federal University of Bahia, Brazil
  • 49. 49
  • 50. LCOM – Lack of Cohesion in Methods [Chidamber & Kemerer, 1994] 50 Counts the number of pairs of methods that access (Q) and do not access (P) attributes in common. Q = 1 P = 1 + 1 = 2 LCOM = P – Q = 2 -1 = 1
  • 51. Rely on text mining techniques and/or identification of pieces of code implementing the concerns. C3  [Marcus & Poshyvanyk, 2005] MWE  [Y. Liu et al., 2009] LCbC  [B. Silva et al., 2012] 51
  • 52. LCbC – Lack of Concern-based Cohesion [B. Silva, C. Sant’Anna, C. Chavez, A. Garcia, 2012] 52 Counts the number of concerns implemented by a class. Relies on a concerns-to-code mapping. Concerns: Business rule Persistence Exception handling LCbC = 3
  • 53.  “it is a class with a well defined scope of responsibilities”;  “(...) It should not take responsibility for functions other than its own”;  “(...) When it performs a well- defined role”;  “Singular in purpose. It does one thing, and only one thing”;  “All the included functionalities are conceptually highly related”;  “(…) If you think of a Def-Use-Graph almost all nodes should be connected to achieve high cohesion”;  “Methods of this class implement features by calling each other”;  “Its members are concerned mostly with themselves and other members of the same class”. 53
  • 54. The term cohesion was first introduced in 1974 by Stevens and colleagues in the context of structured design and defined as a measure of the degree to which the internal elements* of a module* belong together. Accordingly, in a highly cohesive module, all the elements are related to the performance of a single behavior of the software. Martin (2003) defined that a highly cohesive class should have a single responsibility. Bieman and Kang (1995) stated that a highly cohesive class should be dificult to split. * A module can be considered as a class in object-oriented programming. Accordingly, the internal elements are its fields and methods. 54
  • 55. 55 • Size • Context • Naming conventions • Source code comments