Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Mini-Tutorial: Mutual Use of Exporting Modules

by Jenda (Abbot)
on Jul 09, 2009 at 23:04 UTC ( [id://778721]=note: print w/replies, xml ) Need Help??


in reply to Mini-Tutorial: Mutual Use of Exporting Modules

If ModA uses ModB and ModB uses ModA, you should sit down and change them both to use ModC instead.

Jenda
Enoch was right!
Enjoy the last years of Rome.

  • Comment on Re: Mini-Tutorial: Mutual Use of Exporting Modules

Replies are listed 'Best First'.
Re^2: Mini-Tutorial: Mutual Use of Exporting Modules
by ikegami (Patriarch) on Jul 09, 2009 at 23:13 UTC
    What if ModA is Car and ModB is CarEngine? There's nothing inherently wrong with the concept. Sometimes refactoring is in order. Sometimes it's not. (And sometimes, refactoring is not an option for business reasons.)
      CarEngines can be put in things other than cars.

      I have yet to see a case of circular requires that would not be much clearer if refactored. I have, however, great sympathy for the situation where refactoring is not an option for business reasons.

      If ModA is Car and ModB is CarEngine then I understand that the Car wants to import CarEngine because Car HasA CarEngine, I don't see why would CarEngine import Car. Even if it later keeps a IsIn reference.

      The concept makes about as much sense as multiple inheritance. It looked like a good idea at first, but it causes too many subtle and hard to debug problems. Which is why things like mixins were invented. Though of course it means a bit of refactoring, instead of merging two classes and hoping for the best.

      Jenda
      Enoch was right!
      Enjoy the last years of Rome.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (3)
As of 2025-03-25 01:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    When you first encountered Perl, which feature amazed you the most?










    Results (65 votes). Check out past polls.

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.