Passing a nil FolderItem to FolderItem.MoveFileTo results in a NilObjectException. This is either a bug, or is working by design, but is undocumented. I filed a bug report <http:// www.realsoftware.com/feedback/viewreport.php?reportid=ddaggcfz> to which the following evaluation was added.

"This is behaving by design. You're passing in nil; what do you expect to happen? The exception is an appropriate way to alert you of the error."

What I would expect to happen is that the method would simply return and set an error value in FolderItem.LastErrorCode, in keeping with the design of the FolderItem class, as well as much of the REALbasic framework. There is no reason to raise an exception, because it's easy for MoveFileTo to know how to handle a nil parameter -- set an error code and return -- and it is easy to check whether or not the method succeeded by testing the Exists property of both the FolderItem objects involved.

But, assuming arguendo that raising an exception is a reasonable response, it should be documented because the raising of an exception is then part of the method interface, as with, say, Dictionary.Remove. And a NilObjectException is semantically ill- chosen. According to the REALbasic documentation, "A NilObjectException occurs when you use a property or variable to access an object that doesn't exist.". Here, the problem is that one has passed a parameter that the method refuses to accept; in DBC terms, it's a precondition violation. So the proper response would be for REALbasic to define a RuntimeException subclass that captures such a notion, and raise an instance of it here.

Charles Yeomans
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to