Think about Loose Coupling | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
A lot of good suggestions here. Some time ago, however, I went the other way round: I wrote some improved, all-new gizmo-packed object-oriented modules, that covered my previous functions. Then I wrote a compatibility layer module that presented a procedural interface for some functions to my old scripts. Here's an (untested) quick shot to illustrate what I mean:
With that approach, of course, switching to the new module could break your old scripts, should you realize that your compatibility layer just isn't. ;) Thus, extensive testing is needed before going live with the new module. I would not reccomend that for large, critical applications. On the other hand, you'd keep the old module around, so you could easily downgrade in case of problems... What I like about this approach, is that you don't pack your OO code with old procedural interface stuff. Applications that use only the OO interface with have no overhead at all. On the other hand, of course, your old apps might suffer from the overhead of the disguised object creation and method calls. Besides all that, I suggest to study the code of CGI.pm or some of the other CPAN modules that offer both an object and a procedural interface (no I can't think of another right now... (help me!)), if you really want to get serious on this. BTW, does any of you brothers and sisters know of some literature/articles on this topic? Updated: Just added a comment in the code above, since it functionally diverts from Rudif's original code. So long, In reply to Re: How to morph a plain module to OO (use a compatibility layer)
by Flexx
|
|