<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/don-t-let-these-4-code-smells-ruin-your-unity-game-psebpvq2j" -->

---
title: Don’t Let These 4 Code Smells Ruin Your Unity Game
description: Four common code smells in Unity C# projects are identified and refactored: temporary field (data only needed sometimes, fixed by extracting a class and using...
canonical: https://daily.dev/posts/don-t-let-these-4-code-smells-ruin-your-unity-game-psebpvq2j
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Don’t Let These 4 Code Smells Ruin Your Unity Game | daily.dev
og:description: Four common code smells in Unity C# projects are identified and refactored: temporary field (data only needed sometimes, fixed by extracting a class and using...
og:url: https://daily.dev/posts/don-t-let-these-4-code-smells-ruin-your-unity-game-psebpvq2j
og:image: https://api.daily.dev/og/posts/psebPvQ2j.png
og:image:alt: Don’t Let These 4 Code Smells Ruin Your Unity Game
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Don’t Let These 4 Code Smells Ruin Your Unity Game

**[git-amend](https://daily.dev/sources/git-amend)** · 14 min read · 0 upvotes · 0 comments

## Summary

Four common code smells in Unity C# projects are identified and refactored: temporary field (data only needed sometimes, fixed by extracting a class and using the null object pattern), switch statements (long conditionals replaced with polymorphism and composition), shotgun surgery (duplicated logic scattered across classes consolidated into a single source of truth via a policy interface), and refused bequest (subclasses forced to inherit unused members, fixed by replacing inheritance with composition). Each example is walked through with practical refactoring steps using ReSharper/Rider tooling, drawing on Martin Fowler's Refactoring book adapted for Unity game development.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://www.youtube.com/watch?v=fPZB8oLLcRU>

## Similar posts on daily.dev

- [From Unity Prototypes to Production Pipelines: Growing Into C\#](https://daily.dev/posts/from-unity-prototypes-to-production-pipelines-growing-into-c--puxb9vfzc) · Atomic Spin · 3 upvotes · 0 comments

---

Tags: [#c#](https://daily.dev/tags/c#), [#unity](https://daily.dev/tags/unity), [#design-patterns](https://daily.dev/tags/design-patterns)

[View this post on daily.dev](https://daily.dev/posts/don-t-let-these-4-code-smells-ruin-your-unity-game-psebpvq2j)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Don’t Let These 4 Code Smells Ruin Your Unity Game","url":"https://daily.dev/posts/don-t-let-these-4-code-smells-ruin-your-unity-game-psebpvq2j","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/don-t-let-these-4-code-smells-ruin-your-unity-game-psebpvq2j"},"datePublished":"2026-07-19T07:59:06.839Z","dateModified":"2026-07-19T08:25:54.361Z","description":"Four common code smells in Unity C# projects are identified and refactored: temporary field (data only needed sometimes, fixed by extracting a class and using...","image":"https://i.ytimg.com/vi/fPZB8oLLcRU/sddefault.jpg","thumbnailUrl":"https://i.ytimg.com/vi/fPZB8oLLcRU/sddefault.jpg","isAccessibleForFree":true,"articleSection":"git-amend","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"git-amend","logo":"https://media.daily.dev/image/upload/s--dR-FewbM--/f_auto,q_auto/v1784447928/logos/git-amend?_a=BAMAMicg0","url":"https://daily.dev/sources/git-amend"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/don-t-let-these-4-code-smells-ruin-your-unity-game-psebpvq2j","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"c#,unity,design-patterns","timeRequired":"PT14M","video":{"@type":"VideoObject","name":"Don’t Let These 4 Code Smells Ruin Your Unity Game","description":"Four common code smells in Unity C# projects are identified and refactored: temporary field (data only needed sometimes, fixed by extracting a class and using...","thumbnailUrl":"https://i.ytimg.com/vi/fPZB8oLLcRU/sddefault.jpg","uploadDate":"2026-07-19T07:59:06.839Z","duration":"PT14M","url":"https://api.daily.dev/r/psebPvQ2j","embedUrl":"https://www.youtube.com/embed/fPZB8oLLcRU"}}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"git-amend","item":"https://daily.dev/sources/git-amend"},{"@type":"ListItem","position":3,"name":"Don’t Let These 4 Code Smells Ruin Your Unity Game"}]}
```

