First of all I'm developing a parser for an XML-based format for 3D graphics called XGL. But this question can be applied to any situation when you have fields in your class that are optional i.e. the value of this field can be missing.
As I was taking a Scala course on coursera there was an interesting pattern when you create an abstract class with all the methods you need and then create a normal fully functional subclass and an "empty" singleton subclass that always returns
isEmpty method and throws exceptions for the other ones.
So my question is: is it better to just assign
null if the optional field's value is missing or make a hierarchy described above and assign it an empty singleton implementation?