Programming foundations

Stage 5 · Lesson 8 of 10

Code smells and refactoring

Object-oriented design and clean code

means changing the structure of code without changing what it does. You do it in small steps, with the tests passing after each one. A code smell is a sign that a refactoring might help.

Common smells are a very long , a long list of parameters, duplicated code, a vague name, deeply nested if statements, or one change that forces edits in many files. Each smell has standard fixes. You can extract part of a function into its own function, rename things, or replace nested conditions with .

You can also group related parameters into a small class. One rule keeps it safe: never refactor and add features in the same step, and run the tests after every change. This is the core of the milestone.

A question to check yourself, an AI practice session and 1 cheat sheet entry come when you add the roadmap to your account. Add it

Resources for this stage

Start with· follow one of these

Practise

  • Request mentoring on a solved exercise and ask specifically about naming and structure

Keep handy

Also worth your time

Mark this stage as not done?