Luke’s Blog

Unity Software Design – Generalising and Specialising

usd_genspec

It’s a seemingly inherent desire in most programmers to make every solution as general as it possibly can be. That is to say, to design code such that it can handle almost any input, any situation. The attraction is obvious – design one amazing bit of code, and you can use it all over your…

Read More

Unity Software Design – Statics and State

usd_state

I’ve mentioned statics in the first post in this series, on Singletons, but there’s a bigger discussion to be had about this concept, and – more generally – the concept of “state”. Static Fields Static fields exists outside any particular instance of the object that declares them, and are thus shared between all instances of…

Read More

Unity Software Design – Factoring

usd_factoring

We’re finally back to the topic that prompted this whole thing. I didn’t want to start off by being too controversial, but I think you know what I’m about by now. So, even more than usual: OPINION WARNING! What is Factoring? First off – it’s not refactoring. That’s entirely separate[1]Refactoring, loosely, is rewriting code to…

Read More

Unity Software Design – Source Control

usd_sourceControl

As I noted in the first post in this series[1]or rather, in the footnotes – but if you read the footnotes you’ll already know that, and if you don’t then you’re not reading this either., Source Control, or Version Control, isn’t strictly a software design topic. But I’m going to argue – unlike specific patterns,…

Read More

Unity Software Design – Defensive Coding

DefensiveCoding

Defensive coding is the practice of making your code error-resistant. The idea is to make your code handle unexpected circumstances gracefully, rather than just going wrong or crashing. It’s a pretty broad topic, but in its simplest form means checking for invalid values or references before attempting to do things. For example, consider the following….

Read More

Unity Software Design – Inheritance and Composition

sdu_inheritance_composition

Inheritance is a big deal in object oriented programming. The ability to extend parent classes into subclasses, and have those subclasses be recognised as the parent (via polymorphism), is extremely powerful. It’s one of those Big Ideas that, once it clicks in your head, drastically changes how you think about coding. And if you’re not…

Read More

Unity Software Design – Encapsulation

use_encapsulation

The previous post was about a fairly specific “pattern” (Singletons). The topic this time is more of a general concept. Encapsulation, also known as Information Hiding, refers to designing code modularly, such that each part is as isolated from the others as possible. This doesn’t mean any one technique – it’s a broad engineering principle…

Read More

Unity Software Design – Singletons

blog_design_singletons

A recent debate on Twitter (on #UnityTips Tuesday) got me thinking. The vast majority of coding articles and tutorials for Unity (both official and third-party) are pretty specific. You get plenty of “How to Make a Space Shooter” or “How to Make Hitscan Weapons”, and almost none of “Minimising Coupling Between Classes” or “Writing Maintainable…

Read More

Unity Software Design – Introduction

This is a series of posts prompted by an observation – the vast majority of Unity tutorials and articles (official and third-party) teach how to use Unity, not how to design software. It’s easy to find, for example, specific help on “how to make a hitscan weapon in Unity”. And there’s plenty of abstract software…

Read More