Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Update these modules if installed?

by LanX (Saint)
on Mar 08, 2020 at 02:21 UTC ( [id://11113960]=note: print w/replies, xml ) Need Help??


in reply to Update dependants if installed (was: Update these modules if installed?)

> because they do not actually require() or use() Log::ger, but instead are used together by users in the user's code. However, the plugins do "depend" on the Log::ger API

How is it possible to depend on the API of a module one doesn't require ?

IMHO if you need another modules API, then you are calling it's subs or methods, hence you need to import them.

Sorry, this really smells like bad design.

edit

anyway, IIRC you are able to list dependencies to other modules and versions as JSON or YAML in a distribution without actually importing them.

update

see CPAN::Meta

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery

Replies are listed 'Best First'.
Re^2: Update these modules if installed?
by perlancar (Hermit) on Mar 08, 2020 at 13:00 UTC

    I am talking about API in a more general sense instead of the more restricted sense of calling a module's functions/methods or variables. In the Log::ger case, a plugin returns a hash of hooks with names that are agreed upon. This is not enforced "mechanically", which can be a bad design choice in itself but I am choosing minimalism over stricture.

    Anyway, making the plugin depends explicitly to Log::ger does not solve my problem. If Log::ger changes in a backward-incompatible way, I *will* break installed plugins unless clients choose to update the plugins (the dependants).

      Why not just introduce some code in your distribution that can catch the plugins doing things the old, broken way, and gracefully throw a notice to the user and exit, with the notice advising them to upgrade the broken plugin (caller() could potentially be used to get the plugin name)?

      Not ideal, but significantly better than forcing an upgrade of user installed distributions.

        Yes, I did this to some extent, but there are still some scenarios where things could break. Your post reminds me that in other frameworks that I wrote, I do introduce API/metadata versioning and throw an exception whenever a plugin follows an older version which I no longer want to support. I might apply that to Log::ger too, thanks.
      Thanks for the clarification, tho that's a bit over my head.

      Hope Syphilis approach helps. :)

      Cheers Rolf
      (addicted to the Perl Programming Language :)
      Wikisyntax for the Monastery

        You're welcome. And thanks for the response nevertheless. It tells me that I haven't expressed myself well enough :-)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (5)
As of 2024-03-29 12:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found