<?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: Two controllers, type conformance and the Liskov Substitution Principle</title>
	<atom:link href="http://www.markhneedham.com/blog/2009/11/19/two-controllers-type-conformance-and-the-liskov-substitution-principle/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.markhneedham.com/blog/2009/11/19/two-controllers-type-conformance-and-the-liskov-substitution-principle/</link>
	<description>Thoughts on Software Development</description>
	<lastBuildDate>Sat, 11 Feb 2012 23:17:00 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: domenico</title>
		<link>http://www.markhneedham.com/blog/2009/11/19/two-controllers-type-conformance-and-the-liskov-substitution-principle/comment-page-1/#comment-27370</link>
		<dc:creator>domenico</dc:creator>
		<pubDate>Sun, 29 Nov 2009 13:15:26 +0000</pubDate>
		<guid isPermaLink="false">http://www.markhneedham.com/blog/?p=1847#comment-27370</guid>
		<description>I think that if we agree on that arguments values are part of a precondition the situation is more clear:

1. &quot;Preconditions can be modified in redefined routines, but they may only be weakened[2]. That is, the redefined routine may lessen the obligation of the client, but not increase it.&quot;

http://en.wikipedia.org/wiki/Precondition

2. &quot;* Preconditions cannot be strengthened in a subtype.
    * Postconditions cannot be weakened in a subtype.
    * Invariants of the supertype must be preserved in a subtype.
    * History constraint (the &quot;history rule&quot;)... &quot; 

http://en.wikipedia.org/wiki/Behavioral_subtyping

So I agree with Zubair Khan and, personally, i would change the base class contract to throw an exception in presence of null arguments.</description>
		<content:encoded><![CDATA[<p>I think that if we agree on that arguments values are part of a precondition the situation is more clear:</p>
<p>1. &#8220;Preconditions can be modified in redefined routines, but they may only be weakened[2]. That is, the redefined routine may lessen the obligation of the client, but not increase it.&#8221;</p>
<p><a href="http://en.wikipedia.org/wiki/Precondition" rel="nofollow">http://en.wikipedia.org/wiki/Precondition</a></p>
<p>2. &#8220;* Preconditions cannot be strengthened in a subtype.<br />
    * Postconditions cannot be weakened in a subtype.<br />
    * Invariants of the supertype must be preserved in a subtype.<br />
    * History constraint (the &#8220;history rule&#8221;)&#8230; &#8221; </p>
<p><a href="http://en.wikipedia.org/wiki/Behavioral_subtyping" rel="nofollow">http://en.wikipedia.org/wiki/Behavioral_subtyping</a></p>
<p>So I agree with Zubair Khan and, personally, i would change the base class contract to throw an exception in presence of null arguments.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mark Needham</title>
		<link>http://www.markhneedham.com/blog/2009/11/19/two-controllers-type-conformance-and-the-liskov-substitution-principle/comment-page-1/#comment-26944</link>
		<dc:creator>Mark Needham</dc:creator>
		<pubDate>Thu, 19 Nov 2009 17:23:49 +0000</pubDate>
		<guid isPermaLink="false">http://www.markhneedham.com/blog/?p=1847#comment-26944</guid>
		<description>Yeh that&#039;s interesting. In reality neither of those is likely to be null but it seemed like something interesting!

If I understand what you&#039;re saying correctly then we should make MoreSpecificController handle the null situation without throwing a Null Pointer Exception? Makes sense.</description>
		<content:encoded><![CDATA[<p>Yeh that&#8217;s interesting. In reality neither of those is likely to be null but it seemed like something interesting!</p>
<p>If I understand what you&#8217;re saying correctly then we should make MoreSpecificController handle the null situation without throwing a Null Pointer Exception? Makes sense.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Zubair Khan</title>
		<link>http://www.markhneedham.com/blog/2009/11/19/two-controllers-type-conformance-and-the-liskov-substitution-principle/comment-page-1/#comment-26942</link>
		<dc:creator>Zubair Khan</dc:creator>
		<pubDate>Thu, 19 Nov 2009 15:21:59 +0000</pubDate>
		<guid isPermaLink="false">http://www.markhneedham.com/blog/?p=1847#comment-26942</guid>
		<description>I think we&#039;re looking too closely at what the arguments are as opposed to what they can be(?)

null&#039;s make this problem more obvious in that they&#039;re not actually instances of the argument as the method has specified.

Saying that a sub class should be able to replace a super class wherever the super class is used doesn&#039;t mean it is to behave the same (clearly).

So the fact the specific class snaps when given a null isn&#039;t a violation of LSP. It&#039;s just the fact that null&#039;s are evil and a change in behaviour.

Having discussed the above with Pete (Gillard-Moss) he&#039;s schooled me some. He states two things I didn&#039;t consider.

1. In a contract based language the acceptable values are part of the contract, which means the subclass indeed breaks the initial contract.

2. Throwing an exception is beyond a change in behaviour, it too is a break in the contract given (1).

That to me suggests that either the super class should check for nulls and throw an exception, or the subclass should check for nulls and handle that scenario gracefully.</description>
		<content:encoded><![CDATA[<p>I think we&#8217;re looking too closely at what the arguments are as opposed to what they can be(?)</p>
<p>null&#8217;s make this problem more obvious in that they&#8217;re not actually instances of the argument as the method has specified.</p>
<p>Saying that a sub class should be able to replace a super class wherever the super class is used doesn&#8217;t mean it is to behave the same (clearly).</p>
<p>So the fact the specific class snaps when given a null isn&#8217;t a violation of LSP. It&#8217;s just the fact that null&#8217;s are evil and a change in behaviour.</p>
<p>Having discussed the above with Pete (Gillard-Moss) he&#8217;s schooled me some. He states two things I didn&#8217;t consider.</p>
<p>1. In a contract based language the acceptable values are part of the contract, which means the subclass indeed breaks the initial contract.</p>
<p>2. Throwing an exception is beyond a change in behaviour, it too is a break in the contract given (1).</p>
<p>That to me suggests that either the super class should check for nulls and throw an exception, or the subclass should check for nulls and handle that scenario gracefully.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mark Needham</title>
		<link>http://www.markhneedham.com/blog/2009/11/19/two-controllers-type-conformance-and-the-liskov-substitution-principle/comment-page-1/#comment-26907</link>
		<dc:creator>Mark Needham</dc:creator>
		<pubDate>Wed, 18 Nov 2009 15:33:29 +0000</pubDate>
		<guid isPermaLink="false">http://www.markhneedham.com/blog/?p=1847#comment-26907</guid>
		<description>Couple of questions:

If we had explicit pre and post conditions then would it be true that sub classes should adhere to those laid out in their super class?

What would you say is the definition of a provable property? I think you&#039;re saying that it&#039;s just a coincidence that request and response aren&#039;t being used in the super class, and that&#039;s why it wouldn&#039;t be a violate. Is that right?</description>
		<content:encoded><![CDATA[<p>Couple of questions:</p>
<p>If we had explicit pre and post conditions then would it be true that sub classes should adhere to those laid out in their super class?</p>
<p>What would you say is the definition of a provable property? I think you&#8217;re saying that it&#8217;s just a coincidence that request and response aren&#8217;t being used in the super class, and that&#8217;s why it wouldn&#8217;t be a violate. Is that right?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: MauricioC</title>
		<link>http://www.markhneedham.com/blog/2009/11/19/two-controllers-type-conformance-and-the-liskov-substitution-principle/comment-page-1/#comment-26906</link>
		<dc:creator>MauricioC</dc:creator>
		<pubDate>Wed, 18 Nov 2009 15:28:49 +0000</pubDate>
		<guid isPermaLink="false">http://www.markhneedham.com/blog/?p=1847#comment-26906</guid>
		<description>Or, in other words: Every code can be held to much stronger assumptions than what&#039;s explicitly stated as a pre-condition or post-condition, but that doesn&#039;t mean derived classes have to adhere to those implicit assumptions. That&#039;s why making pre-conditions and post-conditions explicit is a good idea.</description>
		<content:encoded><![CDATA[<p>Or, in other words: Every code can be held to much stronger assumptions than what&#8217;s explicitly stated as a pre-condition or post-condition, but that doesn&#8217;t mean derived classes have to adhere to those implicit assumptions. That&#8217;s why making pre-conditions and post-conditions explicit is a good idea.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: MauricioC</title>
		<link>http://www.markhneedham.com/blog/2009/11/19/two-controllers-type-conformance-and-the-liskov-substitution-principle/comment-page-1/#comment-26905</link>
		<dc:creator>MauricioC</dc:creator>
		<pubDate>Wed, 18 Nov 2009 15:25:27 +0000</pubDate>
		<guid isPermaLink="false">http://www.markhneedham.com/blog/?p=1847#comment-26905</guid>
		<description>Not really. Quoting Wikipedia&#039;s more precise version of the Liskov Substitution Principle:

Let q(x) be a property provable about objects x of type T. Then q(y) should be true for objects y of type S where S is a subtype of T.

The word &quot;provable&quot; is important: It means that implementation details for the Base class, such as the fact that GenericController doesn&#039;t use request and response, need not be true for the Derived class as well. Unless not using request and response is by Design, at which point you obviously have a LSP violation.</description>
		<content:encoded><![CDATA[<p>Not really. Quoting Wikipedia&#8217;s more precise version of the Liskov Substitution Principle:</p>
<p>Let q(x) be a property provable about objects x of type T. Then q(y) should be true for objects y of type S where S is a subtype of T.</p>
<p>The word &#8220;provable&#8221; is important: It means that implementation details for the Base class, such as the fact that GenericController doesn&#8217;t use request and response, need not be true for the Derived class as well. Unless not using request and response is by Design, at which point you obviously have a LSP violation.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

