[prev in list] [next in list] [prev in thread] [next in thread] 

List:       ruby-talk
Subject:    Re: assertions in Ruby
From:       "Volkmann, Mark" <Mark.Volkmann () AGEDWARDS ! com>
Date:       2002-10-04 18:20:02
[Download RAW message or body]

> -----Original Message-----
> From: Jason Voegele [mailto:jason@jvoegele.com]
> Sent: Friday, October 04, 2002 9:30 AM
> To: ruby-talk@ruby-lang.org
> Subject: Re: assertions in Ruby
> 
> 
> Volkmann, Mark wrote:
> > Yes, I'm aware of RubyUnit.  I love it and use it 
> extensively!  However,
> > I think there is a place for assertions too.  Assertions 
> provide useful
> > documentation inside the code as opposed to be being in a 
> separate file
> > as I believe most unit tests are implemented.  My examples 
> demonstrated
> > another potential use of assertions which is to provide a 
> weak form of
> > type checking ... which of course has been a controversial 
> issue on the
> > mailing list in the past few weeks.
> 
> http://www.pragmaticprogrammer.com/ruby/downloads/dbc.html
> 
> It's an implementation of Design By Contract for Ruby put together (I
> believe) by Andy Hunt.  And although it should be viewed mostly as a
> prototype, it is directly usable and may inspire you to grow it into
> something greater.

DbC looks interesting, but it's also much more involved than the Java
Assertions API which is what I used as a model.

I have a basic assert method that accepts a boolean condition (similar to
the check method in DbC).  I also have a few variations of the assert method
for common kinds of assertions like verifying that an object responds to a
set of messages or is a kind of one of a set of classes.  These assertions
can be placed wherever they are appropriate.

DbC has three constructs that perform assertions at different points in a
method ... pre for the beginning, post for the end and check for places in
between.  There are also methods to determine the value of an expression
before the current method started (old) and to determine that a condition is
met at the end of executing every method in a class (invariant).  All of
this is interesting, but also may be overkill.  Obviously this is a matter
of opinion.  Sometimes simpler is better and this feels like one of those
times to me.

Another concern is that the date on the DbC documentation is August 2000,
the software is still marked as version 0.1 and the status on the web page
is "Alpha (i.e., use at your own risk)".


***********************************************************************************
WARNING:  All e-mail sent to and from this address will be received or
otherwise recorded by the A.G. Edwards corporate e-mail system and is
subject to archival, monitoring or review by, and/or disclosure to,
someone other than the recipient.
************************************************************************************

[Attachment #3 (text/html)]

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Generator" CONTENT="MS Exchange Server version 5.5.2653.12">
<TITLE>RE: assertions in Ruby</TITLE>
</HEAD>
<BODY>

<P><FONT SIZE=2>&gt; -----Original Message-----</FONT>
<BR><FONT SIZE=2>&gt; From: Jason Voegele [<A \
HREF="mailto:jason@jvoegele.com">mailto:jason@jvoegele.com</A>]</FONT> <BR><FONT \
SIZE=2>&gt; Sent: Friday, October 04, 2002 9:30 AM</FONT> <BR><FONT SIZE=2>&gt; To: \
ruby-talk@ruby-lang.org</FONT> <BR><FONT SIZE=2>&gt; Subject: Re: assertions in \
Ruby</FONT> <BR><FONT SIZE=2>&gt; </FONT>
<BR><FONT SIZE=2>&gt; </FONT>
<BR><FONT SIZE=2>&gt; Volkmann, Mark wrote:</FONT>
<BR><FONT SIZE=2>&gt; &gt; Yes, I'm aware of RubyUnit.&nbsp; I love it and use it \
</FONT> <BR><FONT SIZE=2>&gt; extensively!&nbsp; However,</FONT>
<BR><FONT SIZE=2>&gt; &gt; I think there is a place for assertions too.&nbsp; \
Assertions </FONT> <BR><FONT SIZE=2>&gt; provide useful</FONT>
<BR><FONT SIZE=2>&gt; &gt; documentation inside the code as opposed to be being in a \
</FONT> <BR><FONT SIZE=2>&gt; separate file</FONT>
<BR><FONT SIZE=2>&gt; &gt; as I believe most unit tests are implemented.&nbsp; My \
examples </FONT> <BR><FONT SIZE=2>&gt; demonstrated</FONT>
<BR><FONT SIZE=2>&gt; &gt; another potential use of assertions which is to provide a \
</FONT> <BR><FONT SIZE=2>&gt; weak form of</FONT>
<BR><FONT SIZE=2>&gt; &gt; type checking ... which of course has been a controversial \
</FONT> <BR><FONT SIZE=2>&gt; issue on the</FONT>
<BR><FONT SIZE=2>&gt; &gt; mailing list in the past few weeks.</FONT>
<BR><FONT SIZE=2>&gt; </FONT>
<BR><FONT SIZE=2>&gt; <A \
HREF="http://www.pragmaticprogrammer.com/ruby/downloads/dbc.html" \
TARGET="_blank">http://www.pragmaticprogrammer.com/ruby/downloads/dbc.html</A></FONT> \
<BR><FONT SIZE=2>&gt; </FONT> <BR><FONT SIZE=2>&gt; It's an implementation of Design \
By Contract for Ruby put together (I</FONT> <BR><FONT SIZE=2>&gt; believe) by Andy \
Hunt.&nbsp; And although it should be viewed mostly as a</FONT> <BR><FONT SIZE=2>&gt; \
prototype, it is directly usable and may inspire you to grow it into</FONT> <BR><FONT \
SIZE=2>&gt; something greater.</FONT> </P>

<P><FONT SIZE=2>DbC looks interesting, but it's also much more involved than the Java \
Assertions API which is what I used as a model.</FONT> </P>

<P><FONT SIZE=2>I have a basic assert method that accepts a boolean condition \
(similar to the check method in DbC).&nbsp; I also have a few variations of the \
assert method for common kinds of assertions like verifying that an object responds \
to a set of messages or is a kind of one of a set of classes.&nbsp; These assertions \
can be placed wherever they are appropriate.</FONT></P>

<P><FONT SIZE=2>DbC has three constructs that perform assertions at different points \
in a method ... pre for the beginning, post for the end and check for places in \
between.&nbsp; There are also methods to determine the value of an expression before \
the current method started (old) and to determine that a condition is met at the end \
of executing every method in a class (invariant).&nbsp; All of this is interesting, \
but also may be overkill.&nbsp; Obviously this is a matter of opinion.&nbsp; \
Sometimes simpler is better and this feels like one of those times to me.</FONT></P>

<P><FONT SIZE=2>Another concern is that the date on the DbC documentation is August \
2000, the software is still marked as version 0.1 and the status on the web page is \
&quot;Alpha (i.e., use at your own risk)&quot;.</FONT></P>

<CODE><FONT SIZE=3><BR>
<BR>
***********************************************************************************<BR>
                
WARNING:  All e-mail sent to and from this address will be received or<BR>
otherwise recorded by the A.G. Edwards corporate e-mail system and is<BR>
subject to archival, monitoring or review by, and/or disclosure to,<BR>
someone other than the recipient.<BR>
************************************************************************************<BR>
 </FONT></CODE></BODY>
</HTML>



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic