tag:blogger.com,1999:blog-18677687.post5259631042766145297..comments2024-03-27T15:13:24.764-04:00Comments on Computer Science Teacher: Pluses and Minuses of the Unary increment OperatorAlfred Thompsonhttp://www.blogger.com/profile/05575057876858763822noreply@blogger.comBlogger4125tag:blogger.com,1999:blog-18677687.post-15209634001724278182021-07-22T00:19:55.005-04:002021-07-22T00:19:55.005-04:00Somewhat related to the cognitive load point, a = ...Somewhat related to the cognitive load point, a = a + 1 most clearly exemplifies the "=" symbol as an assignment operator, which is itself a bit odd at first for some students. It's not uncommon for some to reverse the order at first, writing a + 1 = a. (Some days I miss APL's <- assignment operator!)<br /><br />I stick with the traditional at least until everyone gets assignment figured out, and then introduce the other variations in Python and Java classes. <br /><br />I studiously avoid ++a.:)rwhite5279https://www.blogger.com/profile/05657921863093970820noreply@blogger.comtag:blogger.com,1999:blog-18677687.post-81402232921310463132021-07-20T13:16:44.795-04:002021-07-20T13:16:44.795-04:00I agree with the others. a=a+1 is just fine for e...I agree with the others. a=a+1 is just fine for everything. Very true about cognitive load for your students.<br /><br />And I think that is just fine in a professional environment as well. It seems to lead down that road of ever increasing density of code. When someone says the can rewrite a section of code in one or two lines I always say that I don't want to be the person maintaining that code in a few years.Clarkhttps://www.blogger.com/profile/11074228300661229812noreply@blogger.comtag:blogger.com,1999:blog-18677687.post-40228074626294477642021-07-20T10:31:34.319-04:002021-07-20T10:31:34.319-04:00a=a+1 works in every language I teach. The other ...a=a+1 works in every language I teach. The other forms are dependent. I point them out to the kids but rarely actually use or teach them. I know a=a+1 works and requires no thinking. I like things with no thinking.Garthnoreply@blogger.comtag:blogger.com,1999:blog-18677687.post-9882023436946570032021-07-20T06:50:15.387-04:002021-07-20T06:50:15.387-04:00I do much as you do - teach and encourage i=i+1 mo...I do much as you do - teach and encourage i=i+1 most of the time but consider i++ or ++i acceptable as standalone constructs.<br /><br />I always used to write i++ but have been seeing ++i more and more these days - ++i probably makes more sense. I don't know any stats but it seems to me to be more intuitive what it does as opposed to i++.<br /><br />Mike Zamanskyhttps://www.blogger.com/profile/15069276938781711576noreply@blogger.com