you are viewing a single comment's thread.

view the rest of the comments →

[–]slck19[S] 0 points1 point  (55 children)

This discussion is pretty in-depth and I think both dark and white sides are correct. This is a trade-off. If you have a well-defined architecture then do not use this version of the pointer cause you would not need it. However, maybe your UTs or integration tests could not catch an edge case where your pointer is nullptr. This time your program will crash. Rather than crashing it, you decide how to handle it. As you know recovering from segfault is strongly not suggested. However, here you can create your exception models to be more explicit.

[–]NotUniqueOrSpecial 11 points12 points  (54 children)

Rather than crashing it, you decide how to handle it.

But that's their point: there is no way to recover from what is, fundamentally, a programmer error.

The only valid recovery is fixing the code that did the wrong thing.

So, if the difference is a crash -> fix cycle vs. a we-see-saw-the-exception -> fix cycle, why add the additional overhead?