The Artima Developer Community
Sponsored Link

Java Buzz Forum
If you can't type them, join them

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Bill de hÓra

Posts: 1137
Nickname: dehora
Registered: May, 2003

Bill de hÓra is a technical architect with Propylon
If you can't type them, join them Posted: Aug 17, 2004 8:29 AM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by Bill de hÓra.
Original Post: If you can't type them, join them
Feed Title: Bill de hÓra
Feed URL: http://www.dehora.net/journal/atom.xml
Feed Description: FD85 1117 1888 1681 7689 B5DF E696 885C 20D8 21F8
Latest Java Buzz Posts
Latest Java Buzz Posts by Bill de hÓra
Latest Posts From Bill de hÓra

Advertisement
Here's Martin Fowler on frigging with base classes: "Many people get very disturbed by this kind of thing, but it does a great deal to simplify the logic of code that sweeps through the composite structure. I think of it as getting the leaf class (elephant) to provide a simple implementation as a courtesy to its role as a node in the hierarchy." class Elephant I would go a bit further, and make this useful for non-Elephants. In 'Scruby' (Statically Compiled Ruby): class Node def num(type) if type is Node return 1 else return 0 end end Now subclass it where the Elephant Node returns 1 when supplied its type. Why? Two reasons. First, putting Elephants in boxes is just the beginning. More frigs are bound to occur, resulting in you AddingMoreStuffToTheBaseClass. That way lies honest to goodness Lovecraftian madness (or the DOM). Second, if you're going to make a hack, you might as well make a judicious hack so that you or someone else can dig your way out later. Above you've got the option to send a message to all types of Node and they can decide for themselves what type they are. There are other ways to deal with this, the ultimate choice depending of course on the language at hand. For folks programming with composite structures in Java or C#, these guys have it nailed. While the term CourtesyImplementation is tad Newspeak, it's good to see an industry leader outlining a trade-off instead of a fantasy world where trade-offs Just Don't Happen. [franz ferdinand: michael]...

Read: If you can't type them, join them

Topic: Concurrent Testing and Patterns for Java Previous Topic   Next Topic Topic: Oracle releases BPEL PM 2.0 rc9

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use