If you read my last blog, you already know I've been cheating a little bit with how I prepare my data for functions, and how I write out function definitions so I've been cutting out some time here. Also, I coded only some of the exercises, in C# again, which took less than an hour, It would have taken much longer, but I completed the drawing exercises in pseudo code, which is hardly enough to qualify for a grade should you actually take this course, and certainly no where near enough to qualify for learning something new if you've never used code to draw pictures (to be fair, it's not all that exciting).
In doing this, I've noticed is that I've betrayed this learning opportunity by making things too easy in some areas, and too complicated in others. I'm so used to using C#, that I can write the code for simple problems (EX. create a definition for a point) with very little effort, and it feels like I'm wasting time. I want to go through all of these courses as thoroughly as I can, without wasting my own time, so I can give a fair analysis of the content, but using C# has actually proven to be a waste of time for things that may be very simple in Racket (drawing shapes/images), and too familiar for things like designing compound data (movies with title, budget, release date, etc.) and comparing certain values.
In short, I've decided to download Racket and use it for the rest of the course, starting with parts 2 and 3. The lesson learned here, is that if you want to participate in any course, even if you're told you can code in the language of your choice, it's best to use the tools provided.
As for what you can expect to learn in section 3, there's some seriously valuable ideas. The major concepts are: using templates, domain analysis, programming through the main, using 'wishes' to work out the details for the main function, and creating compound data structures. I'll explain the details of each concept in bullet form here.
- Using Templates
- The essence here is that using templates allows you to break apart your solution into manageable steps that can be worked on one at a time. With a template you can work systematically, then end up with all of the pieces of your solution
- Domain Analysis
- Start with a sentence to describe the goal of your function
- Ex. This function will draw a cat walking across the screen
- Identify the things that stay the same
- Height and Width of the screen might be a couple constants
- Speed of the cat, and the image of the cat might be a couple more
- Identify the things that change
- If the cat is moving horizontally, its x-coordinate will change
- You might want it's rotation to change to give it a wobble effect
- Draw pictures to represent the things you've listed
- Programming Through the Main Function, Using 'Wishes' Where Necessary
- Start coding your function with the assumption that it has all the functions you need, and when you run into a piece of missing functionality, create a 'wish'
- That is, if you write, using the big bang example, (on-tick advance-cat) you've assumed the function advance-cat exists. However, advance-cat does not exist yet, so you've made your wish for it to exist, and now you need to quickly write a short section (this section already exists in the big bang template) for your wish, the same way you would any other data definition.
- Mark incomplete wishes with !!! (often marked as //TODO in C#)
- Essentially, this means, when you run into missing functionality in your program, just write the name of the function you want to exist, then fill in the details for that part of the code later.
- Creating Compound Data Structures
- As the word compound suggests, these are data structures with multiple parts
- Example: (define-struct point (x y))
- Access x through: point-x
- Access y through: point-y
- Example 2: (define-struct cow (point dx))
- Access x through: cow-point-x
- Access y through: cow-point-y
- Here, dx represents velocity and can be accessed similarly: cow-dx
There was certainly some valuable information in these sections. I discovered the importance of drawing pictures and writing program goals in natural language very early on in my computer science education, but I never had a full-on systematic strategy like this course teaches. As annoying as it can be to write out all the details for a simple program, I am excited to see how this strategy really shines when attempting to write more complex designs.