At the beginning of the week, I showed you this picture.
And I talked about how the structure of this part of the course is really
going to be defined. By the cross product of recipes, like how
to design functions and how to design world programs, with data definitions
with different structure. During the week we saw how to design
simple atomic data definitions, interval data definitions, enumerations, and
itemizations. And then we designed one function using
each of those data definitions. We basically completed the red box in
this week. Next week we'll do the green box.
That point that you can think about the organization of the first part of the
course in terms of a cross product between the form of the data and the how
to design functions recipe. That point's important but there's a much
more important point that underlies that. Think about the examples we've seen this
week. Think about the city name example and the
best function. The inherent structure of the domain
information in that case was atomic. So we represented it using simple atomic
data. And that meant the template had a certain
form, dot, dot, dot x. And that told us something about the
function and something about the test as well.
And that happened with all of the data definitions.
With seednum, the inherent structure of the information is a contiguous range of
numbers. So in that case, we use an interval.
That formed the template a certain way, it formed the body of the function a
certain way, and it told us something about the test, in that case, that there
should be three of them. Every example we saw this week, it was
the same phenomenon. Which is that once we identify the
structure of the information, the inherent structure of the information,
that gives us the structure of the data used to represent it.
Which gives us the structure of the template.
Which gives us the structure of the function and also we get guidance about
the tests for that function. So identifying the structure of the
information is really a key step or maybe the key step in the program design.
At least for many kinds of programs, the ones we're going to look at for the first
part of this course. As data definitions get more
sophisticated, what you're going to see is that there are different choices you
can make about the data that you'll use to represent information.
And by making different choices, you actually have a lot of influence on the
rest of the program. Because of this fact that the structure
of the data determines the structure of the template, determines the structure of
the functions. So, designing data is a very high point
of leverage for designing programs. There are some programs for which that's
less true but for very many programs, this approach that we're taking in this
first part of the course, this data driven approach, does a very good job of
producing the structure of large parts of the program.
What we'll see later in the course is some examples where the control structure
becomes dominant and what we'll learn in that part of the course is how to blend
templates based with control structure together with templates based on type
comments or templates based on a form of data to produce the dominant structure of
our program. But even in those programs, the form of
the information determines the form of the data and the form of the data
determines the form of many of the functions that operate on the data.
So identifying the form of the information remains a key step in the
design of programs. That's going to be true throughout the
course and throughout all programs you write.
So have fun with the homework assignments, and I'll see you next week.