http://www.perlmonks.org?node_id=1004303

tomishere has asked for the wisdom of the Perl Monks concerning the following question:

On what basis Directories and Files should be classified(Right now each of my Files are for handling specific section of our application)? What should be the maximum number of lines in a file? What are the basic concepts and standards that should be followed while designing Classes and methods? If there is any good links for the same please provide me Thanks

  • Comment on Is there any specific convention/best practices for perl module creation?

Replies are listed 'Best First'.
Re: Is there any specific convention/best practices for perl module creation?
by 2teez (Vicar) on Nov 17, 2012 at 13:15 UTC

    Hi tomishere,
    ..If there is any good links..
    Links you say?
    Please check the followings:
    perlstyle, perlmod then
    See perlmodlib for general style issues related to building Perl modules and classes, as well as descriptions of the standard library and CPAN,
    Exporter for how Perl's standard import/export mechanism works,
    perlootut and perltooc for an in-depth tutorial on creating classes,
    perlobj for a hard-core reference document on objects,
    perlsub for an explanation of functions and scoping, and
    perlxstut and perlguts for more information on writing extension modules.

    If you tell me, I'll forget.
    If you show me, I'll remember.
    if you involve me, I'll understand.
    --- Author unknown to me

      Unless my eyes are deceiving me, I don't see perlmodstyle in your list, which is a very good resource.

      Additionally, if you intend to upload to CPAN, I recommend reading the CPAN Author's FAQ, and About PAUSE (even if you're not uploading to CPAN, there's useful advice).

      Once you're confident enough in your own good judgement to not be blindly influenced by the book, Perl Best Practices (O'Reilly) is useful. But most people seem to ignore the instructions early in the book telling authors that these guidelines are more intended to "get you thinking" than to "tell you what to do." In practice, it seems the opposite happens; the "best practices" are trotted out as a crutch to excuse coders from thinking for themselves. With that caveat, I still think it can be helpful to read through it and try to understand what issues are being addressed, and where the suggestions are (and are not) appropriate.


      Dave

        ++ Dave. Agreed with your point on Perl Best Practices Book.
        However, I suppose the OP wanted a pointer or references to Perl documentations that could help (in writing or) using perl modules correctly.
        Nice inclusion of perlmodstyle.
        Thanks.

        If you tell me, I'll forget.
        If you show me, I'll remember.
        if you involve me, I'll understand.
        --- Author unknown to me
Re: Is there any specific convention/best practices for perl module creation?
by ww (Archbishop) on Nov 17, 2012 at 13:34 UTC
    Please see our excellent Tutorials section; specifically, "Modules-How-to-Create-Install-and-Use"

    And please read On asking for help for some hints on how to best obtain help here.

Re: Is there any specific convention/best practices for perl module creation?
by eyepopslikeamosquito (Archbishop) on Nov 17, 2012 at 23:09 UTC

    On what basis Directories and Files should be classified (Right now each of my Files are for handling specific section of our application)?
    Focus not on files and directories, but on modules. The principal unit of decomposition in Perl is the module.

    When designing modules, focus first on the module interface. Perl Best Practices, Chapter 17 (Modules), "Design the module's interface first" advises how to go about this (play testing and so on). For a detailed discussion of software interfaces in general, see On Interfaces and APIs.

    What should be the maximum number of lines in a file?
    Don't focus on lines in a file. Focus on sound software design. For example:
    • Design highly cohesive, loosely coupled modules.
    • Ensure modules can be tested in isolation.
    • Minimize the exposure of implementation details and avoid global data.
    If you do that, code maintenance becomes easier, and none of your files should be grotesquely huge. See also:

Re: Is there any specific convention/best practices for perl module creation?
by karlgoethebier (Abbot) on Nov 17, 2012 at 13:15 UTC

    Please take a look at here - and you will find some answers to your questions. Regards, Karl

    «The Crux of the Biscuit is the Apostrophe»