On Mar 8, 2006, at 8:18 PM, Charles Yeomans wrote:
On Mar 8, 2006, at 6:31 PM, Guyren Howe wrote:
<snip>
Can you offer an example of an advantage to method overriding that
outweighs these advantages, or a more common and complex use of
method overriding than return type covariance?
Take a look at my column in the RBD issue included in your REAL
World bag. In it, I make the claim that overriding was the more
natural approach in that application of the Chain of Responsibility
pattern.
I looked at that. It's a shame you didn't say *why* you found
overriding a more natural solution. Right now, to me it appears as
though you could happily implement all of this by passing everything
down as a functional event returning a Boolean (where returning True
indicates that the subclass wants to handle the tag), and it would be
clearer and more concise.
So then, say, your XMLReaderHandler.HandleStartElement would look
like (here, eHandleStartElement is the corresponding event):
Sub HandleStartElement(name as String, attributeList as
XMLAttributeList)
If Not eHandleStartElement Then
If me.NextHandler <> Nil then
me.NextHandler.HandleStartElement name, attributeList
End If
End If
End Sub
and your DatabaseXMLHandler.HandleStartElement would then look like:
Sub eHandleStartElement(name as String, attributeList as
XMLAttributeAttributeList)
If name = "Database" then
me.Handler = new TablesXMLHandler(dbRef)
Return True
End If
End Sub
The second of these is considerably more concise than your overriding
version (although you could have replaced the entire Else clause in
your version of this with Super.HandleStartElement, and been *almost*
as concise).
What am I missing?
Guyren G Howe
guyren-at-relevantlogic.com
http://relevantlogic.com
REALbasic, PHP, Python programming
PostgreSQL, MySQL database design and consulting
Technical writing and training
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>