Forums

F.A.Q. F.A.Q.    Register Register    Login Login    Home Home
Search Search
SBML Discussions » jsbml-development » Errors for undefined elements
Show: Today's Posts  :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
AuthorTopic
Andreas Dräger


Posts: 273
Registered:
June 2006
Errors for undefined elements 30 Mar '11 10:41 Go to next message

Dear all,

Recently, Roland Keller detected the problem that if a mandatory
attribute of some element has not been defined, it is difficult to
predict the behavior of a method that is supposed to access this
property. Lucian Smith suggested to throw an Exception in case of, e.g.,
calling getPerstistent() while the persistent attribute has not been set
for Trigger with SBML Level 3. This is also what is now implemented.
However, maybe we should better consider to move one step away from
libSBML here and change the signature of methods like this in the way
that the return value is not longer boolean but Boolean. In other cases
it might be usefull to have the return value Integer instead of int etc.
We could then simply return null for an undefined property instead of
throwing an unexpected runtime exception. What do users or other people
think should be done when trying to access an undefined attribute in
some SBML element?

Best wishes
Andreas

--
Dipl.-Bioinform. Andreas Dräger
University of Tuebingen
Center for Bioinformatics Tuebingen (ZBIT)
Sand 1
72076 Tübingen
Germany

Phone: +49-7071-29-78982
Fax: +49-7071-29-5091
____________________________________________________________
To manage your jsbml-development list subscription, visit
https://utils.its.caltech.edu/mailman/listinfo/jsbml-development

For a web interface to the jsbml-development mailing list, visit
http://sbml.org/Forums/

For questions or feedback about the jsbml-development list,
contact sbml-team@caltech.edu

      
Mike Hucka


Posts: 961
Registered:
October 2003
Re: Errors for undefined elements 31 Mar '11 05:55 Go to previous messageGo to next message

On Wed, 30 Mar 2011 19:41:06 +0200, Andreas Draeger wrote:
> What do users or other people
> think should be done when trying to access an undefined attribute in
> some SBML element?

Sorry that I don't know this off-hand, but does jsbml also have the libSBML-style isFooSet() methods to query whether a given attribute has been set at all? Because if so, callers could use that to resolve the question of whether a boolean attribute was set in the model.

MH


____________________________________________________________
To manage your jsbml-development list subscription, visit
https://utils.its.caltech.edu/mailman/listinfo/jsbml-development

For a web interface to the jsbml-development mailing list, visit
http://sbml.org/Forums/

For questions or feedback about the jsbml-development list,
contact sbml-team@caltech.edu

      
Andreas Dräger


Posts: 273
Registered:
June 2006
Re: Errors for undefined elements 31 Mar '11 06:07 Go to previous messageGo to next message

>> What do users or other people
>> think should be done when trying to access an undefined attribute in
>> some SBML element?
>
> Sorry that I don't know this off-hand, but does jsbml also have the libSBML-style isFooSet() methods to query whether a given attribute has been set at all? Because if so, callers could use that to resolve the question of whether a boolean attribute was set in the model.

Hi Mike,

Yes, it does have this. However, it is still a bit strange to receive
either one of the following two things for a non-defined element:
* an excepetion by simply calling a get* method
* some value, although nothing is defined
Furthermore, it will probably confuse newbies: they'll call getSomething
and then won't understand that Something has not been defined.

Cheers
Andreas

--
Dr. Andreas Dräger
University of Tuebingen
Center for Bioinformatics Tuebingen (ZBIT)
Sand 1
72076 Tübingen
Germany

Phone: +49-7071-29-78982
Fax: +49-7071-29-5091
____________________________________________________________
To manage your jsbml-development list subscription, visit
https://utils.its.caltech.edu/mailman/listinfo/jsbml-development

For a web interface to the jsbml-development mailing list, visit
http://sbml.org/Forums/

For questions or feedback about the jsbml-development list,
contact sbml-team@caltech.edu

      
rodrigue


Posts: 307
Location:
Cambridge UK
Registered:
February 2005
Re: Errors for undefined elements 31 Mar '11 06:39 Go to previous messageGo to next message

Andreas Draeger wrote:
>>> What do users or other people
>>> think should be done when trying to access an undefined attribute in
>>> some SBML element?
>>>
>> Sorry that I don't know this off-hand, but does jsbml also have the libSBML-style isFooSet() methods to query whether a given attribute has been set at all? Because if so, callers could use that to resolve the question of whether a boolean attribute was set in the model.
>>
>
> Hi Mike,
>
> Yes, it does have this. However, it is still a bit strange to receive
> either one of the following two things for a non-defined element:
> * an exception by simply calling a get* method
>
That is not that bad. First, we are doing this a lot already for getter
methods.
And if the exception message explain to the user that he need to call
the isSet method before calling the get method
it should not be a problem.

> * some value, although nothing is defined
>
This is not what we want and the discussions about what behavior should
libsbml have in this cases concluded
that not value should be returned, I think.

* if we return Null, the user will also probably get a
NullPointerException if they did not read the documentation.

In the case of the method sending an exception, the exception message
will be display straight away with a clear explanation,
while a null value could provoke an error later on in the code of the
user that can be more difficult to track.

Nico

____________________________________________________________
To manage your jsbml-development list subscription, visit
https://utils.its.caltech.edu/mailman/listinfo/jsbml-development

For a web interface to the jsbml-development mailing list, visit
http://sbml.org/Forums/

For questions or feedback about the jsbml-development list,
contact sbml-team@caltech.edu

      
Andreas Dräger


Posts: 273
Registered:
June 2006
Re: Errors for undefined elements 31 Mar '11 07:19 Go to previous message

> In the case of the method sending an exception, the exception message
> will be display straight away with a clear explanation,
> while a null value could provoke an error later on in the code of the
> user that can be more difficult to track.

This sounds reasonable. So, we don't change anything here, but have to
identify step by step positions where we also have to throw excheptions
like this (besides Trigger).

Thanks to Mike, Nico and Lucian.
Andreas

--
Dr. Andreas Dräger
University of Tuebingen
Center for Bioinformatics Tuebingen (ZBIT)
Sand 1
72076 Tübingen
Germany

Phone: +49-7071-29-78982
Fax: +49-7071-29-5091
____________________________________________________________
To manage your jsbml-development list subscription, visit
https://utils.its.caltech.edu/mailman/listinfo/jsbml-development

For a web interface to the jsbml-development mailing list, visit
http://sbml.org/Forums/

For questions or feedback about the jsbml-development list,
contact sbml-team@caltech.edu

      
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic:Write to SBML
Next Topic:jsbml/parsing errors
Go to forum:
-=] Back to Top [=-

Powered by FUDforum. (Copyright Advanced Internet Designs Inc.)

Please use our issue tracking system for any questions or suggestions about this website.