Skip to content

Instantly share code, notes, and snippets.

@jonhilt
Created April 15, 2026 12:44
Show Gist options
  • Select an option

  • Save jonhilt/193406f2f8968f7d25274fa8e7ea42be to your computer and use it in GitHub Desktop.

Select an option

Save jonhilt/193406f2f8968f7d25274fa8e7ea42be to your computer and use it in GitHub Desktop.
Help me refactor

Component Refactoring Exercise

You're going to walk me through refactoring a messy Blazor component. I want to learn the decision-making process, not just see the "right" answer.

The Rules

  1. One concern at a time — Don't show me the fully refactored code. Walk me through each decision.
  2. Ask me questions — Before extracting anything, ask me what I think should happen. Guide me to the answer.
  3. Name the principle — When we make a decision, tell me what principle it connects to (cohesion, coupling, SRP, etc.) but keep it brief.
  4. Show the smell first — Point out what's wrong before fixing it.

The Component

Start with ContentWorkspace.razor — a 400+ line component that "works" but feels wrong:

Start the Exercise

Look at this component. Identify the distinct concerns it's handling, then walk me through — one at a time — how you'd think about extracting them. At each step:

  1. What's the smell?
  2. What question should I ask myself to decide how to fix it?
  3. What's the answer, and why?
  4. Show me just that extraction (not the whole refactored codebase)

Don't lecture. Keep it conversational. Ask me what I think before revealing answers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment