Development Cycles
  Home arrow Development Cycles arrow Thoughts on the Craft of Programming: Abst...
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Moblin 
JMSL Numerical Library 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
DEVELOPMENT CYCLES

Thoughts on the Craft of Programming: Abstraction, Refactoring, and How Changes Introduce Bugs
By: The Rational Edge
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 3
    2003-08-13

    Table of Contents:
  • Thoughts on the Craft of Programming: Abstraction, Refactoring, and How Changes Introduce Bugs
  • Bugs
  • Cleaning Code
  • Vowels
  • An Aside on Programming by Contract
  • Lesson

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Thoughts on the Craft of Programming: Abstraction, Refactoring, and How Changes Introduce Bugs


    (Page 1 of 6 )

    It is inevitable that bugs begin to pop up when a piece of code is changed in a software application. What is the solution to this frequent annoyance? Read this article to find the remedy.

    IllustrationThis article is about the craft of programming, which comprises both scientific and artistic elements. By "scientific," I mean that programming concerns logical propositions that are objectively true or false, and by "artistic," I'm referring to the many ways to formulate these propositions and the need to make subjective judgments about which are good and which are bad. When discussing software development, we tend to bandy about the grand concepts of modularity and abstraction without a real understanding of how these concepts are reflected in our everyday work. When it comes to improving and refactoring chunks of software code under development, I believe it's worth exploring the reasons -- the motivations -- behind the code improvements. I think there are some general principles that may guide programmers toward producing code of higher quality.

    One of the problems, of course, is that in making code changes, we frequently introduce new errors into the code, even when we are being careful, even when the change is apparently simple and the existing code is well-structured. So to make my ideas concrete, I will examine a fragment of code known to contain an error, and I will explain the error and illustrate a simple change that will correct it. I will then make several improvements to the code to make it easier to read and maintain.

    Finally, I will add a new feature. The piece of code used here is trivially simple, much too small to really show the advantages of modularity and refactoring, but I believe it is big enough to illustrate the basic principles. It's written in C and uses native types, because that's how the code that originated all this discussion was designed; and I have kept the K&R style because I feel it is, as Tony Hoare1 said about Algol-60, such an improvement on all its successors. For clarity, I have omitted the #include statements that would be required.

    More Development Cycles Articles
    More By The Rational Edge


     

    DEVELOPMENT CYCLES ARTICLES

    - Genetic Algorithm Techniques
    - Greedy Strategy as an Algorithm Technique
    - Divide and Conquer Algorithm Technique
    - The Backtracking Algorithm Technique
    - More Pattern Matching Algorithms: B-M
    - Pattern Matching Algorithms Demystified: KMP
    - Coding Standards
    - A Peek into the Future: Transactional Memory
    - Learning About the Graph Construct using Gam...
    - Learning About the Graph Construct using Gam...
    - Learning About the Graph Construct using Gam...
    - How to Strike a Match
    - Entity Relationship Modeling
    - Tame the Beast by Matching Similar Strings
    - 5 Web Design Tips You Can't Live Without






    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
    Stay green...Green IT