http://qs321.pair.com?node_id=256438


in reply to (jeffa) Re: RFC: CGI::Tables
in thread RFC: CGI::Tables

I hadn't seen DBIx::XHTML_Table before. It is the 96th result returned in a CPAN search for "html table". I rarely search to the 10th page. Truth be told, there are entirely too many results returned. Many of them seem to do the same thing, and most of them also seem poorly designed, IMOH.

<rant>

Some people will naturally like templates better. That's fine, but let's ignore that at the moment, because I personally don't care much for them. They have their place, but most of the time it's not with me.

Where is the best place to put a module like this? I see them in all different namespaces: DBIx, HTML, Table, Text, CGI. Where would it actually belong? If it's made more generic with different output options? What if you decide you want to expand it with other HTML functions? This is a general problem with CPAN, I think. Reusable code doesn't fit well in a hierarchy.

Now what if different people have different ideas of what a good interface would be? The first module claims a good name, and the second really has no place.

Suppose, for instance that I decide I don't like the way CGI.pm works. I decide that I want to redesign it. Sure, reinventing the wheel can be bad, but there's always the possibility of improvement. What would I name my module?

</rant>

It's really hard to find the right module sometimes. Too hard. I suppose it's even harder to write one.

elusion : http://matt.diephouse.com

Replies are listed 'Best First'.
Re: Re: (jeffa) Re: RFC: CGI::Tables
by markjugg (Curate) on May 08, 2003 at 01:49 UTC
    It's curious that in the same burst you rant about too many modules being on CPAN and having them poorly designed, but you offer no feedback at all on DBIx::XHTML_Table, which apparently has support for using an AoA to build the table, which I think is supposed by be one of the neat features of your module-- the easy ability to add a column.

    My suggestion is that you if you are concerned about the proliferation of semi-useful modules on CPAN, look hard at all the alternatives to your own module that you could contribute to before starting yet-another.

    I get the sense that many modules are maintained by primarily one person who would be glad to have help, and we would all benefit by having fewer high quality modules to wade through.

    If you remain confident your module is filling a unique niche, I think the module-authors@perl.org mailing list is the appropriate place to ask about potential names.

    Mark

      Like I said, I hadn't seen DBIx::XHTML_Table before. It was the 96th result returned. Ten pages. I looked for something that filled the need I had, but couldn't find it. I'm not gonna look at every module on CPAN before writing my own. Here is the AoA interface to DBIx::XHTML_Table:
      my $rows = [ [ qw(Head1 Head2 Head3) ], [ qw(foo bar baz) ], [ qw(one two three) ], [ qw(un deux trois) ] ]; my $table = DBIx::XHTML_Table->new($rows);
      It's almost identical to the first way of arranging data in my module, but quite different than the other two. The second two are the ones I consider neat. You supply an array and the number of columns or rows that you want and it builds the table for you.

      As to contacting module authors, one of the main rules of module writing is "don't change the interface." That makes it rather difficult to contribute to an out of alpha/beta module. I could send my code, but its interface is entirely diferent, so it wouldn't do much good to try to incorporate it.

      elusion : http://matt.diephouse.com

        While your second two methods for creating tables are neat, i rarely need such tools. Most of my work involves getting results from a database ... the rows and columns are already determined. The only reason why i added the AoA feature was because it was too trivial to not add it. Besides, creating the table by supplying an array and some number (say, 4) is a piece of cake. ;) .o0(maybe i should add this to the CookBook)
        use strict; use warnings; use DBIx::XHTML_Table; my @avengers = ( 'Iron Man', 'Black Panther', 'Thor', 'Black Widow', 'Mockingbird', 'Captain America', 'Quicksilver', 'Vision', 'Falcon', 'Scarlet Witch', 'Wasp', 'Hawkeye', 'Hercules', 'Yellowjacket', ); my $n = 4; my $rows = [map[@avengers[$_..$_+$n-1]], range(0,$#avengers,$n)]; my $headers = [map "row$_",1..$n]; print DBIx::XHTML_Table->new($rows,$headers)->output; # if Python can do this, so can Perl! sub range {grep !($_%$_[2]-$_[0]),$_[0]..$_[1]}
        However, your module has this encapsulated already, so i just re-invented a wheel. ;) And i will admit that your module does one important thing that mine does not - allow the user to place the headers in a column, and not just in the top row. This is something that i plan to fix this summer. I'll use the printer terms 'landscape' and 'portrait' to describe the two different styles.

        As for why my module turned up so low at search.cpan.org, well i guess it's because my module is named XHTML, not merely HTML. Shame that it doesn't get a higher hit rating ... but if you search for xhtml table, it is the first hit. Kobe, however, lists my module quite a bit higher ... html table. Thanks Randy. :)

        Honestly, i see no reason why your module should not be on CPAN. I like the autogeneration feature ... maybe the name HTML::Table::Generate would be a good name for it. There really are a lot of HTML Table modules on CPAN ... i guess it's a popular problem to solve. ;)

        UPDATE: changed 3 arg to range from $n - 1 to $n. My original was producing duplicate values. (chalk it up to late-nite posting) Thanks jryan. :)

        UPDATE2: changed internals of range. It did not work "if the starting point is not a multiple of the increment" (quote from merlyn). Whereas the fuction works just fine for this example, it won't for other applications. The fix? Simply subtract the starting point from the result of the modulus. Better yet, just use the code i posted at emulate Python's range function.

        jeffa

        L-LL-L--L-LL-L--L-LL-L--
        -R--R-RR-R--R-RR-R--R-RR
        B--B--B--B--B--B--B--B--
        H---H---H---H---H---H---
        (the triplet paradiddle with high-hat)
        
        Hello, I don't fault you not paging through every last CPAN result. I think search system there could be improved as well. I'm also frustrated it doesn't some better kind of "rating/comment" system, or some other way to get a clue about which modules people are generally finding useful.

        I was just surprised that once the module had been brought to your attention, you didn't seem to be giving it much consideration. Cleary, from your post directly above, you have done that.

        I'm really not supposed to having many modules that approach the same problem space the same way. While I think there are many cases where collaboration versus competition would be beneficial, as much as much as anything the problem lies the ability to usefully manage all the information we have about all the available options. To address that, I think we really need some enhancements to CPAN websites, or some better external resources to supplement them.

        Mark