Friday, 25 January 2013

Learning to define variables

As I mentioned in my last post, I really wanted to know how to create a definition so that I can make simple phrases represent large pieces of code. Luckily, we got to learn this early on in the course. This week I learned how compose of definition, set identifiers for a specific value, and properly used check-expect statements to prove code.

First off I'd like to say that composing a definition was actually easier than I though. I have no idea what I was doing in my last week's problem, but I am confident I would be able to tackle that problem easily now. For example, I learned that simple phrases like "tippy-toes" can be defined to resemble an image of a robber on his tiptoes or anything else. This is fascinating function and I know I will readily use this throughout the course.

Second, I learned that I can set definitions to represent long pieces of code that is relatively too long to write or tedious to copy and paste over and over again. Especially in scenarios when codes needs to be recycled repeatedly, composing definitions will surely reduce my time spent on dull tasks and keep me happy. = )

Thirdly, after a long time spent glued to DrRacket, I finally understood the purpose of the check-expect statements. These are tools used to verify whether or not subsequent code resembles our check-expect statements. I'd like to recount a certain problem I had encountered with this tool. When I first watched the tutorial video, I was completely lost.  I understood the reason for writing a contract and purpose statement, which was to explain to the viewer what the upcoming code was about.  But, words like pic:hacker and pic:calender being repeated over and over again really scared me. So, I decided to write the code out on DrRacket for myself and understand it line by line. Soon after I realized that pic:calender, etc., represented placeholders for an actual image. They themselves can be thought of as definitions of a certain image. So, instead of using those words I used random images and developed my own check-expect statements. When I wrote my actual code, it passed the tests! I was glad that I got to figure it out.

It has been a great week, and I'll see you in my next post!

1 comment:

  1. Great to hear about the progress you made. I should add an annotation to the video about pic:hacker

    ReplyDelete