in reply to Re^4: Seeking advice for OO-related strategy
in thread Seeking advice for OO-related strategy
Well, I think that I just pulled stuff out from a bunch of sources.
Then, the rest of my post was extrapolation from there, plus a little bit of trial-and-error.
Other's code: check out the history of CGI::Application. When I first started using it, it handled the two cases (code ref and function name) separately. It now handles them identically (for a fairly significant improvement in speed... at least for that portion of the code).
If you want to limit your users to only using function calls, that's fine. Make it look like a function call. Personally, with this syntax, I see little reason to limit the users like that, especially if you're passing $self in anyway. It allows incredible flexibility (callback or inheritance, or both!) with no cost to the base class. All incredibly different from other OO languages. It allows polymorphic polymorphism - you can change the way that you override something completely dynamically.
One of the reasons why perl doesn't have access modifiers such as public, private, and protected, is because it's recognised that they often get in the way of getting the job done: what was envisioned by the original designer has nothing to do with what you want to do with it. In the same way, design for flexibility - although you may not see yourself needing it now, the next person to come along may see it being incredibly handy to solve that new problem, and will bless your genius for developing that flexibility ;-)
|
|---|