Limbic~Region has asked for the wisdom of the Perl Monks concerning the following question:

All,
Coming up with good meaningful names seems to be harder than writing the code. I am writing a class that given an INI style configuration file representing a DB schema will build that DB.
[TABLE1] FIELD1 = INTEGER FIELD2 = TEXT

Due to reasons beyond my control, I am stuck with this implementation. I understand the limitations and I also understand existing prior art. Suggestions for alternatives, while appreciated, are futile. With that in mind, can you offer a good meaningful namespace?

Suggestions from the CB (thanks Corion, castaway, and rhesa ) include:

Cheers - L~R

While the implementation is being forced by in-house politics, I don't expect there would be any resistance in releasing the code. If there is any interest in that, let me know.

Replies are listed 'Best First'.
Re: Assistance with naming a class
by jdporter (Paladin) on Mar 27, 2007 at 15:34 UTC

    Those suggestions you got already look good, except I'd add one qualification: Whether you use 'SQL' or 'DBIx' should depend on the implementation. Is the module going to be talking DBI? If so, then I'd recommend the latter, since 'SQL' is (it seems to me) more about the language generically. OTOH, if your module is simply going to translate the info into the corresponding schema SQL and leave the actual db creation to another function, then the former makes more sense.

    A word spoken in Mind will reach its own level, in the objective world, by its own weight
Re: Assistance with naming a class
by talexb (Chancellor) on Mar 27, 2007 at 15:45 UTC

    I think either SQL::Schema::FromINI or SQL::Translator::FromINI would be appropriate.

    I like the 'FromINI' because it clearly says where the data is coming from. It sounds like it's more or a translator than anything that generates a schema .. a schema generator is much more of an abstract item.

    I don't believe it should have 'DBIx' in front of it -- it's not actually part of that class or group, it's more of a preparatory step.

    Alex / talexb / Toronto

    "Groklaw is the open-source mentality applied to legal research" ~ Linus Torvalds

Re: Assistance with naming a class
by Mutant (Priest) on Mar 27, 2007 at 15:41 UTC
    Something involving 'FromINI' works for me. If it's not based on SQL::Translator, then perhaps using that namespace is misleading (if it is, then it's probably a good name!). My vote would be for SQL::Schema::FromINI.

    I think it's easy to underestimate how important naming of classes, methods, variables, etc. is. Even if you use something descriptive (i.e. not just $foo), it should provide a reasonable explantion of what it does. Choosing a good name can make for a huge improvent in code readability.
Re: Assistance with naming a class
by Rhandom (Curate) on Mar 27, 2007 at 15:59 UTC
    Sorry this isn't an answer to the posted question.

    How will you handle field constraints such as primary key, foreign key, auto increment (not a true constraint), unique key, check, and other constraints? I am not away of much useful SQL that doesn't have at least some constraints.

    Can you abstract it so that you have a well defined data structure, then you can spit out SQL? This would allow you to store your SQL as not just INI, but YAML, JSON, Storable, and possibly XML simple.

    I'm sorry if you already address these issues in your module's documentation.

    If you have abstracted things, then I'd say that the module names ending in INI might be good - but then you may want something like
    • SQL::CreateTable
    • SQL::CreateTable::INI
    • SQL::CreateTable::YAML
    With a name like this, you could have SQL::CreateTable do the hard work of translating data structure to schema and vice versa. The ::INI and other variants then are used by SQL::CreateTable to serialize to file based on the extention of the filename, or by passing in a parameter.

    my @a=qw(random brilliant braindead); print $a[rand(@a)];
      Rhandom,
      These are good questions. As I said:

      "Due to reasons beyond my control, I am stuck with this implementation. I understand the limitations and I also understand existing prior art. Suggestions for alternatives, while appreciated, are futile."

      In other words, this implementation falls far short of the mark of what a reasonable person would want but that's besides the point.

      Cheers - L~R

Re: Assistance with naming a class
by pdcawley (Hermit) on Mar 30, 2007 at 07:29 UTC

    Is it politically feasible to pick an existing tool that does the job of building the database and write an adaptor that goes from the INI format to whatever the existing tool wants? If you pick something that's well documented and supported, you just saved yourself an awful lot of work, and put a bunch of extra capability in the bank for when the INI approach runs out of steam.

    You can name the resulting translator module Existing::Product::Schema::(From)?INI and release it or not as you choose.

      pdcawley,
      You asked a question which deserves a response though I would have preferred to stay silent. There was a discussion a while back concerning adding a "Perl Career" section devoted to venting frustrations, asking for advice, etc. This would fall into that category.

      I am not a developer. My official title is "Information Technology Specialist". My organization doesn't do any development, we hire contractors. There is a general fear of free and/or open source technology. Since I can remember, the only language used in development has been Java. The organization is oozing with hidden agendas, political power struggles, irrational fears, and a general angst against change.

      I am sure this situation isn't too unfamiliar. You may be surprised to hear that I love my job. I remain a perl hobbyist and not a professional because I do it for fun not money. If you take the fun away, the money isn't worth it. My job pays extremely well, provides unique opportunities and challenges, and is quite stable in contradiction to the chaos. Surviving in this environment means knowning when to pick your battles. This leads to the answer of your question.

      It is mostly a personal choice rather than one of political absolutes that is preventing me from changing this implementation. I treasure the rare occasions I am asked to contribute code. I have learned that the battles that need to be fought and won in order to win the war of change take a heavy toll and the road to victory is littered with casualties. You are fighting multiple adversaries and most employ attrition as their weapon of choice.

      The short answer is, I probably could after a long and arduous struggle but I wouldn't like who I became in the end.

      Cheers - L~R

Re: Assistance with naming a class
by pemungkah (Priest) on Mar 29, 2007 at 11:38 UTC
    Schema::Builder::FromINI encapsulates the sentence you used to describle the code: it builds schemas from INI files.