Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
I'm unsure if I should write use <name of module> in two special cases.
Special Case 1:
I'm in module A. This needs a functionality of module B. But it also needs the functionality of modules B1 and B2. B1 and B2 are inheriting from B. Or in other words B is the base class of B1 and B2.
Now in module A:
use B; # not necessary because B1 and B2 are using B. use B1; use B2;
Shall I write use B; or not. What is your opinion?
Special Case 2:
Class A has an object of class B inside and of course uses its functionality. Class A is not creating the object B. The object B is created somewhere else and to class A is given the already created object of B. Because the object B is created outside of class A, I can assume that the Module B was loaded before somewhere else. And thus writing use B; in class A would not be necessary. Would you write use B; in class A?
What is your opinion? Thank you very much!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: use of modules in special cases (updated)
by LanX (Saint) on Dec 21, 2019 at 21:35 UTC | |
|
Re: use of modules in special cases
by davido (Cardinal) on Dec 21, 2019 at 22:33 UTC | |
|
Re: use of modules in special cases
by choroba (Cardinal) on Dec 21, 2019 at 23:16 UTC | |
|
Re: use of modules in special cases
by Dirk80 (Pilgrim) on Dec 22, 2019 at 07:06 UTC | |
by soonix (Chancellor) on Dec 22, 2019 at 12:46 UTC | |
by LanX (Saint) on Dec 22, 2019 at 12:36 UTC | |
|
Re: use of modules in special cases
by Anonymous Monk on Dec 23, 2019 at 05:12 UTC | |
by soonix (Chancellor) on Dec 23, 2019 at 11:49 UTC |