leocharre has asked for the wisdom of the Perl Monks concerning the following question:
Warning. This post is about naming modules. If you think having a discussion about namespace is second class devel work, or simply a waste of time, don't bother reading me.
For the rest of you who also have previous experience having to deal with someone else's demented code- and would be too guilty to do that to someone else in turn- Good Karma to you, bless your classy self.
I tend to separate code into various modules if things get large. I can get around vi pretty alright, but I get feel safe with under 500 lines of code per module.
I am concerned that I could be making it more obvious to others, and to
myself- which modules are meant to be used directly, and which to be used indirectly (they are inherited).
Briefly put, I was thinking of prepending the module name with an udnerscore.
I have a few projects that are large-ish. They comprise of various scripts, tests, modules.. etc..
For example I have a DMS, a document management system- which we use in an office environment.
I have a DMS module, which abstracts the concept of many users, projects, etc. This is an oo module that can be instanced, tested, etc stand alone.
I have a DMS::Client module, which represents a client project's information, etc. This is also an oo module that can be tested, instanced, by itself.
I also try to organize my code and docs so I don't lose my freaking mind. So I have other modules like
DMS::Setup (aid with installation, check current machine's installation) and maybe DMS::Database, DMS::Configuration... etc
These last modules do not do anything by themselves, they are inherited by the DMS object, sometimes by DMS::User, DMS::Client.
So, since these modules are there for organization's sake, since, they are always used inherited (use base..)- I was considering naming these something like DMS::_Setup, DMS::_Database, so any module names that start with an underscore can be assumed to be inherited.
I want to know if this sounds good. I also would like to know if in your experiences, separating the code up is indeed good, at what line count do you feel good about doing that- and do you have other ways of dealing with this other then to just put a big warning in the description that says 'dont use me' ?
(What about putting all private methods in external modules, and all public methods in main object? It sounds good, but I fear it would be hairy to maintain?)
|
---|