Preconditions, postconditions and assertions

The use of specific JADE features and proposals for new feature suggestions
ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Preconditions, postconditions and assertions

Postby ConvertFromOldNGs » Fri Aug 07, 2009 10:51 am

by johnmunro >> Tue, 21 May 2002 10:07:02 GMT

Does anyone know how likely it is for preconditions, postconditions and assertions to be incorporated into Jade? They are extremely useful coding structures (yes, I learned OOP on Eiffel). I am currently doing assertions myself, by placing the following method on Object:

assert(assertCondition : Boolean);

vars
tmpException : AssertionException;
begin

if not assertCondition then
create tmpException;

tmpException.errorCode := UserException_AssertionFailed;
tmpException.errorItem := "Assertion Failed";
tmpException.continuable := false;
tmpException.resumable := false;
tmpException.extendedErrorText := "Assertion Failed";
tmpException.kind := '0';

raise tmpException;
endif;

end;

which works fine, but without a precondition structure built in, it results in the starts of all my methods being a big list of assertions undivided from the main method body. I assume the epilog is ok to put more assertions in as postconditions...

Having searched the newsgroups I found another thread about preconditions, postconditions and assertions from February 2001, in which Dean implies that they could be added in, which hopefully means it's more likely...

Anyway, that's my new feature suggestion: build preconditions, postconditions and assertions into Jade.

--
John Munro
Synergist Limited - Home of FileVisionT
The Bioscience Innovation Centre
Cowley Road, Cambridge, UK
CB4 0DS
Telephone: +44 (0) 1223 478200
Fax: +44 (0) 1223 477969
Email: john.munro@filevision.com
Web: http://www.filevision.com
The contents of this communication are confidential and are only intended to be read by the addressee. We apologize if you receive this communication in error and ask that you contact Synergist Limited immediately to arrange for its return. The use of any information contained in this communication by an unauthorized person is strictly prohibited. Synergist Limited cannot accept responsibility for the accuracy or completeness of this communication as it is being transmitted over a public network. If you suspect this message may have been intercepted or amended, please inform Synergist Limited.

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Preconditions, postconditions and assertions

Postby ConvertFromOldNGs » Fri Aug 07, 2009 10:51 am

by CarlRanson >> Mon, 15 Jul 2002 23:46:10 GMT

I agreee that it would be a fantastic addition to the languague.

Especially if:
pre & post conditions & class invariants inherited independantly of source code.
compliler allows for them to be compiled out easily if necessary.

the first point is a very important one that I didn't get until i had been reading about Eiffel for a while, as it allows an abstract class to include a specification of the behaviour that subclasses can't reimplement.

CR

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Preconditions, postconditions and assertions

Postby ConvertFromOldNGs » Fri Aug 07, 2009 10:51 am

by PWCDEMO >> Thu, 22 Aug 2002 7:18:04 GMT

Another great idea.

Maybe the Jade Support people could mark these so that we know whether or not they have been submitted to the JADE Plant?

- Chris

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Preconditions, postconditions and assertions

Postby ConvertFromOldNGs » Fri Aug 07, 2009 10:51 am

by johnmunro >> Tue, 10 Sep 2002 9:28:41 GMT

I have raised this as an NFS, but I would think that the more people rise it with Jade the more likely it is to happen...

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Preconditions, postconditions and assertions

Postby ConvertFromOldNGs » Fri Aug 07, 2009 10:51 am

by JensRichnow >> Mon, 27 Jan 2003 1:42:37 GMT

Recently I came across an article about the "Design by Contract" pattern in a Java Book ("More Java Gems", pp.69: "Prevention is Better than Cure") which deals with the problem you are talking about. Java lacks also the notion of pre- and postconditions as well as assertion (although an assert is implemented in the last Java release.

I had a look around in the web and there are many very good articles and implementation of this pattern, many dealing also with inheritance and, like in Eiffel, the selective inheritance of pre- and post-conditions. I was playing around with a few implementations of DBC in Jade and it works fine (having scratched the surface only currently).

So, while it would be good that Jade directly supports pre- and post-conditions as well as assertions, there are good design patterns (the Contract Pattern by Michele de Champlain at the University of Canterbury is a variation of DBC and was submitted to PLoP '97) which work fine for languages lacking the useful feature in Eiffel.

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Preconditions, postconditions and assertions

Postby ConvertFromOldNGs » Fri Aug 07, 2009 10:51 am

by JensRichnow >> Mon, 27 Jan 2003 1:51:10 GMT

For those who are not content with the articles posted in the Internet, I just came across a book review for "Design by Contract, By Example" in the latest online "Journal oi Object Technology" @

http://www.jot.fm/books/review4

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Preconditions, postconditions and assertions

Postby ConvertFromOldNGs » Fri Aug 07, 2009 10:51 am

by CarlRanson >> Mon, 27 Jan 2003 3:35:52 GMT

Im curious, how does a end user implementation deal with the inheritance of pre & post conditions independanlty of the method code?
C


Return to “Feature Discussions”

Who is online

Users browsing this forum: No registered users and 3 guests