Having a meal, or at least getting through that plate of spaghetti

0

Contributed by Angela Hall, Senior Technical Architect at SAS, (@angelahall1)

The SAS Global Forum Technology Session included the technically funny comedian Don McMillan , who pulled out the #SASGF11 program and stated, very seriously, that there was plenty of comedy material within those pages. He then highlighted the long and windy, the Shakespearian, and the most likely to leave you hungry paper titled ‘Plate of Spaghetti Anyone? Techniques for Learning Existing SAS® Programs’. My friend and co-author Tricia Aanderud was suddenly responsible for making the entire audience wish they'd eaten a bigger, expensive breakfast @CaesarsPalace .

However during Tricia’s presentation, she explained that over time many programmed applications become inflicted with scope creep. (Personally, I think she was very generous with this assessment.) Code can get so entangled it resembles a plate of spaghetti, making it impossible for the observer to see where the same noodle starts and ends or how many noodles there are. This correlation between the title and the method of madness that creates spaghetti code became even more apparent when she opened the talk to the entire audience. Tricia asked attendees to air their own dirty laundry (oh wait, we are talking about food). Included are some of the tips they provided on how to walk through existing processes as well as suggestions on how to better code processes:

  1. Review the output (or expected result) before walking through the code, this ‘bottom-up’ approach can provide insight into understanding what the prior coder was trying to accomplish.
  2. Discontinue reusing temporary table names in the program. (This can cause problems for the new programmer to step through the process when they are studying it.)
  3. Use macro and variable names that make sense. The eight character limit is gone, take advantage of it.
  4. Comment – Comment – Comment, and it’s all about quality over quantity.
  5. Build a flow chart, plotting what steps are taken to get from input to output.
  6. Run the program and analyze the log.

A funny moment was when an attendee admitted sadly that they had used these techniques on one of their own programs to ‘relearn’ it. But it highlighted the fact that everyone can benefit from good programming techniques.

What examples or suggestions do you have for SAS programmers who are creating applications or those that are parsing through and trying to learn previously created code?

By the way, Tricia’s paper also offers a sample mechanism (written in BASE SAS) that trolls through the .sas programs and generates an excel spreadsheet with information on all of the jobs and macros, and gives an analysis of the code. So in spaghetti speak - this offers an initial menu of the types of spaghetti being sold.

Share

About Author

Waynette Tubbs

Editor, Marketing Editorial

+Waynette Tubbs is the Editor of the Risk Management Knowledge Exchange at SAS, Managing Editor of sascom Magazine and Editor of the SAS Tech Report. Tubbs has developed a comprehensive portfolio of strategic business and marketing communications during her career spanning 15 years of magazine, marketing and agency work.

Leave A Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Back to Top