Greg Ewing wrote: > > Brian Slesinsky <bslesins@best.com>: > > > But sometimes you need to work with base types or other people's > > classes without subclassing them > > I think there are situations where it's legitimate to prefer a > case-statement approach even when dealing with your own classes. > > I once wrote a compiler in HUGS (a Haskell dialect), and I found it > very convenient to be able to write a self-contained function which > took a parse tree node and did something for each possible subtype of > that node. It kept all the processing related to each phase of the > compiler together in one place. > > Using a pure OO aproach, I would have had to scatter it all among > hundreds of one or two-line methods of many classes, and probably > would have gone insane before finishing the project. Right. IMO, the method callback approach is nice if you need an extendable architecture, e.g. to write generic parsers frameworks. It doesn't pay off in situations where you have a set of fixed requirements. In these cases, the performance gain is more important than being able to extend by subclassing. -- Marc-Andre Lemburg CEO eGenix.com Software GmbH ______________________________________________________________________ Consulting & Company: http://www.egenix.com/ Python Software: http://www.lemburg.com/python/
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4