My response to that was that the number of different types of tokens goes up rapidly when you add in convenience features like turning emoticons into pictures, autolinking URLs, and using \ as an escape mechanism. The result is that the number of different methods in your API quickly grows. You came back from that with the idea of putting an OO wrapper around the whole thing. I'm still unsure what that would buy.
The basic problem is that your original suggestion was trying to draw an abstraction layer across the tight coupling between configuration and the handlers generated from that configuration. Tight coupling across a complex and young API is guaranteed to mean a lot of changes. A better idea is to have building the configuration hash broken up into a series of functions that return related sets of handlers. Like valid HTML tags, emoticons, automatic paragraph breaking, and convenience shortcuts. If this was for a discussion site like this one, you could then expose to the user the choice of which types of functionality they want available for processing their posts. And now even fairly significant rewrites of this code could take place without problems. Of course this approach doesn't lead you in an OO direction.
On the question of how to select which paradigm to use when, I am a firm believer that programming should be viewed as a craft. Which, among other things, means that people need to be mentored. You can read all you like and be told all of the rules that exist without necessarily being able to apply it very well. But when you come up with a design and get detailed feedback on your design, things work much better. Mentoring online is better than nothing, but mentoring in person is much better.
The fly in the ointment is where to get competent mentors from and match them up to programmers. I am all ears for a solution because I don't have one. However I had the luck to have a good mentor when I was just starting out, and I'm firmly convinced that that is the best way to go.
In reply to Re^11: replace conditionals with polymorphism
by tilly
in thread replace conditionals with polymorphism
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |