Consolidated Collection of unresolved Exceptions/bugs?

I’m bumping into NullPointerExceptions and IndexOutOfRange exceptions left and right in this course even when trying to do exactly what Sam is doing in the course. I actually don’t know how Sam managed to get through some of these videos without triggering an exception on the video :slight_smile:

I’ve managed to figure out two of them and it looks like many people here did too. Does a consolidated list exist? It would be great to have a consolidated reference (no pun intended) of bugs to fix especially while the course is fresh in our heads.

If no list exists maybe we can start one:

  1. Attempting to get status on a quest you don’t have returns a null because we attempt to call IsComplete() on null This happens a lot on the condition checks in dialogue
    CompletedQuest

  2. Any dialogue that ends with the player turn returns an IndexOutOfRangeException because PlayerConversant.Next() attempts to get the an element out of an array that has 0 elements.
    Index out of range exception

I like these courses a lot but there are three main categories of feedback for making them better.

  1. Would like to see better habits with checking null values and boundary conditions
  2. I am not expecting bug-free code. It would be great if each course had a forum post maintained by gamedev.tv containing all the unresolved bugs and their fixes in a consolidated spot.
  3. It would be great if some of these gnarly bugs were selected for examples of how to write unit tests and regression tests in Unity. I have explored this a tiny bit and it’s non-obvious how to do this Unity.

There is not currently a list, no. I’ll admit, I’ve probably been lax in that, basically putting out fires as they crop up. Essentially, I serve as the fix when these issues come up. Some students spot the issues and apply common remedies even as Sam is typing the code (my version of the DAQ project, for example, did not encounter either of the two bugs you mentioned, and that was actually a problem when I was helping students… I’d already patched the bugs before they existed in my project, but when I went to the course project, I could see what was happening).

You’re quite right that we don’t mention a lot of basic error checking at this point in the course series. A lot of assumptions are made, and if those assumptions are true, your code can look error free when it’s not.

Heres’ a couple rules I recommend following in -=any=- course, and more importantly, as you progress in your own coding in -=any=- project you work on:

  • If it can be null, it must be null checked. Any reference value should be null checked unless you have a concrete way of ensuring it is not. Lists, for example, can be initialized at declaration, ensuring that they won’t be null. Receving a list by reference from a method, on the other hand has no such guarantee, especially if that method is public.
  • Every subscription to an event via code should generally be unsubscribed to in OnDisable or OnDestroy depending on where you subscribe. The exception to this is when you can guarantee that there will be no null call of the event, like in a button you know you’ll be destroying as soon as the next choice is made.
  • Component references should be cached in Awake(), not Start() to minimize race conditions.
  • Do not ACT on those component references until Start() or Update()

Unit Testing in general is a course I would love to see (though at this stage, it’s likely I’d have to be the one to write it, and you might be my only student). While outside of Unity, Unit Testing is a profoundly universal concept, it’s sorely underutilized within Unity, and Unity’s documentation assumes you already understand how Unit Testing works to begin with, so it isn’t very friendly to new programmers.

Brian - you’re one of the reasons I keep coming back to gamedev.tv. Every now and then I’ll do a google search to figure out how to do something (Property Drawers was a recent one) and a good chunk of the time I’ll run into your “tips and tricks.” I don’t know where you find the time! :slight_smile: There’s so much good stuff on here.

I try to do this too but with DAQ it’s been hard. In DAQ, I’ve been marking things with //TODO: then moving on hoping it would be easier to integrate the future lessons or tips-and-tricks if I hold off my customization until the end. I have a huge TODO list for DAQ compared to the preceding courses. :grimacing:

lol! I figure it’s so critical for when we start making major personalization and modification to make sure we don’t break anything. In lieu of proper unit tests, I have basic error checking methods that are called inline within the methods that perform the tasks. I’m sure it’s not great for performance but it feels the appropriate tradeoff for my limited skillset.


Anyway - Since there’s no list I’d like to keep this thread open a few days and see if the community can append to my list.

I’ve converted this to a Talk so it doesn’t clog up the Ask channel and tagged it for all four courses.

1 Like

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.

Privacy & Terms