asOid() return is an invalid object
Posted: Tue Aug 01, 2017 11:25 am
I have just realised that the asOid() method always returns an object even if it is not valid
This to me doesn't make any sense. Why does Jade not just return a null like all other methods? For example calling getAtKey would return a null not an invalid object.
So, if you have any code that is just doing a null check after an asOid this is pointless because there is always going to be an object after using the asOid method, whether it is valid or not is the only check you should be doing.
I feel as though this is a fault but would be interested to know if others agree before I log this in Parsys.
Code: Select all
vars
currOid : String;
jadeSkin : JadeSkin;
begin
currOid := "525.1"; //This is an invalid oid.
jadeSkin := currOid.asOid().JadeSkin;
if not app.isValidObject(jadeSkin) then
write "**INVALID OBJECT**";
endif;
if jadeSkin <> null then
write "but this is also not null????";
endif;
end;
So, if you have any code that is just doing a null check after an asOid this is pointless because there is always going to be an object after using the asOid method, whether it is valid or not is the only check you should be doing.
I feel as though this is a fault but would be interested to know if others agree before I log this in Parsys.