Archive for the ‘Perl’ Category

PBP: 024 Booleans

Thursday, July 24th, 2014

The PBP suggests that boolean variables and subroutines should get special naming consideration, and be named in ways that read well.  That may involve giving them names like “is_whatever” or “has_whaterver” or “can_whatever”, so that they make contextual sense.

(more…)

PBP: 023 Identifiers

Monday, July 21st, 2014

This section of the PBP is a long one, and goes into great detail about how to think about naming important parts of your programs.  It covers explicitly modules/namespaces, variables (several types of them), and functions.

I thought, at first glance, it was way too picky and specific, but the more I read it, the more I liked it.

(more…)

PBP: 022 Automated Layout

Thursday, July 17th, 2014

The Best Practice is to get a tool to do the work for you; it’ll be regular, and not spend your time doing it.

My only concern is that Mr. Conway says, “You can take ugly code like this and turn it into something readable.” where the “readable” code isn’t, to my mind, that much better.  Spaces around the parens and an extra blank line do not readable code make. (more…)

PBP: 021 Lists

Monday, July 14th, 2014

Lists need to be formatted to be readable.  The suggestion is to always use parenthesis, indent after a parenthesis, and line things in columns, all with trailing commas.

The book provides clear examples, which I won’t duplicate here. (more…)

PBP: 020 Ternaries

Thursday, July 10th, 2014

The book talks about how confusing the ternary operator can be and how much of a mess it can make.  I’m almost surprised it doesn’t say, “Don’t use it.”

It suggests columns instead, with the condition, then the positive result.

(more…)

PBP: 019 Assignments

Thursday, July 3rd, 2014

The  PBP suggests breaking assignments much like it suggests breaking other operators; the assignment leads the broken line:


my $thingy

= $stuff + $hard_things + $foo;

(more…)

PBP: 018 Breaking by Precedence

Monday, June 30th, 2014

This Practice is to break long expressions at lower-possible operators.  It actually says “the lowest possible precedence”.  At a glance, this sounds like a fine idea, and it, in general, is.  The reason given is pretty solid, that you can easily confuse people about precedence by splitting things apart.  This will be even more important on operators people may not be familiar with the precedence of.  (Quiz: Which is higher precedence “&&” or “and”?  Which is higher precedence, “~” or “^”?)

(more…)

WebGUI: A Perl replacement for WordPress

Saturday, June 28th, 2014

I’ve been watching the YAPC::NA presentations, and saw a mention of this Kickstarter:

https://www.kickstarter.com/projects/2083389021/create-perl-competition-to-the-php-content-managem

This is a project to help get a system written in Perl to compete with WordPress.  There is an existing system that’s close, all it needs is time, energy, and developers.  It sounds like there’s a great core there, but it’s lost the commercial support it had before, and the one developer can’t go it alone.

The Kickstarter is to try and fund some key work on it, and make it more accessible and as easy to get started as WordPress.

Sadly, the Kickstarter’s getting close to no traction, and that makes it look kind of bleak.

Here’s a signal boost; have a look at the system, read the page (the video has lots of good stuff, but it’s a little wordy) and consider supporting this useful development.

If you can’t support the Kickstarter, maybe you have time to help them get the major new release unblocked and keep it from sinking into the murk of obscurity.

At the end of the video, they point out that a hundred people giving a hundred dollars each will fund it, and get it over some of these hurdles.  A thousand people giving ten dollars each would work just as well.

 

PBP: 017 Non-Terminal Expressions

Thursday, June 26th, 2014

This Best Practice is one that I’ve seen people argue horribly about, and I don’t get it.  The suggestion is to avoid doing a big calculation, with sequences of complex operations, in the middle of  a statement.  Take that complexity, stick it in a variable, and use the variable. (more…)

PBP: 016 Breaking Long Lines

Monday, June 23rd, 2014

This Practice is about how to break long lines of code.  It suggests breaking them before an operator, so the operator serves as a visual cue on the left, where you’re likely to be reading, that this line is continued from last time.

(more…)