A Quick Reference to Key Topics on C# and Unity Covered in My Blog

Posted by : on

Category : C#   Unity   Architecture

Introduction

In this post, I’ve compiled links to my most significant blog articles from the past two years. My goal is to create a quick reference guide to what I consider my most valuable posts, both for myself and anyone interested.

For easier navigation, this post is divided into three sections: C# Posts, Unity Posts, and Architectural Posts.

C# Posts

  1. If your enums values are ordered, have a First and Last value with integer values the same as your first and last enum values. This way you don’t have to hardcode them. This can make refactoring easier. See A guide for better use of enums in C# part 1.

  2. Instead of big switch statements for our enum we can map them with the help of a Dictionary to a type and use polymorphism. A guide for better use of enums in C# part 2

  3. We can use the dynamic C# keyword, to create a more flexible visitor pattern. Using dynamic overloading in C# for a more flexible architecture

  4. Overload the checked operators in C# in your own types for boundary checking. Encapsulation of primitive types and checked operator overloading in C# 11

  5. How lists are implemented in C#, how to initialize them and how to get a Span from a List: Initializing Lists in C#

  6. Learn which timer to use by understanding the differences between them in What are the differences in the timers in C#

  7. Avoid the boxing of structs that implement an interface when passing them as a parameter to a method by using generics: How to avoid boxing structs that implement interfaces in C#

  8. How to use the Null(or default) object pattern to avoid null reference exceptions: The Null object pattern in C#

  9. See different usages of extension methods, other than extending types that we don’t own the code in 4 Ways To Use Extension Methods In C# Other Than Extending Existing Types

  10. Don’t use default parameters if you write code for libraries: Prefer overloading than default parameters

  11. Get tuples with more than one values from a type by using the Deconstruct method: C# Deconstructor

  12. Learn everything you might need to know (and more) about equality and comparisons in C#, in this three-part series: Part 1, part 2, part 3

  13. Use Primary Constructors in C# 12

  14. What is the order of Instantiation And Initialization of classes in C# and Unity

  15. Learn when to use polymorphism with How To Properly Use Dynamic Polymorphism

  16. Find out the different kinds of dependency injection in C# in Dependency Injection in C#

  17. How conversions work in C# in Type Conversions And The Implicit and Explicit Operators In C#

  18. What are Indexers and how to use them in C#

  19. Learn about Indices And Ranges in C#

  20. Struct initialization in C# can be a source of hard to find bugs. Learn How To Ensure Correct Struct Initialization In C#

  21. Learn about Collection Expressions in C# 12.

  22. Find out the most efficient ways to perform string reversals with benchmarks in C# in Efficient String Reversal In C#

  23. See how you can have a type that can be true and false at the same time in C#, with a code example that creates a “Schrödinger’s cat” type in A Deep Dive Into Boolean Operator Overloading

  24. The new (.NET 9+) Alternate Lookup For Dictionary And HashSet With The IAlternateEqualityComparer

Unity Posts

  1. Don’t depend on the execution order of Awake and OnEnable for different Monobehavior scripts: Execution order of Awake and onEnable for different scripts in Unity is undefined

  2. Easily handle and replace prefabs in your Unity project, with How to create a Database system to handle Unity prefabs

  3. How to use enum flags and potential problems with Unity: What are enum flags and how to use them in Unity

  4. Learn how to use encryption to prevent changes to your save files in Unity How to prevent external changes to your save files in Unity

  5. Add or remove systems to Unity’s game loop, by using the low-level PlayerLoop class in How to create an early and a super late update in Unity

  6. Use the ScriptableWizard class to easily create a quick editor tool in Unity: Unity Scriptable Wizard, what it is and how to use it

  7. How to find the destination of an object that will rotate any number of degrees around a certain point: How to move around a point in straight lines in Unity

  8. A system that uses mod and own update methods to improve the performance of Unity’s update: How to improve performance of conditional execution in Update

  9. Get a simple program that shows the performance cost of different Unity’s expensive calls and how compare with each other in both Unity’s update and by using your own update methods in: What is the performance cost of expensive calls in Unity’s Update

  10. An example of How To Create A Simple Spell System In Unity with scriptable objects.

  11. Avoid crashing Unity and learn How To Use Loops Inside Unity’s Update Methods

  12. How to calculate modifiers in stats and an implementation of a stat system in Unity with the full code in a github repository, plus the difference between stats and resources in this three-part series:

  13. How to Asynchronously Instantiate Objects with InstantiateAsync In Unity

  14. How to use the new (Unity 6+) Awaitable in Asynchronous Code In Unity Using Awaitable and AwaitableCompletionSource plus learn how you can await anything in Await Anything In Unity With AwaitableCompletionSource And Custom Awaiters and how to create your own custom async return types for usage in Unity with How To Create Custom Async Return Types In Unity

  15. Communication between our classes by using different implementations of The Mediator Pattern In Unity

  16. How to implement loot table probabilities with the help of MinMaxCurve And AnimationCurve

  17. Audio randomization with Unity’s Audio Random Container: A Guide to Randomizing Audio in Unity

  18. Replace null fields with default values automatically in Unity at compile time, with the help of Property Bags And Visitors

  19. See How To Use The Decorator Pattern In Unity

  20. See how to use The Proxy Pattern In Unity

  21. Find out Different Ways to Determine When an Event Occurred in Code

  22. Learn about the Unity Behavior graph in this two part series:

  23. See Various Timer Implementations in Unity

  24. Benchmark the performance of your code with Unity’s Performance Testing

Architectural Posts

  1. Learn about static polymorphism with the help of Curiously Recurring Template Pattern in C#

  2. What is the monostate pattern and how to use it instead of a singleton: The Monostate pattern with default interface implementation in C#

  3. The difference between the command and strategy patterns: Command vs Strategy pattern

  4. The Template Method Pattern and Usage in Unity

  5. Bugs categorization depending on how they disrupt the user experience: 4 Ways To Deal With Bugs In a Program

  6. The three kinds of dependency our types can have and subtypes in each one: 3 Ways To Create Dependencies Between Classes: Inheritance, Composition And Parameterization

  7. What is temporal coupling and how to deal with it: How To Avoid Temporal Coupling in C#

  8. Learn about the different kinds of encapsulation in C# in The Benefits Of Encapsulation With Examples In C#

  9. Everything you might need about the SOLID principles, with explanations on when and how to use them in this 8-part series:

  10. Don’t do one of the most annoying things in programming, avoid the “implied if statements” : What Are The Implied If Statements In Code

  11. Learn about What Is Primitive Obsession And How To Avoid It

  12. Learn about The Tell Don’t Ask Principle

  13. All those different programming principles can be overwhelming, see How To Choose Between Conflicting Programming Principles

  14. Learn about the resurrection pattern in Finalizers And The Resurrection Pattern In C#

  15. The Principle Of Least Astonishment with examples.

Conclusion

Over the past two years, I’ve covered a wide range of topics across my 100 blog posts. If you’re curious about my experience running a programming blog, check out my previous post, Two Years and 100 Programming Blog Posts: Lessons Learned.

In my next post, I’ll continue exploring various aspects of C#, Unity, and code architecture, just as before. See you then, and have a Happy New Year!

As always, thank you for reading and if you have any questions or comments you can use the comments section, or contact me directly via the contact form or by email. Also, if you don’t want to miss any of the new blog posts, you can subscribe to my newsletter or the RSS feed.


Follow me: