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 Heemstra9h 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
0 views

Related Articles

How-To

The Hidden Magic (and Monsters) of Go Strings: Zero-Copy Slicing & Builder Secrets

Medium Programming • 44m ago

Why Watching Tutorials Won’t Make You a Good Programmer
How-To

Why Watching Tutorials Won’t Make You a Good Programmer

Medium Programming • 3h ago

The Code That Makes Rockets Fly
How-To

The Code That Makes Rockets Fly

Medium Programming • 4h ago

Spotify tests letting users directly customize their Taste Profile
How-To

Spotify tests letting users directly customize their Taste Profile

The Verge • 5h ago

How to Add Face Search to Your App
How-To

How to Add Face Search to Your App

Dev.to Tutorial • 5h ago

Discover More Articles