{"id":518,"date":"2013-06-12T14:22:00","date_gmt":"2013-06-12T14:22:00","guid":{"rendered":"https:\/\/staging.infragistics.com\/blogs\/?p=518"},"modified":"2025-02-26T08:52:56","modified_gmt":"2025-02-26T08:52:56","slug":"introduction-to-systematic-programming","status":"publish","type":"post","link":"https:\/\/www.infragistics.com\/blogs\/introduction-to-systematic-programming","title":{"rendered":"Introduction to Systematic Programming \u2013 Week 1"},"content":{"rendered":"\n<p>If you\u2019ve been here since last week, I\u2019m sure you\u2019re waiting with bated breath to hear how the first week of classes went. Well, the wait is over!<\/p>\n\n\n\n<p>For those of you just tuning in, check out the \u201cIntro\u201d to the Introduction to Systematic Programming series <a href=\"\/community\/blogs\/d-coding\/archive\/2013\/06\/05\/introduction-to-systematic-program-design.aspx\">here <\/a>for some more background on what we\u2019re about to get into.<\/p>\n\n\n\n<p><img loading=\"lazy\" decoding=\"async\" style=\"float: right;\" src=\"\/community\/cfs-filesystemfile.ashx\/__key\/CommunityServer.Blogs.Components.WeblogFiles\/d-coding\/7875.logo.png\" width=\"88\" height=\"85\">Week 1 consisted of 9 lessons centered around the topic of Primitives in <a href=\"http:\/\/docs.racket-lang.org\/drracket\/\" rel=\"noopener\">Dr. Racket<\/a>. I\u2019ll go through each lesson here one by one, giving a quick description of the main topic points we covered and any interesting additional tidbits I may have picked up. Please remember that some terms in this class, as mentioned in post 1, are used in a different manner than most traditional programming. I\u2019ll try to note this when I can, but in some cases, I may not even be aware of how it is used traditionally, since a lot of this is new to me as well!<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"lesson-1-introduction-to-systematic-program-design\">Lesson 1: Introduction to Systematic Program Design<\/h2>\n\n\n\n<p>The primary point covered in this first lesson is that, \u201cComputation is what makes \u2018things\u2019 happen!\u201d This course is based on the idea that programs, and the design of programs, is what makes the majority of our \u201ctypical\u201d 1<sup>st<\/sup> world interactions possible. From food to transportation, a computer program was likely involved somewhere in the process of the product getting from production to the end user, regardless of whether the product is regarded as \u201ctechnology\u201d.<\/p>\n\n\n\n<p>Next, we reviewed the question, \u201cWhat\u2019s the \u2018Design Method\u2019?\u201d In this class, the design method is defined as a structure that takes you from a poorly defined problem all the way to a well-structured solution. To me, this transcends just software development, and can be used throughout one\u2019s daily existence if applied in a thoughtful manner.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"lesson-2-expressions\">Lesson 2: Expressions<\/h2>\n\n\n\n<p>Dr. Racket is set up such that the Definitions Area is above the Interactions area, as you can see here:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"\/community\/cfs-filesystemfile.ashx\/__key\/CommunityServer.Blogs.Components.WeblogFiles\/d-coding\/4338.interactionarea.png\" alt=\"Dr. Racket is set up such that the Definitions Area is above the Interactions area, as you can see \" title=\"Dr. Racket is set up such that the Definitions Area is above the Interactions area, as you can see \"\/><\/figure>\n\n\n\n<p>In Dr. Racket, expressions are evaluated to produce values. In order to create an expression, one should utilize the following recipe:<img loading=\"lazy\" decoding=\"async\" style=\"vertical-align: middle;\" src=\"\/community\/cfs-filesystemfile.ashx\/__key\/CommunityServer.Blogs.Components.WeblogFiles\/d-coding\/0488.primitiveexpression.jpg\" width=\"173\" height=\"38\"><\/p>\n\n\n\n<p>For example, to have Dr. Racket compute \u201c3+6\u201d, you would input the following into its Definitions Area:<\/p>\n\n\n\n<p>(+ 3 6)<\/p>\n\n\n\n<p>Additional notes from this section:<\/p>\n\n\n\n<p>; designates a line to be commented out<\/p>\n\n\n\n<p>#i designates an inexact number<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"lesson-3-evaluation\">Lesson 3: Evaluation<\/h2>\n\n\n\n<p>The Rules in Dr. Racket to Evaluate Expressions are:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>An Expression is a \u201cPrimitive Call\u201d when it begins as (*\u2026\u2026<\/li>\n<\/ol>\n\n\n\n<p>With * standing for any of the primitive Operators, including, but not limited to: +, -, \/, *<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>All the items after the Operator are designated as Operands<\/li>\n\n\n\n<li>The first step in Evaluation is to reduce all Operands to values<\/li>\n\n\n\n<li>Operands are reduced to values from left to right, and from inside to outside<\/li>\n<\/ol>\n\n\n\n<p>Additional notes from this session:<\/p>\n\n\n\n<p>Remember to include spaces before operands and numbers or else your expression won\u2019t be able to be evaluated.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"lesson-4-strings-images\">Lesson 4: Strings &amp; Images<\/h2>\n\n\n\n<p>This lesson covered how to define strings and images, as well as some of their basic functions that the course will be using. Here are some of the highlights:<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><i>Strings<\/i><\/h4>\n\n\n\n<p>\u201cThis is a string in Dr. Racket\u201d<\/p>\n\n\n\n<p>Strings are considered values, and are not numbers, even if the string contains a number or numeric value.<\/p>\n\n\n\n<p>(string-append \u201cAda\u201d \u201cLovelace\u201d) will evaluate to \u201cAdaLovelace\u201d<\/p>\n\n\n\n<p>(string-length \u201capple\u201d) will evaluate to 5<\/p>\n\n\n\n<p>(substring \u201cCaribou\u201d 2 4) will evaluate to ri<\/p>\n\n\n\n<p>Substring uses Zero Based Indexing, which in layman\u2019s terms, means that it begins counting from 0. Thus, Caribou would be numbered C \u2013 0, A- 1, R-2, I-3, B-4, O-5, U-6.<\/p>\n\n\n\n<p>Substring takes the portion of the string beginning with the first operand, as well as the rest of the middle numbers, but does not include the closing operand.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><i>Images<\/i><\/h4>\n\n\n\n<p>In order to utilize images in the Dr. Racket language, the top of the program must include the line (require 2ndp\/image). This references the second edition of the How to Design Book\u2019s image rules.<\/p>\n\n\n\n<p><span style=\"text-decoration: underline;\">To Generate a Circle<\/span><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"\/community\/cfs-filesystemfile.ashx\/__key\/CommunityServer.Blogs.Components.WeblogFiles\/d-coding\/5265.generatecircle.jpg\" alt=\"To Generate a Circle\" title=\"To Generate a Circle\"\/><\/figure>\n\n\n\n<p><span style=\"text-decoration: underline;\">To Generate a Rectangle<\/span><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"\/community\/cfs-filesystemfile.ashx\/__key\/CommunityServer.Blogs.Components.WeblogFiles\/d-coding\/3058.generaterectangle.jpg\" alt=\"To Generate a Rectangle\" title=\"To Generate a Rectangle\"\/><\/figure>\n\n\n\n<p><span style=\"text-decoration: underline;\">Text<\/span><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"\/community\/cfs-filesystemfile.ashx\/__key\/CommunityServer.Blogs.Components.WeblogFiles\/d-coding\/4137.generatetext.jpg\" alt=\"Text\" title=\"Text\"\/><\/figure>\n\n\n\n<p><span style=\"text-decoration: underline;\">Above<\/span><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"\/community\/cfs-filesystemfile.ashx\/__key\/CommunityServer.Blogs.Components.WeblogFiles\/d-coding\/2043.generateabove.jpg\" alt=\"Above\" title=\"Above\"\/><\/figure>\n\n\n\n<p><span style=\"text-decoration: underline;\">Beside<\/span><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"\/community\/cfs-filesystemfile.ashx\/__key\/CommunityServer.Blogs.Components.WeblogFiles\/d-coding\/4442.generatebeside.jpg\" alt=\"Beside\" title=\"Beside\"\/><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\"><span style=\"text-decoration: underline;\">&nbsp;<\/span><\/h4>\n\n\n\n<p><span style=\"text-decoration: underline;\">Stack<\/span><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"\/community\/cfs-filesystemfile.ashx\/__key\/CommunityServer.Blogs.Components.WeblogFiles\/d-coding\/5618.generatestack.jpg\" alt=\"Stack\" title=\"Stack\"\/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"lesson-5-constant-definitions\">Lesson 5: Constant Definitions<\/h2>\n\n\n\n<p>The idea of defining a constant in Dr. Racket is similar, if not identical, to what I have experienced in other programming languages. Generically speaking, defining a constant means giving a name to a value (that has been hard coded) to be used in the future. Constants are usually defined in UPPER case, to differentiate them from other types of defined values.<\/p>\n\n\n\n<p>To define a constant in Dr. Racket, one would use the expression:&nbsp;<img loading=\"lazy\" decoding=\"async\" style=\"vertical-align: baseline;\" src=\"\/community\/cfs-filesystemfile.ashx\/__key\/CommunityServer.Blogs.Components.WeblogFiles\/d-coding\/2727.generatenameexpression.jpg\" width=\"189\" height=\"26\"> A functional example of this would be: (define WIDTH 400). This would create a named value called WIDTH that would evaluate to the number 400 when used in an expression.<\/p>\n\n\n\n<p>Additional Notes from this Section:<\/p>\n\n\n\n<p>Defining a constant does NOT equal an output value.<\/p>\n\n\n\n<p>Constants can be images. For example, (rotate 10 CONSTANT) will rotate a constant by 10 degrees.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"lesson-6-function-definitions\">Lesson 6: Function Definitions<\/h2>\n\n\n\n<p>Functions are the mechanism that lets you produce a different result each time you run a program, and they can be used repeatedly with any (valid) value. In my experience, similar to defining constants, this definition is true across many, if not all, programming languages. Across languages, a parameter is the changeable value that is passed into the function.<\/p>\n\n\n\n<p>Using functions allows programmers to avoid the \u201ccut and paste\u201d trap that they may be inclined to fall into in order to review multiple values, and allows for cleaner, more concise code.&nbsp;<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"\/community\/cfs-filesystemfile.ashx\/__key\/CommunityServer.Blogs.Components.WeblogFiles\/d-coding\/7245.kitten.jpg\" alt=\"\"\/><\/figure>\n\n\n\n<p>To write a function in Dr. Racket, the following recipe is used:<\/p>\n\n\n\n<p><img loading=\"lazy\" decoding=\"async\" width=\"375\" height=\"28\" style=\"vertical-align: middle;\" src=\"\/community\/cfs-filesystemfile.ashx\/__key\/CommunityServer.Blogs.Components.WeblogFiles\/d-coding\/6215.underkittenfunction.jpg\"><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"lesson-7-boolean-if-expressions\">Lesson 7: Boolean &amp; If Expressions <\/h2>\n\n\n\n<p>Boolean values are expressions that evaluate to either true or false; this result is also known as a predicate. There\u2019s no in-between for Booleans, and this is also true across the majority of programming languages.<\/p>\n\n\n\n<p>If expressions rely on this predicate in order to branch its responses. If statements ask the program, \u201cis this true? If so, do this. If not, do this!\u201d. In Dr. Racket, an if statement is expressed as follows:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"\/community\/cfs-filesystemfile.ashx\/__key\/CommunityServer.Blogs.Components.WeblogFiles\/d-coding\/0407.ifexpression.jpg\" alt=\"\"\/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"lesson-8-using-the-stepper\">Lesson 8: Using the Stepper<\/h2>\n\n\n\n<p>Lesson 8 reviewed how to utilize a Dr. Racket tool called \u201cThe Stepper\u201d. This program allows the developer to evaluate their program step by step, to determine where an error may lie. It\u2019s a great tool for those using the class, but I don\u2019t think it\u2019s necessary to get into too much detail here.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"lesson-9-discovering-primitives\">Lesson 9: Discovering Primitives<\/h2>\n\n\n\n<p>What I found really interesting about lesson 9 was that its basic principles seemed counterintuitive to most other types of learning, but very indicative of how I feel about memorizing theorems and methods. As this class has its own \u201cmade up\u201d programming language for us to use, no one is intimately familiar with the primitives (or anything, really!) we have available. The advice for this is twofold. First, we\u2019re encouraged to \u201cTake a Guess!\u201d because the likelihood is that since programming is intuitive, we just might be right. The second suggestion is to \u201cSearch &amp; Scroll\u201d, which is explained as looking up a similar primitive and seeing what else related is available in our guidebook. As I said, I\u2019m a huge fan of this approach, because it does not force the student to memorize countless hours of specifics, but rather allows them to dive right into the interactive work and learn along the way.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"alright\">ALRIGHT<\/h2>\n\n\n\n<p>That\u2019s it for the Week 1 Lessons. I think it was a really great start because I was able to refresh a lot of basic concepts, but also get a general feel for how Dr. Racket works. The homework assignments were pretty basic and I was able to get through them with relative ease. What I did get stuck on, for those of you who are following along as fellow course students, is that when putting in evaluation results, do NOT forget the \u201cs surrounding your strings! I forgot this and I almost failed the homework quiz because of it. Luckily, our week 1 quiz allows a retake, so I was able to fix my mistake and I\u2019m happy to say I scored 100%.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you\u2019ve been here since last week, I\u2019m sure you\u2019re waiting with bated breath to hear how the first week of classes went. Well, the wait is over!<\/p>\n","protected":false},"author":21,"featured_media":2366,"comment_status":"publish","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[17],"tags":[],"class_list":["post-518","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-how-to"],"_links":{"self":[{"href":"https:\/\/www.infragistics.com\/blogs\/wp-json\/wp\/v2\/posts\/518","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.infragistics.com\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.infragistics.com\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.infragistics.com\/blogs\/wp-json\/wp\/v2\/users\/21"}],"replies":[{"embeddable":true,"href":"https:\/\/www.infragistics.com\/blogs\/wp-json\/wp\/v2\/comments?post=518"}],"version-history":[{"count":6,"href":"https:\/\/www.infragistics.com\/blogs\/wp-json\/wp\/v2\/posts\/518\/revisions"}],"predecessor-version":[{"id":2436,"href":"https:\/\/www.infragistics.com\/blogs\/wp-json\/wp\/v2\/posts\/518\/revisions\/2436"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.infragistics.com\/blogs\/wp-json\/wp\/v2\/media\/2366"}],"wp:attachment":[{"href":"https:\/\/www.infragistics.com\/blogs\/wp-json\/wp\/v2\/media?parent=518"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.infragistics.com\/blogs\/wp-json\/wp\/v2\/categories?post=518"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.infragistics.com\/blogs\/wp-json\/wp\/v2\/tags?post=518"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}