Stanford CS106A Lecture 3

28 Oct

Haha… I should have watched this Lecture before completing the first assignment (at least for the last two problems from it)!

Here are my takeaways from this Lesson, which I wish I would have applied earlier:

  • Add in comments: I was so focused on making sure the program worked, I didn’t really write out comments of what I was doing. If you have a few lines of comments, you can comment by starting with “/*” adding the comments and ending with “*/”. Or if you just have a one line comment, you can just start the line with “//”. I will keep this in mind and add in more detailed notes to my future assignments.
  • Pre and Post Conditions: For each method, the professor recommended adding a “Pre-Condition” and a “Post-Condition” in the comment section, to clarify in what circumstances this command should be used and what to expect after Karel is done executing this command.
  • Top-down Processing: The idea is to start by listing out the higher-level steps Karel needs to execute and then write out the more detailed commands. I’ve kind of realized that on my own while going through the first assignment, but would have been useful to know to do this initially.
  • Rules of Decomposition: These sound like pretty good guidelines for decompositions – solve 1 problem, methods should be 1-15 lines, have a good name, explain what you’re doing in a comment.
I will write much better documented code from now on!

One Response to “Stanford CS106A Lecture 3”

  1. Olivier February 22, 2012 at 3:12 pm #

    I agree!

    I also started the 1st Karel assignment without watching lecture 3 and it helps a lot!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s