02-13-2017 01:43 PM
@JÞB wrote:
A Local (or Global) variable to a reference just sounds like a really bad idea. If you really need to avoid the wire an Action Engine with Open / Get / Close methods sounds a whole lot safer and a darn sight easier to debug.
And...
Include a flag in the internal data stored in the AE that indicates if the refrence has been closed. If any operation requiring a valid references is attempted while the flag indicates the reference has been closed is is invalid, you can return a error message to the caller clearly spelling out why the invocation failed.
If I am going to write code that others will use, I try to write it such that it warns them when they are not playing by the rules with error messages.
Just my 2 cents,
Ben
02-13-2017 02:48 PM
Ben wrote:
Include a flag in the internal data stored in the AE that indicates if the refrence has been closed. If any operation requiring a valid references is attempted while the flag indicates the reference has been closed is is invalid, you can return a error message to the caller clearly spelling out why the invocation failed.
1. You will already get an error when you try to use the invalid reference.
2. What if somebody closes the reference outside of the AE? Now your flag is invalid.
So I guess the point I am trying to make here is that your flag will work as long as the reference does not leave the Action Engine. Otherwise, all bets are off. And if you say that you can check to see if the reference is valid first, go talk to Fab and Mercer. They actually found a race condition where a queue reference was closed between the checking for a valid reference and enqueuing an item (got error code 1).
02-13-2017 02:53 PM
I aggree crosrulz about keeping the reference encapsulated in the AE.
There error message could be alittle more robust than the standard that will simply say the ref is invalid and could read as "You already closed the references!" or "The ref has nver been opened, make sure you open it first!"
The intent is to keep others from misusing the code I develop and let them quickly learn where and how the screwed up.
Ben
02-13-2017 05:54 PM
@Ben wrote:
I aggree crosrulz about keeping the reference encapsulated in the AE.
The intent is to keep others from misusing the code I develop and let them quickly learn where and how the screwed up.
Ben
Ideally, any action taken on the reference would be contained in a method of the AE (And, do "Goto Nirvana" by wrapping the methods as a public API) Thais keeps the follow-on developers honest. Of course, some developer is going to grab their own ref to the object and write a nice bug. You can laugh at them after they admit they did that and wasted a bunch of time tracking down their error.