I'm new to UE4, and I encountered the general pattern of checking each pointer before using it, for example:
AActor *pActor = getOwner();
if(pActor){
pActor->SOME_FUNCTION();
}
I'm aware to the fact that crashes are awful in terms of user experience, and that it is always advised to write code with maximum robustness, but are there well-known cases in which the pattern is really useful? (for example in theoretically safe settings, such as a pointer set to GetOwner()
).
And if so, are there any common alternatives for this? (perhaps making use of smart pointers?)
EDIT: In my question I wanted to get an answer regarding UE4 specifically, since I encountered a source relating to UE4 only, which advised me to check pointers, although I wasn't sure about its necessity and in which pattern.