beanOnce upon a time, in a far off kingdom named 1996, there was a developer named Jack. Jack worked for a poor company that could barely afford to buy grain with which to bake objects; they had to make do with Delphi forms, pinching and scraping what they could into an application. Instead of methods, they were stuck with button events, from which they milked database tables.

One day, Jack came to realize that the button events were growing old, and soon, no more good could be wrung from them. Sadly, he knew it was time to retire his old Delphi code. But what could he live on?

"I will help you," said Jack's neighbor, another developer. "Take these magic variables and plant them in the soil, and soon you will have a beautiful garden of maintainable code instead of the dried-up old husk you milk." And so Jack planted the variables and went to sleep.

When he woke up, he found an amazing sight:

 
TForm1.Button131Click(Sender: TObject);
var
 Row1Type1Count, Row2Type1Count, Row3Type1Count, Row4Type1Count, Row5Type1Count,
 Row1Type2Count, Row2Type2Count, Row3Type2Count, Row4Type2Count, Row5Type2Count,
 Row1Type3Count, Row2Type3Count, Row3Type3Count, Row4Type3Count, Row5Type3Count,
 NoOfItemsRow1, NoOfItemsRow2, NoOfItemsRow3, NoOfItemsRow4, NoOfItemsRow5, NoOfItemsRow6,
NoOfItemsRow7,
 NoOfItemsRow8, NoOfItemsRow9, NoOfItemsRow10, NoOfItemsRow11, NoOfItemsRow12, NoOfItemsRow13,
NoOfItemsRow14,
 NoOfItemsRow15,
 WT_ItemsRow1, WT_ItemsRow2, WT_ItemsRow3, WT_ItemsRow4, WT_ItemsRow5, WT_ItemsRow6,
WT_ItemsRow7,
 WT_ItemsRow8, WT_ItemsRow9, WT_ItemsRow10, WT_ItemsRow11, WT_ItemsRow12, WT_ItemsRow13,
WT_ItemsRow14,
 WT_ItemsRow15
 , Position: integer;
 NofBagParcelRow1, NofBagParcelRow2, NofBagParcelRow3, NofBagParcelRow4, NofBagParcelRow5,
NofBagParcelRow6,
 NofBagParcelRow7, NofBagParcelRow8, NofBagParcelRow9, NofBagParcelRow10, NofBagParcelRow11,
NofBagParcelRow12,
 NofBagParcelRow13, NofBagParcelRow14, NofBagParcelRow15: integer; 2
 WtofBagParcelRow1, WtofBagParcelRow2, WtofBagParcelRow3, WtofBagParcelRow4, WtofBagParcelRow5,
WtofBagParcelRow6,
 WtofBagParcelRow7, WtofBagParcelRow8, WtofBagParcelRow9, WtofBagParcelRow10, WtofBagParcelRow11,
WtofBagParcelRow12,
 WtofBagParcelRow13, WtofBagParcelRow14, WtofBagParcelRow15: Double;
 WtofItemAndBagRow1, WtofItemAndBagRow2, WtofItemAndBagRow3, WtofItemAndBagRow4,
WtofItemAndBagRow5, WtofItemAndBagRow6,
 WtofItemAndBagRow7, WtofItemAndBagRow8, WtofItemAndBagRow9, WtofItemAndBagRow10,
WtofItemAndBagRow11, WtofItemAndBagRow12,
 WtofItemAndBagRow13, WtofItemAndBagRow14, WtofItemAndBagRow15: Double; begin ... 
 
 

That's right: The tiny method had grown until it was 700 lines long! Not only that, but it had attracted friends: 60,000 lines in total, all squished into a few button events.

And so Jack went off in search of an axe with which to prune his massive garden...

[Advertisement] Release! is a light card game about software and the people who make it. Play with 2-5 people, or up to 10 with two copies - only $9.95 shipped!