SlideShare a Scribd company logo
Writing Readable Code
            Eddie Haber
   Sr Developer, Reflexions Data




                            Reflexions on Coding
                                9.7.2012
Writing Readable Code
Overview
1. What is Readable Code?
2. Why is it So Important?
3. How Code Gets Unreadable
4. Patterns that Make Code Hard to Read:
 ● Deep Nesting
 ● Unnecessary Generalization
 ● Ambiguous Names
 ● Hard to Follow Flow of Execution
 ● Code Style vs Individualism
 ● Code Comments
5. Best Practices
What is Readable Code?




                         Source: Head First Labs
What is Readable Code?
Reads like natural language
What is Readable Code?
Reads like natural language

Spaced into digestible chunks like paragraphs
What is Readable Code?
Reads like natural language

Spaced into digestible chunks like paragraphs

Explains Itself
What is Readable Code?
Reads like natural language

Spaced into digestible chunks like paragraphs

Explains Itself

Tells a story: The Spec
Why is it So Important?
Why is it So Important?
Saves you, your team, your client time.
Why is it So Important?
Saves you, your team, your client time.

Memories fade with time.
Why is it So Important?
Saves you, your team, your client time.

Memories fade with time.

Many projects go undocumented. Readable
code can be documentation in itself.
Why is it So Important?
Saves you, your team, your client time.

Memories fade with time.

Many projects go undocumented. Readable
code can be documentation in itself.

Fewer regression bugs.
Why is it So Important?
Hard-to-read code seems more complex and
harder to edit than it really is.
How Code Gets Unreadable



Business logic can be
arbitrary, complex,
even contradictory.
How Code Gets Unreadable


                  Polluted over time

                  Cruft

                  Inefficient edits
Software applications are the most complex
    man-made constructs in existence.




                            Source: scottmccloud.com
Patterns that Make Code Hard to Read
                 · Deep Nesting
                 · Unnecessary Generalization
                 · Ambiguous Names
                 · Hard to Follow Flow of
                   Execution
                 · Code Style vs Individualism
                 · Code Comments
1.Deep Nesting
Patterns that Make Code Hard to Read
4. Patterns: Deep Nesting
Writing Readable Code
Writing Readable Code
Writing Readable Code
Writing Readable Code
Writing Readable Code
Writing Readable Code
1.Deep Nesting
Nesting is hard to read and edit.

Return early from loops and functions.

Use continue, break, return.

Meat of function ideally at first level of
indentation
2.Unnecessary
   Generalization
Patterns that Make Code Hard to Read
2.Unnecessary Generalization
Never abstract for a single implementation.
2.Unnecessary Generalization
Never abstract for a single implementation.

// 10 lines of code
// that calls a
// gateway once

vs

// a gateway class
// with a single
// implementation
3.Ambiguous Names
Patterns that Make Code Hard to Read
3.Ambiguous Names
Is that string you're about to use to query
authors from a SQL table a...

                $qry                 $sql
                         $search
  $select
                                   $author_qry
                  $authors_sql

    $db_query              $query_authors
3.Ambiguous Names
Is the result that comes back a...

                   $search
 $dbh
                                   $authors_list
        $rslt
                 $author_result
                                     $response

     $results
                       $auth_dbh
3.Ambiguous Names
Be consistent. Use clear simple naming.

$db = new Database_Adapter();
$sql = "SELECT * FROM authors";
$result = $db->query($sql);




$sql (goes to) $db (delivers) $result
3.Ambiguous Names
Sneaky Boolean Variables...
if ($fail_gateway)...


Is it true if failed, or false if failed?
3.Ambiguous Names
Mysterious Boolean Parameters...
send_mail($recipients, $msg, true);
3.Ambiguous Names
Mysterious Boolean Parameters...
send_mail($recipients, $msg, true);


Use constants (they're free!) to make codeflow
readable...
const('DELETE_ALL_ACCOUNTS', true);
const('DO_NOT_DELETE_ACCOUNTS', false);
send_mail($recipients, $msg, DELETE_ALL_ACCOUNTS);
3.Ambiguous Names
Avoid excessive abbreviation.

Abbreviations are arbitrary and hard to
remember.
3.Ambiguous Names
Avoid excessive abbreviation.

Abbreviations are arbitrary and hard to
remember.
            $srchBttn ?
Was it...   $searchBtn ?
            $schBtn ?
            $srchBtn ?


Be explicit.    $search_button
4.Hard to Follow
Flow of Execution
Patterns that Make Code Hard to Read
4.Hard to Follow Flow of Execution
Reading code means following the flow of
execution.
4.Hard to Follow Flow of Execution
Transitional variables
$string = "Three Card Monte";
$lowercase = strtolower($string);
$ready_for_web = htmlentities($lowercase);
$view->name = $ready_for_web;
4.Hard to Follow Flow of Execution
Transitional variables
$string = "Three Card Monte";
$lowercase = strtolower($string);
$ready_for_web = htmlentities($lowercase);
$view->name = $ready_for_web;


Less code = Less reading
$string = "Three Card Monte";
$view->name = htmlentities(strtolower($string));
4.Hard to Follow Flow of Execution
Status codes and ids in code are mysteries.
$order->set_order_type(5);
4.Hard to Follow Flow of Execution
Status codes and ids in code are mysteries.
$order->set_order_type(5);



Use strings or constants for concrete statuses.
$order->update_status(OrderStatus::PAID);
4.Hard to Follow Flow of Execution
Status codes and ids in code are mysteries.
$order->set_order_type(5);



Use strings or constants for concrete statuses.
$order->update_status(OrderStatus::PAID);



Reference concrete data by string
$sql = "SELECT * FROM role WHERE id = 1";
$sql = "SELECT * FROM role WHERE role = 'admin';
4.Hard to Follow Flow of Execution
Functions that return arbitrary data:
$monster_array = $book->process_authors();
print $monster_array[0]['author']['first_name'];
4.Hard to Follow Flow of Execution
Functions that return arbitrary data:
$monster_array = $book->process_authors();
print $monster_array[0]['author']['first_name'];


●   Return arrays of objects instead
    or an iterator

●   Make a (documented) class for the
    return objects

●   Sample of the returned data
    structure in the comment block
5.Code Style vs.
   Individualism
Patterns that Make Code Hard to Read
5.Code Style vs. Individualism
Camelcase or underscore?

Curly braces with or without conditionals?

Use the formats and conventions of the
language or framework you're working with.
5.Code Style vs. Individualism
Funny variable names, comments, and
methods.

Just make sure they explain functionality.


$dull_boy = work_all_day($Jack_Torrence);
5.Code Style vs. Individualism
Whitespace is crucially important even when
the compiler doesn't mind.

                        ●   If tabs, stay with tabs

                        ●   If spaces, stay with spaces

                        ●   Indent consistently - indentation
                            is a queue for reading
6.Code Comments
Patterns that Make Code Hard to Read
6.Code Comments
Helpful vs. unhelpful comments
// ping the server                // ping server to make
$results = ping($server);         // sure still running and
                                  // log results
// check the results        vs.   $results = ping($server);
check_results($results);          check_results($results);
                                  log_results($results);
// log the results                exit;
log_results($results);

// exit
exit;
6.Code Comments
Who are you talking to?

Avoid unhelpful questions in comments
// Why is this even here?



Make comments clear and useful
// Magic. Do not touch.
6.Code Comments
Use DocBlock style blocks...

● Over all functions/methods

● Define @params and @returns

● If business rules involved, give a synopsis of
  what the method does.
6.Code Comments




                  Source: NetTutsPlus
Best Practices
Best Practices
Refactor! The first pass is usually the least
efficient implementation.



                         ●   Jeuje code
                         ●   Transitional variables
                         ●   Return early
                         ●   Add comments
Best Practices
Break down large tasks into smaller ones.


                       ●   More private and protected
                           "helper" methods.

                       ●   Objects format and filter their
                           own output.
Best Practices
DRY - Don't Repeat Yourself. Use libraries and
conventions already established

                    ●   In the class (method already exists?)

                    ●   In the libs (utility already exists?)

                    ●   In the framework (component already
                        exists?)

                    ●   On the web (website already exists?)
//
//   Dear maintainer:
//
//   Once you are done trying to 'optimize' this routine,
//   and have realized what a terrible mistake that was,
//   please increment the following counter as a warning
//   to the next guy:
//
//   total_hours_wasted_here = 42
//




                                             Reflexions on Coding
                                                 9.7.2012

More Related Content

What's hot (19)

PPTX
SOLID, DRY, SLAP design principles
Sergey Karpushin
 
PPTX
Java Script An Introduction By HWA
Emma Wood
 
PDF
Why Ruby
Daniel Lv
 
PPTX
Clean Code: Stop wasting my time
Edorian
 
PDF
Grooming with Groovy
Dhaval Dalal
 
PPTX
Coding standards for java
maheshm1206
 
PPTX
Coding standard and coding guideline
Dhananjaysinh Jhala
 
PPSX
Coding standard
FAROOK Samath
 
PDF
Dependency Injection for PHP
mtoppa
 
PDF
Dart, Darrt, Darrrt
Jana Moudrá
 
PDF
DDD/CQRS - I must learn to repeat myself
Douglas Reith
 
PDF
Javascript Roadmap - The Basics
Aswin Barath
 
PPTX
Javascript functions
Alaref Abushaala
 
PDF
Php melb cqrs-ddd-predaddy
Douglas Reith
 
PPTX
Java script
Prarthan P
 
PDF
JavaScript and EPUB: Making interactive ebooks - Christina Truong - ebookcraf...
BookNet Canada
 
PPTX
Java script
Sadeek Mohammed
 
PDF
Java 例外處理壞味道與重構技術
teddysoft
 
PDF
Programming style
Sebastian Pożoga
 
SOLID, DRY, SLAP design principles
Sergey Karpushin
 
Java Script An Introduction By HWA
Emma Wood
 
Why Ruby
Daniel Lv
 
Clean Code: Stop wasting my time
Edorian
 
Grooming with Groovy
Dhaval Dalal
 
Coding standards for java
maheshm1206
 
Coding standard and coding guideline
Dhananjaysinh Jhala
 
Coding standard
FAROOK Samath
 
Dependency Injection for PHP
mtoppa
 
Dart, Darrt, Darrrt
Jana Moudrá
 
DDD/CQRS - I must learn to repeat myself
Douglas Reith
 
Javascript Roadmap - The Basics
Aswin Barath
 
Javascript functions
Alaref Abushaala
 
Php melb cqrs-ddd-predaddy
Douglas Reith
 
Java script
Prarthan P
 
JavaScript and EPUB: Making interactive ebooks - Christina Truong - ebookcraf...
BookNet Canada
 
Java script
Sadeek Mohammed
 
Java 例外處理壞味道與重構技術
teddysoft
 
Programming style
Sebastian Pożoga
 

Similar to Writing Readable Code (20)

PPTX
Clean Code - Writing code for human
NETKO Solution
 
PPTX
Php rules
christopher mabunda
 
PDF
WordCamp US: Clean Code
mtoppa
 
PPTX
Clean code, Feb 2012
cobyst
 
PPTX
Code reviews
Roger Xia
 
PPTX
Php rules
christopher mabunda
 
PDF
Clean Code
Chris Farrell
 
PPTX
Coding conventions
systemcrashed
 
PPTX
Clean code - DSC DYPCOE
Patil Shreyas
 
PDF
Patterns, Code Smells, and The Pragmattic Programmer
Jason McCreary
 
PDF
Hardcore JavaScript – Write it Right
Mike Wilcox
 
PDF
The art of readable code (ch1~ch4)
Ki Sung Bae
 
PDF
The art of readable code (ch1~ch4)
Ki Sung Bae
 
PDF
WordCamp Nashville: Clean Code for WordPress
mtoppa
 
PDF
Does your code spark joy? Refactoring techniques to make your life easier.
Juciellen Cabrera
 
PPT
How to be a Guru Coder
TeraTech, Inc
 
PDF
Clean code & design patterns
Pascal Larocque
 
PDF
Good Coding Practices with JavaScript
🏁 Pierre-Henry Soria 💡
 
PPT
c-coding-standards-and-best-programming-practices.ppt
VinayakHospet1
 
PPS
CS101- Introduction to Computing- Lecture 44
Bilal Ahmed
 
Clean Code - Writing code for human
NETKO Solution
 
WordCamp US: Clean Code
mtoppa
 
Clean code, Feb 2012
cobyst
 
Code reviews
Roger Xia
 
Clean Code
Chris Farrell
 
Coding conventions
systemcrashed
 
Clean code - DSC DYPCOE
Patil Shreyas
 
Patterns, Code Smells, and The Pragmattic Programmer
Jason McCreary
 
Hardcore JavaScript – Write it Right
Mike Wilcox
 
The art of readable code (ch1~ch4)
Ki Sung Bae
 
The art of readable code (ch1~ch4)
Ki Sung Bae
 
WordCamp Nashville: Clean Code for WordPress
mtoppa
 
Does your code spark joy? Refactoring techniques to make your life easier.
Juciellen Cabrera
 
How to be a Guru Coder
TeraTech, Inc
 
Clean code & design patterns
Pascal Larocque
 
Good Coding Practices with JavaScript
🏁 Pierre-Henry Soria 💡
 
c-coding-standards-and-best-programming-practices.ppt
VinayakHospet1
 
CS101- Introduction to Computing- Lecture 44
Bilal Ahmed
 
Ad

Recently uploaded (20)

PDF
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
PDF
Biography of Daniel Podor.pdf
Daniel Podor
 
PDF
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
PPTX
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
PPTX
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
PDF
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
PDF
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
PDF
Blockchain Transactions Explained For Everyone
CIFDAQ
 
PDF
Presentation - Vibe Coding The Future of Tech
yanuarsinggih1
 
PDF
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
PPTX
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
PDF
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
PDF
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
PDF
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
PDF
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
PDF
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
PDF
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
PDF
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
Biography of Daniel Podor.pdf
Daniel Podor
 
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
Blockchain Transactions Explained For Everyone
CIFDAQ
 
Presentation - Vibe Coding The Future of Tech
yanuarsinggih1
 
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
Ad

Writing Readable Code

  • 1. Writing Readable Code Eddie Haber Sr Developer, Reflexions Data Reflexions on Coding 9.7.2012
  • 3. Overview 1. What is Readable Code? 2. Why is it So Important? 3. How Code Gets Unreadable 4. Patterns that Make Code Hard to Read: ● Deep Nesting ● Unnecessary Generalization ● Ambiguous Names ● Hard to Follow Flow of Execution ● Code Style vs Individualism ● Code Comments 5. Best Practices
  • 4. What is Readable Code? Source: Head First Labs
  • 5. What is Readable Code? Reads like natural language
  • 6. What is Readable Code? Reads like natural language Spaced into digestible chunks like paragraphs
  • 7. What is Readable Code? Reads like natural language Spaced into digestible chunks like paragraphs Explains Itself
  • 8. What is Readable Code? Reads like natural language Spaced into digestible chunks like paragraphs Explains Itself Tells a story: The Spec
  • 9. Why is it So Important?
  • 10. Why is it So Important? Saves you, your team, your client time.
  • 11. Why is it So Important? Saves you, your team, your client time. Memories fade with time.
  • 12. Why is it So Important? Saves you, your team, your client time. Memories fade with time. Many projects go undocumented. Readable code can be documentation in itself.
  • 13. Why is it So Important? Saves you, your team, your client time. Memories fade with time. Many projects go undocumented. Readable code can be documentation in itself. Fewer regression bugs.
  • 14. Why is it So Important? Hard-to-read code seems more complex and harder to edit than it really is.
  • 15. How Code Gets Unreadable Business logic can be arbitrary, complex, even contradictory.
  • 16. How Code Gets Unreadable Polluted over time Cruft Inefficient edits
  • 17. Software applications are the most complex man-made constructs in existence. Source: scottmccloud.com
  • 18. Patterns that Make Code Hard to Read · Deep Nesting · Unnecessary Generalization · Ambiguous Names · Hard to Follow Flow of Execution · Code Style vs Individualism · Code Comments
  • 19. 1.Deep Nesting Patterns that Make Code Hard to Read
  • 20. 4. Patterns: Deep Nesting
  • 27. 1.Deep Nesting Nesting is hard to read and edit. Return early from loops and functions. Use continue, break, return. Meat of function ideally at first level of indentation
  • 28. 2.Unnecessary Generalization Patterns that Make Code Hard to Read
  • 29. 2.Unnecessary Generalization Never abstract for a single implementation.
  • 30. 2.Unnecessary Generalization Never abstract for a single implementation. // 10 lines of code // that calls a // gateway once vs // a gateway class // with a single // implementation
  • 31. 3.Ambiguous Names Patterns that Make Code Hard to Read
  • 32. 3.Ambiguous Names Is that string you're about to use to query authors from a SQL table a... $qry $sql $search $select $author_qry $authors_sql $db_query $query_authors
  • 33. 3.Ambiguous Names Is the result that comes back a... $search $dbh $authors_list $rslt $author_result $response $results $auth_dbh
  • 34. 3.Ambiguous Names Be consistent. Use clear simple naming. $db = new Database_Adapter(); $sql = "SELECT * FROM authors"; $result = $db->query($sql); $sql (goes to) $db (delivers) $result
  • 35. 3.Ambiguous Names Sneaky Boolean Variables... if ($fail_gateway)... Is it true if failed, or false if failed?
  • 36. 3.Ambiguous Names Mysterious Boolean Parameters... send_mail($recipients, $msg, true);
  • 37. 3.Ambiguous Names Mysterious Boolean Parameters... send_mail($recipients, $msg, true); Use constants (they're free!) to make codeflow readable... const('DELETE_ALL_ACCOUNTS', true); const('DO_NOT_DELETE_ACCOUNTS', false); send_mail($recipients, $msg, DELETE_ALL_ACCOUNTS);
  • 38. 3.Ambiguous Names Avoid excessive abbreviation. Abbreviations are arbitrary and hard to remember.
  • 39. 3.Ambiguous Names Avoid excessive abbreviation. Abbreviations are arbitrary and hard to remember. $srchBttn ? Was it... $searchBtn ? $schBtn ? $srchBtn ? Be explicit. $search_button
  • 40. 4.Hard to Follow Flow of Execution Patterns that Make Code Hard to Read
  • 41. 4.Hard to Follow Flow of Execution Reading code means following the flow of execution.
  • 42. 4.Hard to Follow Flow of Execution Transitional variables $string = "Three Card Monte"; $lowercase = strtolower($string); $ready_for_web = htmlentities($lowercase); $view->name = $ready_for_web;
  • 43. 4.Hard to Follow Flow of Execution Transitional variables $string = "Three Card Monte"; $lowercase = strtolower($string); $ready_for_web = htmlentities($lowercase); $view->name = $ready_for_web; Less code = Less reading $string = "Three Card Monte"; $view->name = htmlentities(strtolower($string));
  • 44. 4.Hard to Follow Flow of Execution Status codes and ids in code are mysteries. $order->set_order_type(5);
  • 45. 4.Hard to Follow Flow of Execution Status codes and ids in code are mysteries. $order->set_order_type(5); Use strings or constants for concrete statuses. $order->update_status(OrderStatus::PAID);
  • 46. 4.Hard to Follow Flow of Execution Status codes and ids in code are mysteries. $order->set_order_type(5); Use strings or constants for concrete statuses. $order->update_status(OrderStatus::PAID); Reference concrete data by string $sql = "SELECT * FROM role WHERE id = 1"; $sql = "SELECT * FROM role WHERE role = 'admin';
  • 47. 4.Hard to Follow Flow of Execution Functions that return arbitrary data: $monster_array = $book->process_authors(); print $monster_array[0]['author']['first_name'];
  • 48. 4.Hard to Follow Flow of Execution Functions that return arbitrary data: $monster_array = $book->process_authors(); print $monster_array[0]['author']['first_name']; ● Return arrays of objects instead or an iterator ● Make a (documented) class for the return objects ● Sample of the returned data structure in the comment block
  • 49. 5.Code Style vs. Individualism Patterns that Make Code Hard to Read
  • 50. 5.Code Style vs. Individualism Camelcase or underscore? Curly braces with or without conditionals? Use the formats and conventions of the language or framework you're working with.
  • 51. 5.Code Style vs. Individualism Funny variable names, comments, and methods. Just make sure they explain functionality. $dull_boy = work_all_day($Jack_Torrence);
  • 52. 5.Code Style vs. Individualism Whitespace is crucially important even when the compiler doesn't mind. ● If tabs, stay with tabs ● If spaces, stay with spaces ● Indent consistently - indentation is a queue for reading
  • 53. 6.Code Comments Patterns that Make Code Hard to Read
  • 54. 6.Code Comments Helpful vs. unhelpful comments // ping the server // ping server to make $results = ping($server); // sure still running and // log results // check the results vs. $results = ping($server); check_results($results); check_results($results); log_results($results); // log the results exit; log_results($results); // exit exit;
  • 55. 6.Code Comments Who are you talking to? Avoid unhelpful questions in comments // Why is this even here? Make comments clear and useful // Magic. Do not touch.
  • 56. 6.Code Comments Use DocBlock style blocks... ● Over all functions/methods ● Define @params and @returns ● If business rules involved, give a synopsis of what the method does.
  • 57. 6.Code Comments Source: NetTutsPlus
  • 59. Best Practices Refactor! The first pass is usually the least efficient implementation. ● Jeuje code ● Transitional variables ● Return early ● Add comments
  • 60. Best Practices Break down large tasks into smaller ones. ● More private and protected "helper" methods. ● Objects format and filter their own output.
  • 61. Best Practices DRY - Don't Repeat Yourself. Use libraries and conventions already established ● In the class (method already exists?) ● In the libs (utility already exists?) ● In the framework (component already exists?) ● On the web (website already exists?)
  • 62. // // Dear maintainer: // // Once you are done trying to 'optimize' this routine, // and have realized what a terrible mistake that was, // please increment the following counter as a warning // to the next guy: // // total_hours_wasted_here = 42 // Reflexions on Coding 9.7.2012