FlareStart
HomeNewsHow ToSources
FlareStart

Where developers start their day. All the tech news & tutorials that matter, in one place.

Quick Links

  • Home
  • News
  • Tutorials
  • Sources
  • Privacy Policy

Connect

© 2026 FlareStart. All rights reserved.

Back to articles
The Gilded Rose Kata: Composition Over Inheritance
How-ToTools

The Gilded Rose Kata: Composition Over Inheritance

via Dev.to TutorialWillem van Heemstra2w ago

The Gilded Rose refactoring kata is a classic coding exercise that challenges developers to refactor legacy code while adding new functionality. Most solutions reach for inheritance as the primary design pattern, but I want to show you a different approach: composition over inheritance . In this article, I’ll walk you through my solution that leverages composition and the Strategy pattern to create a more flexible and maintainable design. By the end, you’ll see why composition often leads to better software architecture. Credit to Emily Bache’s GitHub repository for the excellent kata resources. The Problem Here’s the legacy code we need to refactor: class GildedRose ( object ): def __init__ ( self , items ): self . items = items def update_quality ( self ): for item in self . items : if item . name != " Aged Brie " and item . name != " Backstage passes to a TAFKAL80ETC concert " : if item . quality > 0 : if item . name != " Sulfuras, Hand of Ragnaros " : item . quality = item . qualit

Continue reading on Dev.to Tutorial

Opens in a new tab

Read Full Article
22 views

Related Articles

How-To

Learn Something Old Every Day, Part XVIII: How Does FPU Detection Work?

Lobsters • 4d ago

“Learn to Code” Is Dead… Learn to Think Instead
How-To

“Learn to Code” Is Dead… Learn to Think Instead

Medium Programming • 4d ago

How-To

How One File Makes Claude Code Actually Follow Your Instructions

Medium Programming • 4d ago

LeetCode Solution: 121. Best Time to Buy and Sell Stock
How-To

LeetCode Solution: 121. Best Time to Buy and Sell Stock

Dev.to Tutorial • 4d ago

The Feature Took 2 Hours to Build — and 2 Weeks to Fix
How-To

The Feature Took 2 Hours to Build — and 2 Weeks to Fix

Medium Programming • 4d ago

Discover More Articles