Chat
Ask me anything
Ithy Logo
Sign in to save

Scoping a Master's Dissertation: LLMs for Code Smell Detection and Refactoring

Refining broad ambitions into actionable research topics for effective LLM integration

software code analysis tools and vibrant office workspace

Key Highlights

  • Focus on Specific Code Smells: Narrow your research to detect and refactor targeted code smells rather than tackling all types.
  • Integration and Evaluation: Combine state-of-the-art LLMs with traditional tools and compare their performance using realistic datasets.
  • Refactoring Strategies & Prompt Engineering: Develop and evaluate strategies including prompt design to enhance LLM recommendations for code improvement.

Overview

In recent years, the emergence of advanced large language models (LLMs) has invigorated the fields of software engineering and automated code analysis. However, the promise of using LLMs to detect code smells—common pitfalls in programming that may indicate deeper issues—and refactor them into maintainable code presents both exciting opportunities and significant challenges. As a Master’s student, your research should aim to bridge theoretical advancements with practical applications, but it is crucial to narrow down the scope to ensure the project is feasible within the allotted timeframe.

This proposal outlines several pragmatic topics and research directions that focus on leveraging LLMs for targeted code smell detection and automated refactoring. Each topic has been reframed into manageable sub-problems that address specific code quality issues in diverse programming environments. The following sections detail potential research directions, assessment criteria, methodology ideas, and implications for software development.


Pragmatic Research Topics

1. Language-Specific Code Smell Detection

Objective and Scope

Rather than attempting to apply LLMs uniformly across all programming languages, focus on a single language such as Python, Java, or C#. Every programming language has unique syntax and idiomatic expressions that can influence the type and occurrence of code smells. By concentrating on one language, you can develop a more specialized detection tool that accounts for these nuances.

Research Methodology

The primary methodological steps could include:

  • Dataset Curation: Collect a corpus of code from open-source repositories, ensuring that it includes known instances of specific code smells for the targeted language.
  • Fine-Tuning LLMs: Train or fine-tune available LLMs using this language-specific dataset. The model can be customized to recognize indicators of specific code smells such as long methods, duplicated code, or god classes.
  • Evaluation Metrics: Compare results from the refined LLM with traditional static analysis tools. Metrics such as precision, recall, and F1 score are key indicators of effectiveness.

With this approach, the research focuses on a well-defined technical challenge while contributing valuable insights into the intersection of language-specific programming practices and modern AI capabilities.

2. Fine-Tuning and Prompt Engineering for Targeted Code Refactoring

Objective and Rationale

LLMs like GPT-4 and StarCoder2 have shown potential not only for code analysis but also for suggesting refactoring opportunities. This research direction involves exploring different prompt engineering techniques that guide LLMs to generate viable refactoring strategies for well-known code smells. Instead of expecting a one-size-fits-all refactoring solution, the study could assess the effectiveness of various prompting methodologies.

Research Methodology

The core components of the research may include:

  • Prompt Designing: Experiment with several prompting styles, such as one-shot, few-shot prompts, and context-specific instructions that include examples of refactored code.
  • Controlled Experimentation: Apply these prompts to different code samples exhibiting specific smells (for instance, "Long Method" or "Excessive Parameters") to determine which prompts induce the best refactoring outcomes.
  • Quality Assessment: Evaluate the refactored code on key parameters such as readability, maintainability, and reduction in complexity using both automated metrics and human coder evaluation.

This topic navigates the interplay between human-authored design patterns and algorithm-driven suggestions, enabling a focused study on creating triggers that improve the practical output of LLMs in refactoring efforts.

3. Integrating LLMs with Traditional Code Analysis Toolkits

Objective and Integration Strategy

By combining conventional static analysis tools with LLM-powered approaches, you can build a hybrid system that leverages the strengths of both. Traditional tools provide rule-based mechanisms that are often well-tested over time, while LLMs offer flexible pattern recognition and language understanding.

Research Methodology

The research strategy includes:

  • System Integration: Design a framework that first utilizes static code analyzers to flag potential code smells, then applies an LLM to offer nuanced refactoring suggestions.
  • Empirical Evaluation: Compare the hybrid system’s efficiency against both standalone static analysis and LLM-only approaches. The evaluation should focus on detection accuracy and the quality of refactoring outputs.
  • Case Study Implementation: Deploy the system on code repositories from different domains (e.g., web applications, embedded systems) to gather a broad set of performance data.

Such integration aims to enhance detection accuracy and reduce false positives while offering practical refactoring recommendations that can be directly applied in real-world development environments.

4. Comparative Analysis of LLM Performance in Code Refactoring

Objective and Comparative Framework

Conducting a comparative study among different LLMs, such as GPT-3, GPT-4, StarCoder2, and industry-specific models can yield valuable insights into their practical utility. Analyzing different models helps in identifying which model performs best for specific kinds of code smells and refactoring strategies.

Research Methodology

The study could include the following steps:

  • Defining Benchmarks: Establish standardized datasets and evaluation criteria, including automated metrics (like cyclomatic complexity reduction) and human assessments for refactor quality.
  • Performing Controlled Experiments: Run a set of experiments where each model is tasked to detect and refactor the same set of code samples. The experiments should compare detection precision, refactoring quality, and time efficiency.
  • Statistical Analysis: Use statistical methods to determine the significance of resulting differences among models, documenting not only successes but also failure cases or sub-optimal suggestions.

This direction allows for a side-by-side comparison that informs future research and development in AI-assisted code quality improvement, and helps tailor the choice of LLMs according to the needs of specific software systems.


A Comprehensive Framework Comparison Table

The table below summarizes the components, methodologies, and expected outcomes for the presented research topics. This comparative overview can serve as a quick-reference guide while finalizing your dissertation scope.

Research Topic Objective Methodology Expected Outcome
Language-Specific Code Smell Detection Specialize detection by focusing on a particular programming language. Curation of domain-specific datasets; Fine-tuning of LLMs; Comparative metric analysis. Enhanced accuracy in detecting language-dependent code smells.
Fine-Tuning and Prompt Engineering for Code Refactoring Develop optimal prompt strategies for effective refactoring recommendations. Experiment with various prompt designs; Controlled experimentation on refactoring; Quality comparisons. Refactoring outputs that improve code readability and maintainability.
Integrating LLMs with Traditional Tools Combine the strengths of static analysis tools with LLM-powered insights. Architect a hybrid system; Execute empirical evaluations; Perform case studies in varied environments. A system with enhanced detection accuracy and practical refactoring suggestions.
Comparative Analysis of LLM Performance Benchmark multiple LLMs for their code smell detection and refactoring capabilities. Define standard test cases; Run comparative experiments; Evaluate using statistical analysis. Identification of best-performing models for specific types of code smells and contexts.

Considerations for Your Research Proposal

Focused Research Question

The key to a successful dissertation is framing a well-scoped, precise research question. For instance, instead of asking, "How can LLMs detect and refactor code smells?" refine your question to something like, "Can fine-tuning GPT-4 on Python-based code repositories significantly improve detection accuracy for the 'Long Method' code smell, and how do prompt engineering techniques influence refactoring quality compared to traditional static analysis tools?"

Available Datasets and Benchmarking

When designing your study, consider available datasets that include annotated instances of code smells. Open-source repositories, industry datasets, and synthetic code corpora can all potentially provide the necessary training and evaluation data. Benchmarking against established static analysis tools will not only validate your approach but also highlight where AI-driven models provide added value or fall short.

Scalability and Integration in Real Projects

Beyond academia, your research could have a significant impact if it leads to tools that integrate seamlessly with existing development environments such as IDEs. Studying the hybrid model that pairs traditional static analyzers with LLM enhancements may show the practical benefits of your approach, such as reducing manual code reviews and maintaining continuous integration quality.

Ethical Implications and Developer Acceptance

An important aspect particularly relevant in AI research is the ethical consideration. Evaluate how biases in training data might affect detection accuracy or lead to unintended consequences in established coding practices. Additionally, conducting small-scale user studies or surveys can provide insights on how developers perceive LLM-suggested refactoring compared to traditional methods, ensuring that your research remains grounded in practical utility.


Technical Approach and Metrics for Evaluation

Defining Success Metrics

Establish clear success metrics and evaluation benchmarks early in your research. Metrics might include:

  • Detection accuracy: Measured using precision, recall, and F1 score.
  • Refactoring quality: Assessed via automated code quality metrics such as cyclomatic complexity, code maintainability indices, and through feedback from experienced developers.
  • Performance benchmarks: Evaluate runtime improvements in detecting or refactoring large codebases.

Validation Techniques

Use both qualitative and quantitative techniques for validating your results. Statistical validation, controlled experiments, and user studies are all essential components. For example, if one of your research topics involves prompt engineering, consider validating different prompts on a standardized set of code examples. This approach ensures that improvements are not only statistically significant but also practically effective.


References

Recommended Related Queries


Last updated March 9, 2025

AI-assisted research. Sources, methodology and corrections · Source-checked guides and tools · Explore published answers

Ask Ithy AI
Download Article
Delete Article