Skip to content

26 — ML, RL & LLMs for Software Design

Driving question: What changes when design analysis becomes learned rather than fully rule-based?

Learning objectives

  • Compare supervised, representation-learning, RL, and LLM-assisted approaches.
  • Identify data leakage and benchmark contamination risks.
  • Separate recommendation quality from generated-code correctness.
  • Design hybrid methods that combine rules, analysis, and learned models.

Learning-based tasks

Models can be applied to:

  • smell classification or prioritization;
  • pattern detection;
  • pattern recommendation;
  • refactoring candidate selection;
  • refactoring sequence generation;
  • quality prediction;
  • explanation generation.

Reinforcement learning view

A state may encode code metrics and structural features; actions are refactorings; reward combines quality change, validity, cost, and test outcomes.

The hardest design choice is often the reward, because the agent will optimize what is measured rather than the true engineering goal.

LLM-assisted design

LLMs add semantic and natural-language context but create new evaluation risks:

  • nondeterminism;
  • unverifiable explanations;
  • hallucinated APIs/pattern claims;
  • context-window truncation;
  • training-data contamination;
  • hidden model/version changes;
  • high cost of controlled replication.

Hybrid designs can use static analysis to constrain LLM proposals and compilers/tests to validate transformations.

Design / research exercise

Design a hybrid LLM + static-analysis pipeline for recommending a design pattern. Mark which decisions are made by the LLM, which are rule-constrained, and which are validated automatically.

Suggested reading

  • Recent AI-for-SE work on learned refactoring/design assistance.
  • Foundational ML-for-code and SBSE literature.