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
If your enums values are ordered, have a
First
andLast
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.Instead of big
switch
statements for ourenum
we can map them with the help of aDictionary
to a type and use polymorphism. A guide for better use of enums in C# part 2We can use the
dynamic
C# keyword, to create a more flexible visitor pattern. Using dynamic overloading in C# for a more flexible architectureOverload the
checked
operators in C# in your own types for boundary checking. Encapsulation of primitive types and checked operator overloading in C# 11How lists are implemented in C#, how to initialize them and how to get a
Span
from aList
: Initializing Lists in C#Learn which timer to use by understanding the differences between them in What are the differences in the timers in C#
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#
How to use the Null(or default) object pattern to avoid null reference exceptions: The Null object pattern in C#
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
Don’t use default parameters if you write code for libraries: Prefer overloading than default parameters
Get tuples with more than one values from a type by using the
Deconstruct
method: C# DeconstructorLearn 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
What is the order of Instantiation And Initialization of classes in C# and Unity
Learn when to use polymorphism with How To Properly Use Dynamic Polymorphism
Find out the different kinds of dependency injection in C# in Dependency Injection in C#
How conversions work in C# in Type Conversions And The Implicit and Explicit Operators In C#
Learn about Indices And Ranges in C#
Struct initialization in C# can be a source of hard to find bugs. Learn How To Ensure Correct Struct Initialization In C#
Learn about Collection Expressions in C# 12.
Find out the most efficient ways to perform string reversals with benchmarks in C# in Efficient String Reversal In C#
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
The new (.NET 9+) Alternate Lookup For Dictionary And HashSet With The IAlternateEqualityComparer
Unity Posts
Don’t depend on the execution order of
Awake
andOnEnable
for differentMonobehavior
scripts: Execution order of Awake and onEnable for different scripts in Unity is undefinedEasily handle and replace prefabs in your Unity project, with How to create a Database system to handle Unity prefabs
How to use enum flags and potential problems with Unity: What are enum flags and how to use them in Unity
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
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 UnityUse the
ScriptableWizard
class to easily create a quick editor tool in Unity: Unity Scriptable Wizard, what it is and how to use itHow 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
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 UpdateGet 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
An example of How To Create A Simple Spell System In Unity with scriptable objects.
Avoid crashing Unity and learn How To Use Loops Inside Unity’s Update Methods
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:
How to Asynchronously Instantiate Objects with InstantiateAsync In Unity
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
Communication between our classes by using different implementations of The Mediator Pattern In Unity
How to implement loot table probabilities with the help of MinMaxCurve And AnimationCurve
Audio randomization with Unity’s Audio Random Container: A Guide to Randomizing Audio in Unity
Replace null fields with default values automatically in Unity at compile time, with the help of Property Bags And Visitors
See how to use The Proxy Pattern In Unity
Find out Different Ways to Determine When an Event Occurred in Code
Learn about the Unity Behavior graph in this two part series:
Benchmark the performance of your code with Unity’s Performance Testing
Architectural Posts
Learn about static polymorphism with the help of Curiously Recurring Template Pattern in C#
What is the monostate pattern and how to use it instead of a singleton: The Monostate pattern with default interface implementation in C#
The difference between the command and strategy patterns: Command vs Strategy pattern
Bugs categorization depending on how they disrupt the user experience: 4 Ways To Deal With Bugs In a Program
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
What is temporal coupling and how to deal with it: How To Avoid Temporal Coupling in C#
Learn about the different kinds of encapsulation in C# in The Benefits Of Encapsulation With Examples In C#
Everything you might need about the SOLID principles, with explanations on when and how to use them in this 8-part series:
Don’t do one of the most annoying things in programming, avoid the “implied if statements” : What Are The Implied If Statements In Code
Learn about What Is Primitive Obsession And How To Avoid It
Learn about The Tell Don’t Ask Principle
All those different programming principles can be overwhelming, see How To Choose Between Conflicting Programming Principles
Learn about the resurrection pattern in Finalizers And The Resurrection Pattern In C#
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.