Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: How do you do multi-version modules?

by ikegami (Pope)
on Oct 13, 2012 at 23:53 UTC ( #998887=note: print w/ replies, xml ) Need Help??


in reply to How do you do multi-version modules?

Polymorphic API:

If this is an OO-based module, you could pass a protocol version to the constructor. (Kinda like many file formats include a version.) If it's not, you could write your own import sub and use use module "1.0.0"; instead of use module 1.0.0;. This would be a bit error prone.

Parallel APIs:

The other approach is add to the interface instead of replacing it. You can use two different module names: "module" for 1.x.x and "module2" for 2.x.x, or you can add methods instead of replacing old ones (do_something2 is the new interface for do_someting).


Comment on Re: How do you do multi-version modules?
Select or Download Code
Re^2: How do you do multi-version modules?
by pokki (Scribe) on Oct 13, 2012 at 23:59 UTC
    If this is an OO-based module, you could pass a protocol version to the constructor. (Kinda like many file formats include a version.) If it's not, you could write your own import sub and use use module "1.0.0"; instead of use module 1.0.0;. This would be a bit error prone.

    And if you go this route, the first version that handles protocol/API/etc. versions should assume that "no API version given" is a valid input that means "the oldest version that did not know how to handle API versions", for the sake of backwards compatibility.

Re^2: How do you do multi-version modules?
by perl-diddler (Hermit) on Oct 14, 2012 at 01:14 UTC
    I wish I'd thought of that in designing the 1st... I thought about passing the version... but the earlier code would still have to be rewritten .... THOUGH, it is SIMILAR to what I was thinking about... and that is adding a new param, that the new stuff looks for but if not there, uses old behavior...(I think someone else suggested similar)...

    Still... gonna have to look at use more ... sounds like there may be some version stuff I missed... Though I'd think I'd go the opposite on the defaults w/o the version number. I don't want to have to support old stuff forever. So unversioned calls would get the newest behavior. It's assumed that most people want the newest and latest and greatest unless they really ask for the the outdated stuff, I don't see why software should assume the opposite is true. Imaging if people ran programs that didn't ask for a version on Windows 7 and got Dos 1.0 behavior... :-)....pretty screwed up eh?

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://998887]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (10)
As of 2014-07-25 03:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (167 votes), past polls