The Elements of Programming Style: Difference between revisions

Content deleted Content added
+cat and add 2009 lecture
m Lessons: replaced: recursively-defined → recursively defined
 
(5 intermediate revisions by 5 users not shown)
Line 1:
{{Short description|1978 book by Brian W. Kernighan and P. J. Plauger}}
{{third -party|date=February 2015}}
{{italic title}}
 
{{Infobox book
| italic title = <!--(see above)-->
Line 53 ⟶ 54:
==Lessons==
Its lessons are summarized at the end of each section in [[Aphorism|pithy maxims]], such as "Let the machine do the dirty work":
# Write clearly don't be too clever.
# Say what you mean, simply and directly.
# Use library functions whenever feasible.
# Avoid too many temporary variables.
# Write clearly don't sacrifice clarity for efficiency.
# Let the machine do the dirty work.
# Replace repetitive expressions by calls to common functions.
Line 68 ⟶ 69:
# Modularize. Use procedures and functions.
# Avoid gotos completely if you can keep the program readable.
# Don't patch bad code rewrite it.
# Write and test a big program in small pieces.
# Use recursive procedures for recursively- defined data structures.
# Test input for plausibility and validity.
# Make sure input doesn't violate the limits of the program.
Line 99 ⟶ 100:
# Make sure special cases are truly special.
# Keep it simple to make it faster.
# Don't diddle code to make it faster find a better algorithm.
# Instrument your programs. Measure before making efficiency changes.
# Make sure comments and code agree.
# Don't just echo the code with comments make every comment count.
# Don't comment bad code rewrite it.
# Use variable names that mean something.
# Use statement labels that mean something.
# Format a program to help the reader understand it.
# Document your data layouts.
# Don't over-comment.
 
 
Modern readers may find it a shortcoming that its examples use older [[procedural programming languages]] ([[Fortran]] and [[PL/I]]) whichthat are quite different from those popular today. Few of today's popular languages had been invented when this book was written. However, many of the book's points that generally concern stylistic and structural issues transcend the details of particular languages.
 
==Reception==
Line 124:
==External links==
*[http://www.softwarequotes.com/showquotes.aspx?id=574&name=P. J. Plauger selected quotes from ''The Elements of Programming Style'']
*{{YouTube|id=8SUkrR7ZfTA|title=Elements of Programming Style - 2009 Brian Kernighan talk at Princeton}}
 
{{DEFAULTSORT:Elements Of Programming Style, The}}
[[Category:1974 non-fiction books]]
[[Category:Computer programming books]]
[[Category:Collaborative non-fiction books]]
[[Category:McGraw-Hill books]]