Thursday, September 27, 2018

Progressive Code Demonstration Programs

One of my goals this year is to improve my demonstration code. As part of that I want some demos that build on top of one another. A lot of things beginners code is complicated because they don’t have all the tools they should have. I find that a student who has seen or done something the hard way often really jumps on a new concept that makes things easier.

My current demo starts with various string library methods. For example, we are using the ToUpper, and ToLower methods to format data. We are using SubString to extract parts of a string, IndexOf to search for substrings, and Length to control a lot of what we are doing.

In the form below, a label shows the input string after the first character was set to uppercase and the rest of the string to lowercase. The list box shows each word in the input string one at a time. You’ll notice those words are not reformatted. We’ll get to that.

image

Very soon we will start some serious discussion about writing our own methods. At that time I will use the same base program but write a method that formats a string to first character uppercase and the rest lowercase. We’ll plug that in to the existing code so that students see how easy that makes things.

Later we will get serious about arrays. That will also be a good time to introduce the Split method which breaks a string apart based on a search character and puts the resulting substrings into an array. We’ll see a much easier way to split a string without writing our own loop and other code that can get tricky quickly. And we’ll see how much easier processing from an array can be.

That’s the plan so far. We’ll see how it works in practice but I have high hopes. Do your do demos or projects like this?

I know that some people teach with a large project that builds over the course of a semester as students learn new things. That sounds like a great idea as well. I struggle to think of the ideal project for that so I’m open to suggestions.

No comments:

Post a Comment