Skip to main content

Learning to Program, Learning to Think

Visalia Direct: Virtual Valley
August 2, 2010 Deadline
September Issue

Learning to Program, Learning to Think

Several times a month I create or modify computer code, but I use the skills I have gained from programming on a daily basis. The more I learn about computer languages and programming, the more I learn to think creatively to solve problems.

Our schools are asked to prepare students for standardized tests, primarily on English and math skills. We frequently claim we want students to learn creative problem solving, but we test memorized knowledge. State and national tests focus on knowing such things as the meanings of words and how to solve math problems with memorized equations. I don’t question the value of memorizing Latin and Greek roots or the quadratic equation, but teaching how to think is essential to the future.

Computer programming requires analyzing a problem, breaking a possible solution into small parts and then writing the code to perform the steps required by the solution. Rarely is there one solution to a problem. Even the best solution depends on specific situations.

When I teach programming and Web design, I find students are perplexed that there can be more than one “best” solution. This is a business problem as much as a technical problem, which forces students to demonstrate the ability to think beyond memorized algorithms. Sometimes a program must be ready on deadline, so the speed of development is more valuable than the elegance of the solution. In other instances, a program will have to calculate and display results as quickly as possible, so development time and cost is secondary to final execution speed.

Programming, then, is about situational analysis. Life is also about situational analysis, however much we might crave “right vs. wrong” and single best solutions to problems.

Teaching programming does not have to mean teaching an advanced computer language such as Microsoft’s C#, Apple’s Objective-C or Sun’s Java. These are great final destinations for aspiring programmers, but far beyond what is needed to solve common problems.

Most of the coding I do falls under the categories of “scripts” and “macros,” not full-fledged applications. I enhance my personal efficiency with brief bits of code.

During the 1980s, what made Lotus 1-2-3 the most popular spreadsheet and WordPerfect the leading word processor was not their ease of use. These were complex, often annoying, applications that required cheat sheets and keyboard templates to fully exploit their features. What made these applications special was their ability to execute “macros,” allowing the automation of complex tasks.

The term “macro” in computer science describes a collection of functions expressed as a single “user-defined” function.

The success of Microsoft Office has been linked to the existence of Visual Basic for Applications (VBA) macro language in Word, Excel, Access, and almost every other Microsoft business application. Office 2007 and 2010 for Windows include extensive VBA support. Arguably, one of the dumbest choices Microsoft made recently was shipping Office 2008 for Mac without VBA macros — a decision Microsoft promises to reverse later this year.

I use a Word VBA macro I coded named “Problem Words.” This macro searches student papers for words and phrases to avoid in academic papers. The macro also creates a report for students on the readability and grade level of a submitted assignment.

The macros I create are listed on a menu and on a toolbar as icons. The “Problem Words” macro appears as a single function, while executing dozens of functions. Best of all, I don’t need to recall the exact steps when I grade a paper: the macro ensures I search for the same problems in every student paper. Like most teachers, I would rather focus on the quality of ideas in a paper than the basic mechanics, but students should be reminded of English rules and academic style. My macro frees me to grade ideas, not grammar.

I teach my students how to create and modify macros in Excel and Word. For many of my students, this is their first experience with computer programming. By the end of each semester, most students have customized Office applications with a dozen or so macros.

In some ways, Apple has taken the macro concept much further than Microsoft. The AppleScript language is available throughout the OS X operating system. AppleScript programming is supported by Apple applications and by thousands of other applications, including Microsoft Office and Adobe Creative Suite. I have AppleScript versions of my favorite Word and Excel VBA macros.

If writing computer code is daunting, Apple also provides Automator, an application that allows you to create scripts without having to master AppleScript. I use Automator to convert and resize graphic images for Web pages. This allows me to process a “batch” of hundreds of pictures without having to edit them individually.

Any time I am going to be dealing with the same problem several times, I ask myself if creating a macro is reasonable. I save hours of time each month with macros and scripts. Each one began as the solution to a problem. Over time, my macros have been improved and expanded to perform their tasks more effectively.

Once students learn to code macros, many ask me about “serious” programming. Usually the students want to learn how games and phone “apps” are created. I’m pleased to report that several of my students have pursued their interest in coding, realizing anyone with an interest can program.

We need to encourage all students to view computer programming as a useful skill, not as a field limited to math wizards and technology fanatics. You don’t need to be a computer scientist to make computers do what you want.




Microsoft Office and Visual Basic for Applications

There are many good books on VBA for Excel. Users with complex spreadsheets tend to benefit more from macros than other computer users. I suggest the following books, listed from beginning skills to advanced:

1. Excel VBA Programming for Dummies by John Walkenbach
2. Excel 2010 Power Programming with VBA by John Walkenbach, part of the series “Mr. Spreadsheet’s Bookshelf”
3. Mastering VBA for Office 2010 by Richard Mansfield

For Word users, I suggest Word 2007 Macros & VBA Made Easy by Guy Hart-Davis. The macros explained work in Word 2010 without any problems.

Advanced Programming

If you want to learn applications programming, both Apple and Microsoft distribute tools for free. Both companies require registering to download the free programming languages and tools from their sites.

Apple Developer Central: http://developer.apple.com/

Microsoft Express Programming: http://www.microsoft.com/express/


Comments

Popular posts from this blog

MarsEdit and Blogging

MarsEdit (Photo credit: Wikipedia ) Mailing posts to blogs, a practice I adopted in 2005, allows a blogger like me to store copies of draft posts within email. If Blogger , WordPress, or the blogging platform of the moment crashes or for some other reason eats my posts, at least I have the original drafts of most entries. I find having such a nicely organized archive convenient — much easier than remembering to archive posts from Blogger or WordPress to my computer. With this post, I am testing MarsEdit from Red Sweater Software based on recent reviews, including an overview on 9to5Mac . Composing posts an email offers a fast way to prepare draft blogs, but the email does not always work well if you want to include basic formatting, images, and links to online resources. Submitting to Blogger via Apple Mail often produced complex HTML with unnecessary font and paragraph formatting styles. Problems with rich text led me to convert blog entries to plaintext in Apple Mail

Learning to Program

Late last night I installed the update to Apple's OS X programming tool suite, Xcode 4. This summer, in my "free" time I intend to work my way through my old copy of Teach Yourself C and the several Objective-C books I own. While I do play with various languages and tools, from AppleScript to PHP, I've never managed to master Objective-C — which is something I want to do. As I've written several times, knowing simple coding techniques is a practical skill and one that helps learn problem solving strategies. Even my use of AppleScript and Visual Basic for Applications (VBA) on a regular basis helps remind me to tackle problems in distinct steps, with clear objectives from step to step. There are many free programming tools that students should be encouraged to try. On OS X, the first two tools I suggest to non-technical students are Automator and AppleScript. These tools allow you to automate tasks on OS X, similar to the batch files of DOS or the macros of Wor

Learning to Code: Comments Count

I like comments in computer programming source code. I've never been the programmer to claim, "My code doesn't need comments." Maybe it is because I've always worked on so many projects that I need comments  to remind me what I was thinking when I entered the source code into the text editor. Most programmers end up in a similar situation. They look at a function and wonder, "Why did I do it this way?" Tangent : I also like comments in my "human" writing projects. One of the sad consequences of moving to digital media is that we might lose all the little marginalia authors and editors leave on manuscript drafts. That thought, the desire to preserve my notes, is worthy of its own blog post — so watch for a post on writing software and notes. Here are my rules for comments: Source code files should begin with identifying comments and an update log. Functions, subroutines, and blocks of code should have at least one descriptive comment.