The purpose statement is easy to describe, and hard (for students) to do. You want a one-line description of what the function does.
Tip for students: if you can’t easily describe what the function does in one line, maybe you need to come up with data definitions that allow you to describe it more clearly, or maybe it shouldn’t be a function.
From a software engineering standpoint, the purpose statement is a vital “deep breath” that precedes writing any function. It gives you a chance to think about the role of this function in the program, and whether it actually makes sense. It’s a part of the antidote to “fingers first” programming, and it’s a part of the “reflection” that’s becoming more and more widely accepted as part of programming education.
Perhaps most importantly: it’s something that students should be doing for the rest of their lives. It’s applicable to every language that they’ll ever use, and it’s always time well spent.
Ed. Note: examples required!
—
Copyright (C) 2017, John Clements (clements@racket-lang.org)