in reply to Re: My module - my latest step
in thread My module - my latest step

It should be possible to cut and paste the entire synopsis and create a working program that shows the utility of the module

I disagree. I think that working programs should be put under examples. I believe that synopsis should be what webster.com tells you: 1 : a condensed statement or outline (as of a narrative or treatise) : ABSTRACT

Think of the module as a shrink-wrapped box, and the user wants to tear off the plastic and make it work as soon as possible.

Not only first-time users read the synopsis. After a while of not using a module I sometimes take a quick look at the synopsis to get going again.

There are many examples of (common) Perl modules that has an IMHO good enough synopsis but doesn't show an in its own useful snippet: strict, Data::Dumper, constant, Exporter, HTML::Parser, DBI (perhaps a bit extreme), Math::BigInt, LWP::UserAgent, File::Slurp, Storable, Switch, English, and more.

Though, you can't really compare "language extention modules" such as constant or strict with modules that does a certain task for you such as HTML::Parser. They need different types of documentation. For Exporter::VA the targeted audience is people who want to export things. What they are interested in is the interface and how they can achieve exporting and what makes Exporter::VA special. So I'd be perfectly happy to see a simple synposis like the one Exporter has. Having a runnable and "useful" snippet would just take away focus from the specialities in Exporter::VA.

Just my thoughts,
ihb

Replies are listed 'Best First'.
Re: Re: Re: My module - my latest step
by toma (Vicar) on Jan 11, 2003 at 21:23 UTC
    I agree that making a perfectly executable synopsis is problematic for some modules, so you have to use judgement. I also agree that language extension modules are different. I didn't think of Exporter::VA as a language extension like strict. If it really is a language extension, then my preferences for the synopsis do not apply.

    Perhaps my favorite synopsis is the one in CGI.

    The idea of tearing off the shrink-wrap is to think about the initial user experience with a module. I don't know if you remember your first experience with use strict;, but I remember that mine was rough! It introduced a whole new way of coding for me. If Exporter::VA is to change the way that I code and become a 'way of life' module, the documentation needs to be especially clearly written. The strict perldoc is quite good, for example. Even with this documentation, I really had to read a detailed article about the requirements and benefits of strict before I was successful with it.

    For ordinary modules that just do something clever, I like to try them out quickly. I typically evaluate five to ten modules a week, so speed is important to me.

    Here is what I did to try out File::Slurp, which I think has a synopsis that is slightly more complex than my ideal, but it is actually fine how it is.

    $ cpan > install File::Slurp > quit $ mkdir fileslurp $ cd fileslurp $ perldoc File::Slurp # This next bit is cut and paste: $ cat > t.pl use File::Slurp; $all_of_it = read_file($filename); @all_lines = read_file($filename); write_file($filename, @contents) overwrite_file($filename, @new_contnts); append_file($filename, @additional_contents); @files = read_dir($directory); $ vi t.pl
    After pulling in my perl test-program template and a bit of editing I have this:
    <P> #!/home/toma/perl58i/bin/perl #!/home/toma/perl58i/bin/perl -d:ptkdb # # Tom Anderson # Sat Jan 11 12:31:00 PST 2003 # # Program to try out File::Slurp # # my $VERSION=".01"; use strict; use warnings; use diagnostics; use File::Slurp; my $filename = "/etc/passwd"; my $all_of_it = read_file($filename); print $all_of_it;

    With very few keystrokes and very little time I have evaluated File::Slurp and my first impression is that it is a very good module. I understand what it does, although I have only scratched the surface. I think that the author of File::Slurp has done me a great favor by uploading this module to CPAN, because I got to experience it working perfectly the first time!

    It should work perfectly the first time! - toma