tag:blogger.com,1999:blog-18677687.post3359907562837972446..comments2024-03-27T15:13:24.764-04:00Comments on Computer Science Teacher: Simplify Simplify SimplifyAlfred Thompsonhttp://www.blogger.com/profile/05575057876858763822noreply@blogger.comBlogger6125tag:blogger.com,1999:blog-18677687.post-63396421501484774092015-03-13T11:15:25.763-04:002015-03-13T11:15:25.763-04:00Good post, this reminds me of a situation from my ...Good post, this reminds me of a situation from my college days (25 years ago) that still irritates me a bit, and of course I still remember it -- from my (the student's) perspective.<br /><br />The assignment involved testing a series of 3 boolean variables, whose values were not independent, for example, in the problem context, all three could not be true at the same time. Rather than putting an expression that involved all the variables, I found an equally correct expression for this situation that simply tested one value, such as testing that some_variable == false. <br /><br />This worked for the problem, but the TA deducted points from my assignment because I didn't test all the values. I was upset because I knew exactly what I was doing by simplifying the expression, but the TA was trying to teach me that I should have checked the other values as well to see if they conformed to the problem context (the consistency). I understand what he was trying to say, especially because if there were a context problem, this would have been a bug that would have been very difficult to find, but I was peeved that we were not in that situation. Instead of using the opportunity to have a teachable moment, he tinged the experience with bitterness by deducting points. I think that was unfortunate, though on the other hand, I still remember the situation after all these years, maybe that sting had a lasting value.<br /><br />In my programming career, I am very careful about enforcing assumptions I make by asserting possible values (ensuring values conform to the problem context I assume). In the right context for teaching others, it would be a useful discussion about optimization and possibly over-optimization.Jonathan Kayehttp://teachingkidstocode.comnoreply@blogger.comtag:blogger.com,1999:blog-18677687.post-84771245879016661532015-03-12T18:10:57.388-04:002015-03-12T18:10:57.388-04:00I really like Casey Muratori's concept of &quo...I really like Casey Muratori's concept of <a href="http://mollyrocket.com/casey/stream_0019.html" rel="nofollow">"compression-oriented programming"</a> and try to introduce my CS students to functions through this technique. I.e., write the simplest thing possible until you have multiple identical (or almost identical) copies of it, then -- and only then -- factor it into functions/classes/larger abstract structures. Certainly as we get more versed in writing code, we may jump immediately to writing a function when we know it will be useful, but from a pedagogical perspective, I really like introducing abstraction and higher level structures through this technique.<br /><br />Also, definitely agree with Mike Zamansky about how CS can be more like humanities (or even art) than math.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-18677687.post-22428716747250647992015-03-12T12:59:44.437-04:002015-03-12T12:59:44.437-04:00I just had a similar event. We were reading data ...I just had a similar event. We were reading data from a text file in Java in a two part assignment. The assignment said do not use an array for part two. So I do part one without arrays. Royal pain but I figured a solution with a bunch of If statements. Very ugly. So I figured I would do it with arrays anyway just for the learning experience. Piece of cake. Very simple. I would teach the kids both ways. The university professor who has been helping me with the course (remember I am learning Java as I teach it?) came over to help and demonstrated a third way to do the problem. All three worked. All three depended on skill level with the language and the tools known. After a little thought I sort of like my two solutions better than his. My solutions would transfer to almost any language. His was very Java specific. This is why this stuff is fun. The three very different solutions prompted me to ask him how he grades programming assignments. “It works and I can read it” were the main criteria. “It works” is obvious. He said variable naming and proper comments, not excessive comments, were the key to the second criteria. Garthnoreply@blogger.comtag:blogger.com,1999:blog-18677687.post-55678651609065182092015-03-12T09:38:56.334-04:002015-03-12T09:38:56.334-04:00Many CS teachers come from math and in math there&...Many CS teachers come from math and in math there's usually little room for discussion/opinion. <br /><br />This is how CS can be more like humanities classes - so many times where the topic isn't really about the topic but rather a platform to discuss something more open ended without a clear cut right answer.<br />Mike Zamanskyhttps://www.blogger.com/profile/15069276938781711576noreply@blogger.comtag:blogger.com,1999:blog-18677687.post-7673596645526406582015-03-12T08:48:44.038-04:002015-03-12T08:48:44.038-04:00Great point about the optimizing compiler. That is...Great point about the optimizing compiler. That is of course yet another great thing to discuss in class. Alfred C Thompson IIhttps://www.blogger.com/profile/06011086242006020298noreply@blogger.comtag:blogger.com,1999:blog-18677687.post-27044352170940816502015-03-12T07:31:50.014-04:002015-03-12T07:31:50.014-04:00It's worth certainly worth discussion but ther...It's worth certainly worth discussion but there isn't a clear answer. <br /><br />One could argue that abstracting out the test in a function call is cleaner and how much overhead is it really? Besides won't an optimizing compiler inline it anyway.<br /><br />Of course, you argue the other side just as well.<br /><br />The beauty is that we can have this discussion with the class over and over in many contexts and they can hopefully learn when each is appropriate.<br />Mike Zamanskyhttps://www.blogger.com/profile/15069276938781711576noreply@blogger.com