Column: Learn Design and Optimization from AI-Generated “Bad Code”!
Now that AI coding tools like Cursor and Copilot have become widespread, have you ever felt a vague sense of discomfort when looking at the code they generate?
And despite living in an era where maintainable designs like the SOLID principles and refactoring are valued,
- Adjusting or adding new features takes more and more time
- Even small code changes have unexpected side effects
…aren’t you getting stuck in situations like these?
Even if the company as a whole can’t quickly change the situation, for individuals, this is a great opportunity to grow your "code design" and "optimization" skills.
Take advantage of AI by intentionally generating “bad code,” then refactor it yourself—a highly effective way to build these skills.
For example, ask your generative AI this prompt:
“Please provide an example of code with room for improvement, and the refactored version. Make it something that can be refactored in about five minutes.”

This way, you will get not just examples but also useful hints about readability, removing code duplication, and separation of concerns—a practical mini-exercise.
Unlike purely textbook-based learning, you can tailor your study to your current level. This is truly a turning point for those who aim to write code as good as—or better than—AI.
As a final note, I remember the days when we outsourced software conversion to overseas teams. To assess the programmers’ skill, we gave them tests where they had to turn bad code into good code. Creating the same level of bad code for each person turned out to be surprisingly difficult.
#SOLIDprinciples #Refactoring