Is that allowed or not? For example I have a method getName()
that returns string, but what should I return if name is not set?
As far as I am aware there isn't any rule in DDD, preventing a DTO of returning Null value from a getter.
Personally I handle the Null values sourcing in DTO in a level closer to the Client/View.
So for example, if I build an MVC web app using DDD, in my interface I will have:
This way you ensure that the client will need to handle the Null value.