delphi - Why would you check for Assigned(self) in object methods? -
I'm looking at some code (Delphi 7) with which the following check is at the top of each method call for a specific object :
If not assigned (self) then take exception. CreateRes (@sAbstractError); {The actual code for this method}
I think it will stop me from trying to call a method on an empty object pointer. But as soon as I am in the case of member data Tried to reach, I will get an exception, is not it?
Is this some type of standard that I have never seen before? The object in question arises from TPersistent.
You can call an example method on an empty pointer, though it is not something that you knowingly When this happens, the execution continues to a great extent until it needs to reach the frequency data and then it all gets banged.
In that case, will alert you to the top of the screening process for zero, so that you do something different as a stack trace logging or you can put a break point on the lifting line so that you can enter it Can and see what is happening.
Ie, there was something that I could do if I had a specific bug that I was trying to track down, a zero reference was being used
It regularly kills me as a code odor.
Comments
Post a Comment