On Mar 8, 2006, at 11:53 PM, Guyren Howe wrote:
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).
Could be; the column was written based on code from one of my projects.
So in six months it will probably have been refactored to something
entirely different. I recall going back and on forth on events v.
overriding before settling on overriding.
--------------
Charles Yeomans
_______________________________________________
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>