<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Contract-Oriented PL/SQL Coding</title>
	<atom:link href="http://technology.amis.nl/2007/03/14/contract-oriented-plsql-coding/feed/" rel="self" type="application/rss+xml" />
	<link>http://technology.amis.nl/2007/03/14/contract-oriented-plsql-coding/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=contract-oriented-plsql-coding</link>
	<description></description>
	<lastBuildDate>Fri, 12 Apr 2013 10:04:09 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
	<item>
		<title>By: Zlatko Sirotic</title>
		<link>http://technology.amis.nl/2007/03/14/contract-oriented-plsql-coding/#comment-4420</link>
		<dc:creator>Zlatko Sirotic</dc:creator>
		<pubDate>Tue, 20 Mar 2007 16:53:06 +0000</pubDate>
		<guid isPermaLink="false">http://technology.amis.nl/blog/?p=1736#comment-4420</guid>
		<description><![CDATA[I am sending mail to

info@amis.nl
Subject: mail for Alex Nuijten - Response to &quot;Contract-Oriented PL/SQL Coding&quot;


Best regards,
Zlatko Sirotic]]></description>
		<content:encoded><![CDATA[<p>I am sending mail to</p>
<p><a href="mailto:info@amis.nl">info@amis.nl</a><br />
Subject: mail for Alex Nuijten &#8211; Response to &#8220;Contract-Oriented PL/SQL Coding&#8221;</p>
<p>Best regards,<br />
Zlatko Sirotic</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alex Nuijten</title>
		<link>http://technology.amis.nl/2007/03/14/contract-oriented-plsql-coding/#comment-4419</link>
		<dc:creator>Alex Nuijten</dc:creator>
		<pubDate>Mon, 19 Mar 2007 12:31:36 +0000</pubDate>
		<guid isPermaLink="false">http://technology.amis.nl/blog/?p=1736#comment-4419</guid>
		<description><![CDATA[Thank you both for your comments.

Sorry about that, Zlatko, Apperently the formatting is lost when using comments... if you could mail the source to me, I could place it in the body of the post (of course with credits to you)]]></description>
		<content:encoded><![CDATA[<p>Thank you both for your comments.</p>
<p>Sorry about that, Zlatko, Apperently the formatting is lost when using comments&#8230; if you could mail the source to me, I could place it in the body of the post (of course with credits to you)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Zlatko Sirotic</title>
		<link>http://technology.amis.nl/2007/03/14/contract-oriented-plsql-coding/#comment-4418</link>
		<dc:creator>Zlatko Sirotic</dc:creator>
		<pubDate>Sat, 17 Mar 2007 22:14:32 +0000</pubDate>
		<guid isPermaLink="false">http://technology.amis.nl/blog/?p=1736#comment-4418</guid>
		<description><![CDATA[What happens with my code :)

Regards,
Zlatko Sirotic]]></description>
		<content:encoded><![CDATA[<p>What happens with my code <img src='http://technology.amis.nl/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Regards,<br />
Zlatko Sirotic</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Zlatko Sirotic</title>
		<link>http://technology.amis.nl/2007/03/14/contract-oriented-plsql-coding/#comment-4417</link>
		<dc:creator>Zlatko Sirotic</dc:creator>
		<pubDate>Sat, 17 Mar 2007 22:05:05 +0000</pubDate>
		<guid isPermaLink="false">http://technology.amis.nl/blog/?p=1736#comment-4417</guid>
		<description><![CDATA[Design by contract (DBC) is a method whose author is Bertrand Mayer, also maker of OOPL language Eiffel.
Simplified, DBC is based on principle that in each routine (procedure or function) with standard code,
two additional parts â€“ PRECONDITION and POSTCONDITION - need to be asserted.
An additional assertion in class is called INVARIANT.

Contract is based on routine&#039;s putting up an obligation to caller (to some other routine)
to satisfy conditions of precondition and conditions of invariant, and hers (called routine&#039;s) obligation
to satisfy conditions of postcondition and conditions of invariant.
The object oriented Eiffel programming language was created to implement DBC.

For now, other object-oriented languages donâ€™t support directly the ideas behind DBC.
However, precondition and postcondition are applicable to many programming languages, both object oriented and not OO.
Invariants are applicable only in OOPL.

This is my attempt to use DBC methodology (including invariants) in Oracle PL/SQL :)


Class interface from Bertrand Meyer&#039;s book &quot;Object oriented software construction&quot;, second edition (OOSC2), page 390-391:

class interface STACK [G]

creation make

feature -- Initialization
  make (n: INTEGER) is -- Alocate stack for a maximum of n elements
    require
      non_negative_capacity: n &gt;= 0
    ensure
      capacity_set: capacity = n
    end

feature -- Access
  capacity: INTEGER -- Maximum number of stack elements

  count: INTEGER -- Number of stack elements

  item: G is -â€“ Top element
    require
      not_empty: not empty
    end

feature -- Status report
  empty: BOOLEAN is â€“- Is stack empty?
    ensure
      empty_definition: Result = (count = 0)
    end

  full: BOOLEAN is â€“- Is stack full?
    ensure
      full_definition: Result = (count = capacity)
    end

feature -- Element change
  put (x: G) is â€“- Add x on top
    require
      not_full: not full
    ensure
      not_empty: not empty
      added_to_top: item = x
      one_more_item: count = old count + 1
    end

  remove is -â€“ Remove top element
    require
      not_empty: not empty
    ensure
      not_full: not full
      one_fewer: count = old count - 1
    end

invariant
  count_non_negative: 0 = 1 AND n = 2 AND capacity  n THEN
      dbc.display_error (&#039;stack - POST&#039;);
    END IF;

    check_invariants;
  END;

  MEMBER FUNCTION item (SELF IN OUT stack) RETURN INTEGER IS
  BEGIN
    IF dbc.checking_level &gt;= 1 AND empty THEN
      dbc.display_error (&#039;item - PRE&#039;);
    END IF;

    check_invariants;

    RETURN implement(el_count);
  END;

  MEMBER FUNCTION empty RETURN BOOLEAN IS
  BEGIN
    IF el_count = 0 THEN
      RETURN TRUE;
    ELSE
      RETURN FALSE;
    END IF;
  END;

  MEMBER FUNCTION full RETURN BOOLEAN IS
  BEGIN
    IF el_count = capacity THEN
      RETURN TRUE;
    ELSE
      RETURN FALSE;
    END IF;
  END;

  MEMBER PROCEDURE put (x INTEGER) IS
  BEGIN
    IF dbc.checking_level &gt;= 1 AND full THEN
      dbc.display_error (&#039;put - PRE&#039;);
    END IF;

    check_invariants;

    el_count := el_count + 1;
    implement(el_count) := x;

    -- PL/SQL has not Eiffel&#039;s OLD
    -- one_more_item: count = old count + 1
    IF dbc.checking_level &gt;= 2 AND (empty OR item  x) THEN
      dbc.display_error (&#039;put - POST&#039;);
    END IF;

    check_invariants;
  END;

  MEMBER PROCEDURE remove IS BEGIN
    IF dbc.checking_level &gt;= 1 AND empty THEN
      dbc.display_error (&#039;remove - PRE&#039;);
    END IF;

    check_invariants;

    el_count := el_count - 1;

    -- PL/SQL has not Eiffel&#039;s OLD
    -- one_fewer: count = old count - 1
    IF dbc.checking_level &gt;= 2 AND full THEN
      dbc.display_error (&#039;remove - POST&#039;);
    END IF;

    check_invariants;
  END;


  -- INVARIANTS

  MEMBER FUNCTION count_non_negative RETURN BOOLEAN IS
  BEGIN
    IF el_count &gt;= 0 THEN
      RETURN TRUE;
    ELSE
      RETURN FALSE;
    END IF;
  END;

  MEMBER FUNCTION count_bounded RETURN BOOLEAN IS
  BEGIN
    IF el_count  0)
    THEN
      RETURN TRUE;
    ELSE
      RETURN FALSE;
    END IF;
  END;

  MEMBER PROCEDURE check_invariants IS
  BEGIN
    IF dbc.checking_level]]></description>
		<content:encoded><![CDATA[<p>Design by contract (DBC) is a method whose author is Bertrand Mayer, also maker of OOPL language Eiffel.<br />
Simplified, DBC is based on principle that in each routine (procedure or function) with standard code,<br />
two additional parts â€“ PRECONDITION and POSTCONDITION &#8211; need to be asserted.<br />
An additional assertion in class is called INVARIANT.</p>
<p>Contract is based on routine&#8217;s putting up an obligation to caller (to some other routine)<br />
to satisfy conditions of precondition and conditions of invariant, and hers (called routine&#8217;s) obligation<br />
to satisfy conditions of postcondition and conditions of invariant.<br />
The object oriented Eiffel programming language was created to implement DBC.</p>
<p>For now, other object-oriented languages donâ€™t support directly the ideas behind DBC.<br />
However, precondition and postcondition are applicable to many programming languages, both object oriented and not OO.<br />
Invariants are applicable only in OOPL.</p>
<p>This is my attempt to use DBC methodology (including invariants) in Oracle PL/SQL <img src='http://technology.amis.nl/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Class interface from Bertrand Meyer&#8217;s book &#8220;Object oriented software construction&#8221;, second edition (OOSC2), page 390-391:</p>
<p>class interface STACK [G]</p>
<p>creation make</p>
<p>feature &#8212; Initialization<br />
  make (n: INTEGER) is &#8212; Alocate stack for a maximum of n elements<br />
    require<br />
      non_negative_capacity: n &gt;= 0<br />
    ensure<br />
      capacity_set: capacity = n<br />
    end</p>
<p>feature &#8212; Access<br />
  capacity: INTEGER &#8212; Maximum number of stack elements</p>
<p>  count: INTEGER &#8212; Number of stack elements</p>
<p>  item: G is -â€“ Top element<br />
    require<br />
      not_empty: not empty<br />
    end</p>
<p>feature &#8212; Status report<br />
  empty: BOOLEAN is â€“- Is stack empty?<br />
    ensure<br />
      empty_definition: Result = (count = 0)<br />
    end</p>
<p>  full: BOOLEAN is â€“- Is stack full?<br />
    ensure<br />
      full_definition: Result = (count = capacity)<br />
    end</p>
<p>feature &#8212; Element change<br />
  put (x: G) is â€“- Add x on top<br />
    require<br />
      not_full: not full<br />
    ensure<br />
      not_empty: not empty<br />
      added_to_top: item = x<br />
      one_more_item: count = old count + 1<br />
    end</p>
<p>  remove is -â€“ Remove top element<br />
    require<br />
      not_empty: not empty<br />
    ensure<br />
      not_full: not full<br />
      one_fewer: count = old count &#8211; 1<br />
    end</p>
<p>invariant<br />
  count_non_negative: 0 = 1 AND n = 2 AND capacity  n THEN<br />
      dbc.display_error (&#8216;stack &#8211; POST&#8217;);<br />
    END IF;</p>
<p>    check_invariants;<br />
  END;</p>
<p>  MEMBER FUNCTION item (SELF IN OUT stack) RETURN INTEGER IS<br />
  BEGIN<br />
    IF dbc.checking_level &gt;= 1 AND empty THEN<br />
      dbc.display_error (&#8216;item &#8211; PRE&#8217;);<br />
    END IF;</p>
<p>    check_invariants;</p>
<p>    RETURN implement(el_count);<br />
  END;</p>
<p>  MEMBER FUNCTION empty RETURN BOOLEAN IS<br />
  BEGIN<br />
    IF el_count = 0 THEN<br />
      RETURN TRUE;<br />
    ELSE<br />
      RETURN FALSE;<br />
    END IF;<br />
  END;</p>
<p>  MEMBER FUNCTION full RETURN BOOLEAN IS<br />
  BEGIN<br />
    IF el_count = capacity THEN<br />
      RETURN TRUE;<br />
    ELSE<br />
      RETURN FALSE;<br />
    END IF;<br />
  END;</p>
<p>  MEMBER PROCEDURE put (x INTEGER) IS<br />
  BEGIN<br />
    IF dbc.checking_level &gt;= 1 AND full THEN<br />
      dbc.display_error (&#8216;put &#8211; PRE&#8217;);<br />
    END IF;</p>
<p>    check_invariants;</p>
<p>    el_count := el_count + 1;<br />
    implement(el_count) := x;</p>
<p>    &#8212; PL/SQL has not Eiffel&#8217;s OLD<br />
    &#8212; one_more_item: count = old count + 1<br />
    IF dbc.checking_level &gt;= 2 AND (empty OR item  x) THEN<br />
      dbc.display_error (&#8216;put &#8211; POST&#8217;);<br />
    END IF;</p>
<p>    check_invariants;<br />
  END;</p>
<p>  MEMBER PROCEDURE remove IS BEGIN<br />
    IF dbc.checking_level &gt;= 1 AND empty THEN<br />
      dbc.display_error (&#8216;remove &#8211; PRE&#8217;);<br />
    END IF;</p>
<p>    check_invariants;</p>
<p>    el_count := el_count &#8211; 1;</p>
<p>    &#8212; PL/SQL has not Eiffel&#8217;s OLD<br />
    &#8212; one_fewer: count = old count &#8211; 1<br />
    IF dbc.checking_level &gt;= 2 AND full THEN<br />
      dbc.display_error (&#8216;remove &#8211; POST&#8217;);<br />
    END IF;</p>
<p>    check_invariants;<br />
  END;</p>
<p>  &#8212; INVARIANTS</p>
<p>  MEMBER FUNCTION count_non_negative RETURN BOOLEAN IS<br />
  BEGIN<br />
    IF el_count &gt;= 0 THEN<br />
      RETURN TRUE;<br />
    ELSE<br />
      RETURN FALSE;<br />
    END IF;<br />
  END;</p>
<p>  MEMBER FUNCTION count_bounded RETURN BOOLEAN IS<br />
  BEGIN<br />
    IF el_count  0)<br />
    THEN<br />
      RETURN TRUE;<br />
    ELSE<br />
      RETURN FALSE;<br />
    END IF;<br />
  END;</p>
<p>  MEMBER PROCEDURE check_invariants IS<br />
  BEGIN<br />
    IF dbc.checking_level</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Karl</title>
		<link>http://technology.amis.nl/2007/03/14/contract-oriented-plsql-coding/#comment-4416</link>
		<dc:creator>Karl</dc:creator>
		<pubDate>Fri, 16 Mar 2007 10:15:20 +0000</pubDate>
		<guid isPermaLink="false">http://technology.amis.nl/blog/?p=1736#comment-4416</guid>
		<description><![CDATA[Would it be nice to have this as real language feature like in Eiffel.
Another point arises here similar to this : programming with aspcects (intrude your own procedures /function with common sense code);
Wouldn&#039;t it be very nices features for PL/SQL
Karl]]></description>
		<content:encoded><![CDATA[<p>Would it be nice to have this as real language feature like in Eiffel.<br />
Another point arises here similar to this : programming with aspcects (intrude your own procedures /function with common sense code);<br />
Wouldn&#8217;t it be very nices features for PL/SQL<br />
Karl</p>
]]></content:encoded>
	</item>
</channel>
</rss>
