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


in reply to Top Level Module Namespace Table

Search trumps lists :) http://search.cpan.org/modlist/ http://www.cpan.org/modules/by-category/

Replies are listed 'Best First'.
Re^2: Top Level Module Namespace Table
by Anonymous Monk on Feb 04, 2010 at 12:23 UTC

      Amazing how difficult it is for me to express myself precisely on this issue! I thought an example would be explicit. Sorry. Please allow me to attempt to improve.

      I'm well acquainted with CPAN Search; it's a great tool. I'm not sure how much an ordinary dev will want to use Parse::CPAN::Modlist; but that's cool. Both of these are solutions to the problem of I want to download a module that does This. They are statements of what is. This is a common problem and an important one; but it's not the issue I'm attempting to address.

      The table I seek is not descriptive but prescriptive. This is where the markers for deprecated namespaces come in.* This table goes no further than the top level of namespaces, perhaps some well-defined second levels (e.g., CGI::Application::). It's a statement of what should be.

      Reviewing the descriptions of existing modules is indeed a way to infer prescriptions for future efforts, I admit. By the same token, one course of bricks is a guide to placing the next. Yet, if we want a wall to stand neatly, we generally use a plumb line.

      I realize that I touch upon philosophical issues here.** My feeling is only that I will be more comfortable writing modules -- even modules that may never escape from my own project -- that are named in conformance with some plan.

      I'm coming rapidly to the belief that no such table exists (I'd like to be wrong!) and that creating it is a worthwhile project. I wrote the original node in hopes that Monks might suggest a good way to get it started.

      *

      **

        Hidden in your "readmore" link is a comment about the Data:: namespace being the world's worst identifier. user::petdance's observations were in regard to "data" as a variable name. Variable names usually identify the content stored in the variable. I totally agree that calling content data is pretty pointless. By definition it is data. However, that is not the meaning behind the top level data namespace.

        Data:: as a namespace is short for "data structures" rather than for "data content".

        It's been my understanding that the Data:: space is most properly used for modules that manipulate data structures independent of content and purpose. For example, a set of list or hash navigation utilities would belong in the Data:: namespace.

        While it is true that nearly all modules use some sort of data, it isn't true that all modules are focused purely on the data structure itself apart from the use case. Most modules manipulate data for a purpose and the module is focused on the larger purpose (web page generation, database extraction, report formatting, user interaction, etc, etc.). Thus not all modules belong to Data:: even though they use data.

        Data:: also seems to be the home of several modules that transform one data structure into another or convert complex data structures to strings, but not all. String representations are often closely tailored to specific use cases (computer persistence vs. human readability) or recognized standards (JSON, YAML). These modules often end up in top level spaces named after the convention or use case for which they were specifically designed.

        Also without Data:: we would have the problem of where to place generic transformation utilities, particularly ones that manage bi-directional transformations between two or more equivalent storage formats and internal data structures: would they belong in the source data structure? There isn't one single source structure. The target data structure? There may not be one single target structure either. A special transformation top level category? If so, what should that top level structure be called if not Data? Transformations? A namespace called Transformations:: would be as vague as Data::. In a certain sense nearly all programs involve some sort of transformation.

        Another issue arises when modules are developed for complex data structuring systems, e.g. a database. One could argue that these are purely about data structure and manipulation rather than the use case. After all, a database is at heart just a fancy data structure that supports validated and possibly distributed persistence. On the other hand, if the data structuring system is large and complex enough it gets its own namespace,e.g. DBI.

        But even though these larger complex systems get their own top level namespace, it would not do to have separate namespaces for each possible complex data structure. There are too many possibilities. Having a top level category dedicated as a catchall for general purpose data structure manipulation saves us from having a multitude of top level categories dedicated to specific data structures.

        Update: cleaned up some typos.
        I share your frustration in this regard. At the least there should be a tool that simply lists all of the current top-level names. It is all fine and dandy for the guidelines to say avoid creating a new top-level namespace, but there seems precious little help for a developer to find the right church for a new module, let alone the proper pew. If that tool exists, I'm having trouble finding it.