Upgrade to Pro — share decks privately, control downloads, hide ads and more …

[ESEM 2022] To What Extent Cognitive Driven Development Improves Code Readability

Gustavo Pinto
September 23, 2022

[ESEM 2022] To What Extent Cognitive Driven Development Improves Code Readability

Paper presented at ESEM'22

Gustavo Pinto

September 23, 2022
Tweet

More Decks by Gustavo Pinto

Other Decks in Technology

Transcript

  1. Gustavo Pinto To What Extent Cognitive Driven Development Improves Code

    Readability? 1 Victor Santiago Alberto de Souza Leonardo Barbosa UFPA & Zup Innovation UFPA Zup Innovation UFPA
  2. @zupinnovation zup.com.br <> @zupinnovation • Software aging is far from

    new • Many old programs are essential and still require maintenance Software gets old
  3. @zupinnovation zup.com.br <> @zupinnovation Cognitive-Driven Development (CDD) • CDD is

    a design technique created at Zup Innovation, a Brazilian tech company • It is based on two psychological theories ◦ The Magical Number 7 ◦ The Cognitive Load Theory
  4. @zupinnovation zup.com.br <> @zupinnovation The Magical Number 7 (+/- 2)

    (Miller, 1956) • We are only able to process 7 (+/- 2) units of information in short-term memory. • As we receive more information simultaneously, we lose the ability to process it (and we tend to make mistakes). Units of information Comprehension
  5. @zupinnovation zup.com.br <> @zupinnovation Cognitive Load Theory (Sweller, 1988; Sweller,

    2010) • Each material has its own intrinsic complexity, and requires some cognitive effort ◦ Sometimes big, sometimes small • Certain types of items can hinder our understanding
  6. @zupinnovation zup.com.br <> @zupinnovation CDD in a nutshell • It

    provides a limit indicating how much a code unit could grow • It defines the code elements that hinder our understanding (and then should be limited)
  7. @zupinnovation zup.com.br <> @zupinnovation Cognitive-Driven Development (CDD) • It provides

    a limit indicating how much a code unit could grow • It defines the code elements that hinder our understanding (and then should be limited) SBES 2021 ICSME 2020
  8. We curated 10 pairs of code 10 CDD-Driven Refactorings 10

    Original Versions Does CDD improve code readability? (ESEM 2022) CDD-Driven Refactorings
  9. Does CDD improve code readability? (ESEM 2022) We asked 133

    devs to answer (and justify) their preferences Java Experience
  10. Does CDD improve code readability? Description Original CDD % Original

    % CDD Encapsulating error handling 67 66 50% 50% Encapsulating business rules 19 114 14% 86% Concatenating logical expressions 9 124 7% 93% Extracting classes 14 119 11% 89% Listing all imports 45 88 34% 66% Functional checking style 95 38 71% 29% Extracting classes 27 106 20% 80% Encapsulating for loops 10 123 8% 92%
  11. Description Original CDD % Original % CDD Encapsulating error handling

    67 66 50% 50% Encapsulating business rules 19 114 14% 86% Concatenating logical expressions 9 124 7% 93% Extracting classes 14 119 11% 89% Listing all imports 45 88 34% 66% Functional checking style 95 38 71% 29% Extracting classes 27 106 20% 80% Encapsulating for loops 10 123 8% 92% Does CDD improve code readability?
  12. Encapsulating error handling Original (50%) CDD (50%) “Logging with try-catch

    is so common that I didn’t even need to read the code to understand its purpose." “the code is smaller and sounds like English"
  13. Encapsulating error handling “It is important to known which exception

    could be raised” “The method signature is clear and it makes it easier to understand its behavior” Original (14%) CDD (86%)
  14. Functional checking style “The ternary is an easy resource and

    there was no complex logic to justify a .map” Original (71%) CDD (29%)