Studies on Developers, Refactoring and Code Smells Aiko Yamashita CWI, Netherlands Oslo and Akershus University College, Norway 2016-12-01
A SHORT INTRO ABOUT ME.. Oslo, Norway Gothenburg, Sweden Amsterdam, Netherlands Sapporo, Japan Berkeley, USA San Francisco, USA mom San Jose, Costa Rica dad
What is going on there?
What types of difficulties developers face? TAXONOMY FOR INCREMENTAL CHANGE Maybe the absence/presence of difficulties? Something outcomes happens code (effort, defects, here... properties etc) Researcher Maintenance Project
There is currently no Taxonomy for Programming related difficulties ? f a c t factors o r s Chapin Lientz & Swanson The wider Maintenance tasks environment User knowledge, programmer effectiveness, product quality, The containing programmer time availability, system machine requirements, and system reliability The system f (operators and a c t o r s processes) Dekleva Maintenance management, The software organizational environment, product personnel factors, and system characteristics. Code Reddy Configuration Management Hall / Chen Software Process Improvement scenario inspired by Karahasanovic Webster Program comprehension Risk factors/programming difficulties difficulties Alexander, Ian F. "A taxonomy of stakeholders: Human roles in system development." International Journal of Technology and Human Interaction (IJTHI) 1.1 (2005): 23-59.
What types of difficulties developers face? METHODOLOGY Maintenance Project: - 3-4 weeks - Six developers - Two companies Data collection: - Daily interviews - Think-aloud sessions - Observational Log Data analysis: - Open and Axial coding
What types of difficulties developers face? RESULTS 1) Introduction of faults as result of changes 2) Confusion and erroneous hypothesis generation 3) Slow acquisition of overview/general understanding of the system 4) Time-consuming information quests 5) Time consuming changes Class Change B Class Change A Class Change I C S M E 2 0 1 3 C
Future work Use the model of ‘Incremental change’ Concept Location Concept Extraction process by Raijlich & Gosabi s i s y l a n A n t o c i a t a p g m a I p o r P e g Refactoring n a h C n o i t a z i l a u t Incorporation c More concise, accurate A categorizations
Are we concerned about the same smells? -EXPLORATORY SURVEY- Goal: - Level of insight on code smells - How is currently used - How can concept/tools potentially be used. Non-probability sample Freelance marketplaces (Freelancer.com) Based on a bid (filling out the survey) which was paid 30US/hr for max. 2 hours 85 respondents
Are we concerned about the same smells? -EXPLORATORY SURVEY- W C R E 2 0 1 3 Smell/Anti-Pattern Points Software Engineering Researchers 1. Duplicated code 19.53 2. Long method 9.78 3. Accidental complexity 8.32 Smell 4. Large class 7.09 detector 5. Excessive use of literals 3.04 6. Suboptimal information hiding 2.70 7. Lazy class 2.33 ����������� ���������� ���������� ������������ ����������� 8. Feature Envy 2.33 Feature Points 9. Long parameter list 2.31 Software Engineers ���������������� 1. Detection of duplicated and near-duplicated code 10.00 10. Dead code 2.25 2. Dynamic analysis (number of calls, etc) 4.08 11. Bad (or lack of good) comments 1.50 ������������������ 3. Define and customize detection strategies 3.50 12. Use deprecated components 1.50 ����������������� 4. Support code inspection 2.67 13. Single Responsibility 1.20 5. Suggest refactorings 2.50 ������������������ 14. Complex conditionals 1.12 6. Good usability 2.50 15. Bad naming 1.12 ��������������������� 7. Detect potentially problematic areas 2.33 ��� ���� ���� ���� ���� ����� 8. Real-time update 2.33 9. Detect memory leaks 2.25
Are we concerned about the same smells? -EXPLORATORY SURVEY- Where do you read about code smells? �C���7���F��F���B7�F��%��� 0C���F�7B��I�������7����� 5CC��6�B�C�F �I�8�FG�F��)�� 49��BG���9�37���F��)�� �CC�F��%,�� 1���F �I�8F�G�F����� 2BG��B�G�0C���F��'��� Like! ��C�F��',�� ��� %��� ���� '��� (��� )��� ���� ���� ,���
Are we concerned about the same smells? -TOOL EXPERIENCES- Only two of the respondents (4%) used smell tools: ➡ JetBrains Re-sharper (smell detection + refactoring) ➡ DevExpress CodeRush + Refactor!Pro Other usages: • Coding standards/detect potentially problematic code: ➡ CheckStyle, FindBugs, FxCop, and PMD. • Performance of web applications: ➡ FireBugs, Pagespeed, Yslow and Pingdom • Exploration and code organization for manual review ➡ Visual Studio, Eclipse • Duplicated code (clone detection).
Are we concerned about the same smells? - SUMMARY - • 85 developers did the survey • 32% did not know about code smells • Main sources on code smells: Developers showed interest in: ✓ Blogs automation, accuracy (less false positives) and ✓ Internet forums not being intrusive during work. ✓ Seminars and working place • Majority moderately concerned about smells • Level of knowledge explains perceived criticality • Most developers refactor ‘on the fly’...
do I really need FALSE to check all POSITIVES of them?
Code Smell and Anti-patterns False Positives FIRST ATTEMPT TO BUILD A TAXONOMY Definition Description Synonyms • Refused Bequest 12 anti-patterns and • Message Chains code smells covered • God Method Argumentation for existence of FP • God Class Empirical studies • Feature Envy • Dispersed Coupling Theory • Duplicated Code • Data Clumps Practical • Data Class experiences • Shotgun Surgery • Circular Dependencies Between Packages Concrete Examples (code) instances of FP • Subtype Knowledge Relevant contextual factors Preliminary Catalogue of Anti-pattern and Factor Code Smell False Positives Technical Report RA-5/2015 Implication Pozna ń University of Technology S A N E R 2 0 1 6
Can we have a simpler categorization of defects? TAXONOMY FOR DEFECT CLASSIFICATION requirement captured incorrectly requirements requirement not implemented Building a metadata for modelling/design requirement misunderstood while implementing improvig sampling of projects design flaw / code smell / anti-pattern from GitHub incorrect expression logic data-flow (incl. variable assignment / initialization) algorithm (control-flow) database data construction OR mapping user interaction interface API (technical interface) memory resources concurrency defect performance taxonomy exceptions case completeness validation language OS operating environment 3rd Party environment hardware build tools (make/rake etc) built environment configuration management system standards QA documentation testing other
How do Code Smells affect Maintenance Activities? -MINING IDE EVENT LOGS- Navigating Programming (code-related) Reading activities during Maintenance Editing Searching Others
Experimental Setting: A Controlled Case Study Context Maintenance Tasks • 4 Java Applications Task 1 . Replacing external data source • Same functionality • Different design/code ✔ • Size: 7KLOC to 14KLOC Study Design System ! System D C A B System Task 3 . New Reporting Task 2 . functionality New authentication mechanism Developer
Experimental Setting: A Controlled Case Study fact-sheet • 50,000 Euros • Sep-Dec, 2008 • 7 Weeks Project context • 6 Developers Tasks Programming Development Moderator • 2 Companies System Skill Technology variables Maintenance outcomes Maintainability Effort** Code smells Variables perception* (num. smells** of interest smell density**) Change Maintenance Defects* Size** problems** Open interviews Subversion Audio files/notes Think aloud Task Eclipse database progress activity Video files/notes sheets logs Data Source code sources Trac (Issue tracker), Think aloud Daily interviews Study Acceptance test Video files/notes Audio files/notes diary reports ** System and f le level * Only at system level
How do Code Smells affect Maintenance Activities? -MINING IDE EVENT LOGS- • Selection of artifacts in the package explorer • Selection of Java elements in the editor window • Selecting Java elements in the file outline • Editing source files (Java files) • Scrolling the source code window • Switching between open files • Running Eclipse “commands” (copy, paste, go to line) Activity logs
Recommend
More recommend