The Solver - Store

Buy crossword, anagram, sudoku related products
puzzle books, crossword and anagram software, electronic dictionaries

arrow Home page Wednesday, 17 August 2005  
 
Home page Add to Favourites Link to this page Something else
Current Store: UK Store
UK Store
front page
Back to listings
Product Categories
Books Classical Music DVD Electronics Health & Personal Care Kitchen & Housewares Music Outdoor Living Software Toys VHS Video Games
 
 

Books : Perl Best Practices

by: Damian Conway

 : Perl Best Practices
Binding: Paperback
Dewey Decimal Number: 005.133
EAN: 9780596001735
ISBN: 0596001738
Label: O'Reilly Media, Inc.
Manufacturer: O'Reilly Media, Inc.
Number Of Items: 1
Number Of Pages: 542
Publication Date: July 12, 2005
Publisher: O'Reilly Media, Inc.
Sales Rank: 32194
Studio: O'Reilly Media, Inc.


Average Rating:  out of 5 stars
List Price: £28.50
Amazon.co.uk's Price: £18.53
You Save: £9.97 (35%)
Prices subject to change.

Availability: Usually dispatched within 24 hours

Buy Now!

 




Related Items:

Editorial Review:

Book Description:
Many programmers code by instinct, relying on convenient habits or a "style" they picked up early on. They aren't conscious of all the choices they make, like how they format their source, the names they use for variables, or the kinds of loops they use. They're focused entirely on problems they're solving, solutions they're creating, and algorithms they're implementing. So they write code in the way that seems natural, that happens intuitively, and that feels good.

But if you're serious about your profession, intuition isn't enough. Perl Best Practices author Damian Conway explains that rules, conventions, standards, and practices not only help programmers communicate and coordinate with one another, they also provide a reliable framework for thinking about problems, and a common language for expressing solutions. This is especially critical in Perl, because the language is designed to offer many ways to accomplish the same task, and consequently it supports many incompatible dialects.

With a good dose of Aussie humor, Dr. Conway (familiar to many in the Perl community) offers 256 guidelines on the art of coding to help you write better Perl code--in fact, the best Perl code you possibly can. The guidelines cover code layout, naming conventions, choice of data and control structures, program decomposition, interface design and implementation, modularity, object orientation, error handling, testing, and debugging.

They're designed to work together to produce code that is clear, robust, efficient, maintainable, and concise, but Dr. Conway doesn't pretend that this is the one true universal and unequivocal set of best practices. Instead, Perl Best Practices offers coherent and widely applicable suggestions based on real-world experience of how code is actually written, rather than on someone's ivory-tower theories on how software ought to be created.

Most of all, Perl Best Practices offers guidelines that actually work, and that many developers around the world are already using. Much like Perl itself, these guidelines are about helping you to get your job done, without getting in the way.

Synopsis:
Many programmers code by instinct, relying on convenient habits or a "style" they picked up early on. They aren't conscious of all the choices they make, like how they format their source, the names they use for variables, or the kinds of loops they use. They're focused entirely on problems they're solving, solutions they're creating, and algorithms they're implementing. So they write code in the way that seems natural, that happens intuitively, and that feels good. But if you're serious about your profession, intuition isn't enough. "Perl Best Practices" author Damian Conway explains that rules, conventions, standards, and practices not only help programmers communicate and coordinate with one another, they also provide a reliable framework for thinking about problems, and a common language for expressing solutions. This is especially critical in Perl, because the language is designed to offer many ways to accomplish the same task, and consequently it supports many incompatible dialects. With a good dose of Aussie humor, Dr.

Conway (familiar to many in the Perl community) offers 256 guidelines on the art of coding to help you write better Perl code - in fact, the best Perl code you possibly can. The guidelines cover code layout, naming conventions, choice of data and control structures, program decomposition, interface design and implementation, modularity, object orientation, error handling, testing, and debugging. They're designed to work together to produce code that is clear, robust, efficient, maintainable, and concise, but Dr. Conway doesn't pretend that this is the one true universal and unequivocal set of best practices. Instead, "Perl Best Practices" offers coherent and widely applicable suggestions based on real-world experience of how code is actually written, rather than on someone's ivory-tower theories on how software ought to be created. Most of all, "Perl Best Practices" offers guidelines that actually work, and that many developers around the world are already using. Much like Perl itself, these guidelines are about helping you to get your job done, without getting in the way.

From the Publisher:
Perl Best Practices offers a collection of 256 guidelines on the art of coding to help you write better Perl code--in fact, the best Perl code you possibly can. The guidelines cover code layout, naming conventions, choice of data and control structures, program decomposition, interface design and implementation, modularity, object orientation, error handling, testing, and debugging.

About the Author:
Damian Conway holds a PhD in Computer Science and is an honorary Associate Professor with the School of Computer Science and Software Engineering at Monash University, Melbourne, Australia. Currently he runs an international IT training company--Thoughtstream--which provides programmer development from beginner to masterclass level throughout Europe, North America, and Australasia. Damian was the winner of the 1998, 1999, and 2000 Larry Wall Awards for Practical Utility. The best technical paper at the annual Perl Conference was subsequently named in his honour. He is a member of the technical committee for The Perl Conference, a keynote speaker at many Open Source conferences, a former columnist for The Perl Journal, and author of the book Object Oriented Perl. In 2001 Damian received the first "Perl Foundation Development Grant" and spent 20 months working on projects for the betterment of Perl. A popular speaker and trainer, he is also the author of numerous well-known Perl modules, including Parse::RecDescent (a sophisticated parsing tool), Class::Contract (design-by-contract programming in Perl), Lingua::EN::Inflect (rule-based English transformations for text generation), Class::Multimethods (multiple dispatch polymorphism), Text::Autoformat (intelligent automatic reformatting of plaintext), Switch (Perl's missing case statement), NEXT (resumptive method dispatch), Filter::Simple (Perl-based source code manipulation), Quantum::Superpositions (auto-parallelization of serial code using a quantum mechanical metaphor), and Lingua::Romana::Perligata (programming in Latin). Most of his time is now spent working with Larry Wall on the design of the new Perl 6 programming language.

Excerpted from Perl Best Practices by Damian Conway. Copyright © 2005. Reprinted by permission. All rights reserved.:
CHAPTER 9 Subroutines

If you have a procedure with ten parameters, you probably missed some.
—Alan Perlis

Subroutines are one of the two primary problem-decomposition tools available in Perl, modules being the other. They provide a convenient and familiar way to break a large task down into pieces that are small enough to understand, concise enough to implement, focused enough to test, and simple enough to debug.

In effect, subroutines allow programmers to extend the Perl language, creating useful new behaviours with sensible names. Having written a subroutine, you can immediately forget about its internals, and focus solely on the abstracted process or function it implements.

So the extensive use of subroutines helps to make a program more modular, which in turn makes it more robust and maintainable. Subroutines also make it possible to structure the actions of programs hierarchically, at increasingly high levels of abstraction, which improves the readability of the resulting code.

That’s the theory, at least. In practice, there are plenty of ways that using subroutines can make code less robust, buggier, less concise, slower, and harder to understand. The guidelines in this chapter focus on avoiding those outcomes.

Call Syntax

Call subroutines with parentheses but without a leading &

It’s possible to call a subroutine without parentheses, if it has already been declared in the current namespace:
sub coerce

# and later...

my $expected_count = coerce $input, $INTEGER, $ROUND_ZERO;

But that approach can quickly become much harder to understand:

fix my $gaze, upon each %suspect;

More importantly, leaving off the parentheses on subroutines makes them harder to distinguish from builtins, and therefore increases the mental search space when the reader is confronted with either type of construct. Your code will be easier to read and understand if the subroutines always use parentheses and the built-in functions always don’t:

my $expected_count = coerce($input, $INTEGER, $ROUND_ZERO);

fix(my $gaze, upon(each %suspect));

Some programmers still prefer to call a subroutine using the ancient Perl 4 syntax, with an ampersand before the subroutine name:

&coerce($input, $INTEGER, $ROUND_ZERO);

&fix(my $gaze, &upon(each %suspect));

Perl 5 does support that syntax, but nowadays it’s unnecessarily cluttered. Barewords is forbidden under use strict, so there are far fewer situations in which a subroutine call has to be disambiguated.

On the other hand, the ampersand itself is visually ambiguous; it can also signify a bitwise AND operator, depending on context. And context can be extremely subtle:

$curr_pos = tell &get_mask( ); # means: tell(get_mask( ))
$curr_time = time &get_mask( ); # means: time() & get_mask( )

Prefixing with & can also lead to other subtle (but radical) differences in behaviour:

sub fix {
my (@args) = @_ ? @_ : $_; # Default to fixing $_ if no args provided

# Fix each argument by grammatically transforming it and then printing it...
for my $arg (@args) {
$arg =~ s/\A the \b/some/xms;
$arg =~ s/e \z/es/xms;
print $arg;
}

return;
}

# and later...

&fix('the race'); # Works as expected, prints: 'some races'

for ('the gaze', 'the adhesive') {

&fix; # Doesn't work as expected: looks like it should fix($_),
# but actually means fix(@_), using this scope's @_!
# See the 'perlsub' manpage for details
}

All in all, it’s clearer, less ambiguous, and less error-prone to reserve the &subname syntax for taking references to named subroutines:

set_error_handler( \&log_error );

Just use parentheses to indicate a subroutine call:

coerce($input, $INTEGER, $ROUND_ZERO);

fix( my $gaze, upon(each %suspect) );

$curr_pos = tell get_mask( );
$curr_time = time & get_mask( );

And always use the parentheses when calling a subroutine, even when the subroutine takes no arguments (like get_mask( )). That way it’s immediately obvious that you intend a subroutine call:

curr_obj( )->update($status); # Call curr_obj( ) to get an object,
# then call the update( )method on that object

and not a typename:

curr_obj->update($status); # Maybe the same (if currobj( ) already declared),
# otherwise call update( ) on class 'curr_obj'

Homonyms

Don’t give subroutines the same names as built-in functions

If you declare a subroutine with the same name as a built-in function, subsequent invocations of that name will still call the builtin...except when occasionally they don’t. For example:

sub lock {
my ($file) = @_;
return flock $file, LOCK_SH;
}

sub link {
my ($text, $url) = @_;
return qq{$text};
}

lock($file); # Calls 'lock' subroutine; built-in 'lock' hidden
print link($text, $text_url); # Calls built-in 'link'; 'link' subroutine hidden

Perl considers some of its builtins (like link) to be "more built-in" than others (like lock), and chooses accordingly whether to call your subroutine of the same name. If the builtin is "strongly built-in", an ambiguous call will invoke it, in preference to any subroutine of the same name. On the other hand, if the builtin is "weakly builtin", an ambiguous call will invoke the subroutine of the same name instead.

Even if these subroutines did always work as expected, it’s simply too hard to maintain code where the program-specific subroutines and the language’s keywords overlap:

sub crypt { return "You're in the tomb of @_\n" }
sub map { return "You have found a map of @_\n" }
sub chop { return "You have chopped @_\n" }
sub close { return "The @_ is now closed\n" }
sub hex { return "A hex has been cast on @_\n" }

print crypt( qw( Vlad Tsepes ) ); # Subroutine or builtin?

for my $reward (qw( treasure danger) ) {
print map($reward, 'in', $location); # Subroutine or builtin?
}

print hex('the Demon'); # Subroutine or builtin?
print chop('the Demon'); # Subroutine or builtin?



Customer Reviews
Average Rating:  out of 5 stars

Rating: 5 out of 5 stars - Detoxing Perl - A must for anyone who writes longer Perl scripts
The Perl motto "there's more than one way to do it" comes to bite you as you start to write longer and longer codes. Other people's Perl "codes" are often totally intractable and my scripts were probably even worse... Where does it all go wrong? Most of us who "code" in Perl started off writing short scripts to do simple tasks and it just grew - still looking like scripts but longer, meaner and weirder.

The Best Practices starts off with formatting. Seemingly trivial but it really makes ... Read More



Rating: 5 out of 5 stars - No Perl bookshelf should be without it...
I have to agree with the previous reviewers that this book will seriously change the way you code Perl. Having read this you will write more readable, more maintainable, more thoughtful, better documented (and better self-documenting) code... and this in addition to learning techniques to simply writing *better* code.

Use the downloadable files to amend your Emacs/Vim config to the PBP way, and run all your pre-release code through perltidy and Perl::Critic (using the PBP theme) and you ... Read More



Rating: 5 out of 5 stars - Best Perl book ever
Not only the best Perl book I've ever read, it's also one of the best programming language books, period.

If you've ever programmed C++ or Java, you'll know how revered the likes of Effective C++ and Effective Java are, a series of tips, suggestions, idioms, advice and commandments. This is the equivalent for Perl, except it's even more thorough and covers even more ground, from brace layout and statement formatting, to regexes, unit testing, documentation and command line parsing.
Read More



Rating: 5 out of 5 stars - Wow
I have been programming computers for the last 22 years. I loved Perl from the moment I set eyes on it. After I receiving my copy of Damian Conway's new book I love Perl even more.


Availability: Usually dispatched within 24 hours

Buy Now!

 


Browse for similar items by category:

 

UK Store
front page
Back to listings
I can put something here:
But for now I don't know what so I will just leave this here as a placeholder.
Shopping Cart
Shopping cart is empty

 

Offers from our
UK Store

Reference Books

Almanacs & Yearbooks

Consumer Guides

Dictionaries & Thesauri

Directories

Encyclopaedias

English as a Foreign Language

Etiquette

Family & Lifestyle

Foreign Languages

Fun Facts & Trivia

Language

Library & Information Sciences

Obituaries

Other Reference By Subject

Publishing & Books

Quotations

Subject & Exam Guides

Transport

Writing

buy cheap software online - UK store
Software

Art, Music & Literature

Astronomy & Space

Bird Guides

Children's Reference

Dictionaries & Thesauri

Directories

Encyclopaedias

Geography & Maps

History & Culture

Human Body & Medicine

Languages

Religion

Route Planning

Science & Nature

Sports

Travel & Leisure Guides

 

Yesterday's most viewed products

Now That's What I Call Music Vol.69
Now That's What I Call Music Vol.69
[ Music ]
[ viewed 22 times ]

Brabantia Smartfix (H) 40-50 litre Bin Liners (30 bags)
Brabantia Smartfix (H) 40-50 litre Bin Liners (30 bags)
[ Kitchen & Housewares ]
[ viewed 6 times ]

HoMedics BKP 100 5-Motor Back Massager With Heat
HoMedics BKP 100 5-Motor Back Massager With Heat
[ Health & Personal Care ]
[ viewed 5 times ]

Freddie As F.R.O.7 [1987]
Freddie As F.R.O.7 [1987]
[ VHS ]
[ viewed 4 times ]

Deep in My Heart [1954]
Deep in My Heart [1954]
[ VHS ]
[ viewed 4 times ]

See all

 

Products viewed most in last 7 days

Now That's What I Call Music Vol.69
Now That's What I Call Music Vol.69
[ Music ]
[ viewed 55 times ]

Kelly Brook A3 Calendar 2008
Kelly Brook A3 Calendar 2008
[ Books ]
[ viewed 23 times ]

ASROCK K8UPGRADE-NF3 ATX MOTHERBOARD, AMD SOCKET 754 CPU SUPPORT, NVIDIA NFORCE3 250 CHIPSET, 1 X AGP 8x, 4 X PCI SLOTS, 2 X DDR 400, 10/100 LAN, 8 CHANNEL AUDIO, 2 X SATA, 2 X IDE 133/100/66, 6 X USB 2.0
ASROCK K8UPGRADE-NF3 ATX MOTHERBOARD, AMD SOCKET 754 CPU SUPPORT, NVIDIA NFORCE3 250 CHIPSET, 1 X AGP 8x, 4 X PCI SLOTS, 2 X DDR 400, 10/100 LAN, 8 CHANNEL AUDIO, 2 X SATA, 2 X IDE 133/100/66, 6 X USB 2.0
[ Electronics ]
[ viewed 19 times ]

Brabantia Smartfix (H) 40-50 litre Bin Liners (30 bags)
Brabantia Smartfix (H) 40-50 litre Bin Liners (30 bags)
[ Kitchen & Housewares ]
[ viewed 19 times ]

Bach: Solo Keyboard Works
Bach: Solo Keyboard Works
[ Music ]
[ viewed 12 times ]

See all

Support Dean

Helping people with computers is my business. If you found my site useful and it saved you time or money I would appreciate a donation.

Donate
Once Monthly
AmountCurrency
Amount
Currency
Featured Puzzle Related Books:

 

Electronics

 

SOFTWARE

 

Puzzle Toys

 

Featured Products:
Electronic Sudoku

 

Featured Computing Books:
Computers and Internet
Computer Peripherals
Electronics
All Electronics
Software
Software
Video Games
Video Games
spread firefox
Please visit our sponsors:
 
top

Dean Marshall. © 1999 - 2008 All rights reserved.
Website design and maintenance by Dean Marshall

Page generated in 0.072 seconds
Amazon Products Feed script by MrRat : Premium APF Mods from Dean Marshall : Open source APF Mods from APFMods.com