Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • I don't have a problem with long sub names themselves, though that one looks absurd.
    I can imagine using that sub, but it should apparently be broken into two subs, at least,
    if it's doing two things (delivering emails, delivering section types).

    deliver_emails_for_products would be a wrapper around deliver_emails,
    if it's delivering separate emails for several products (maybe I misunderstand it).

    deliver_section_types_for_users_that_havent_received_email
    would wrap around deliver_section_types:

    sub deliver_section_types_for_users_that_havent_received_email {
        my $users = get_users_that_havent_received_email();
        deliver_section_types($users);
    }

    sub get_users_that_havent_received_email {
        # depends on the problem, might be broken down further
    }

    I personally like code that is factored out like that,
    even with long sub names.
    I can see from your previous post, though, that the code inside is probably hideous
    in your case.
    • Actually, this sub doesn't really deliver any email (the code that does so is not in the lexical scope of that sub). It gathers information about email to send, then calls send_email_to_user_if_not_already_sent().

      That sub has fourteen positional arguments.

      • “If you have a procedure with 10 parameters, you probably missed some.” —Alan J. Perlis, Epigrams on Programming