Skip to main content
41 votes
Accepted

How to teach the importance of indentation

It has taken me a long time to get to a point where my students regularly indent properly. I basically use a 4-part strategy. (My work here in the context of AP Computer Science, so my examples are ...
Ben I.'s user avatar
  • 33.9k
22 votes

Should teachers enforce standardization of spacing and braces?

Our two deities are clarity and efficiency. Standardization makes a great deal of sense in industry, where large numbers of programmers may work with the same lines of code and must be able to make ...
Ben I.'s user avatar
  • 33.9k
20 votes
Accepted

How to teach students not to use jump statements

I don't believe that your question is entirely valid; some languages require jumping. The first principle, therefore, is to follow the norms of your language. However, I suspect that you are asking ...
Ben I.'s user avatar
  • 33.9k
18 votes

Attempting to prevent learning of poor techniques when self-teaching

I think there are two phases here: the first is just being aware of what the correct idioms and best practices are, and second is attempting to apply what you learned and getting feedback. For the ...
Michael0x2a's user avatar
  • 4,005
17 votes

How to teach the importance of indentation

Indentation (in most languages) is just for readability. This aids in maintainability and other good stuff, all of which an intro student is completely unaware of or uninterested in. So it is best ...
hotpaw2's user avatar
  • 1,903
16 votes

Should teachers enforce standardization of spacing and braces?

I think placing some emphasis on style and conventions is important, yes -- learning how to follow style guides is a skill worth training and learning to be detail-oriented is an important meta-skill. ...
Michael0x2a's user avatar
  • 4,005
11 votes

How to teach to write optimized code

you not going to like this answer, but Don't teach it!! At least, don't teach it unless your teaching a 300-400 level course in college. Most code optimization is very tiny benefit, especially since ...
dsollen's user avatar
  • 281
11 votes

What should be included in a best practices C course?

I think an important aspect to any best-practices list is the rationale behind it. It is entirely too common for a programmer to, for example, insist that gotos and global variables are evil and then ...
Ray's user avatar
  • 539
10 votes

How can I show the value of best practices?

I've faced resistance too. Here are some ideas: Students would not turn in an assignment to an English teacher that was not properly punctuated and proofread, even if that teacher will be the only ...
Ellen Spertus's user avatar
10 votes
Accepted

Do automatic style hints help students to understand the language they're learning?

In my experience, immediate feedback is helpful in speeding along development, but rarely enhances understanding. In fact, I am often frustrated with the immense level of help that is provided to my ...
Ben I.'s user avatar
  • 33.9k
9 votes

How to teach the importance of indentation

Indentation is important so that you can see what code will be run based on the existing conditions. So for a simple example, consider: ...
nycynik's user avatar
  • 381
9 votes

How to teach the importance of indentation

Lots of good comments here. Showing bad code and asking them to understand it will particularly drive the point home. I've taken to having coding standards in my courses. No one followed them until ...
user3329809's user avatar
9 votes
Accepted

How can I discourage poor design while using automatic grading of submissions?

I am a strong advocate for code interviews. I make principles of style into about 50% of a lab grade (though I do permit kids to go back and refactor after an interview for full credit.) For some ...
Ben I.'s user avatar
  • 33.9k
9 votes
Accepted

The importance of writing understandable code

There are a ton of blog posts and several books on the topic of readable code, containing far more eloquent and complete arguments than one can make here (or that I could come up with myself). ...
Rory's user avatar
  • 397
8 votes

What should be included in a best practices C course?

This might be controversial, but I would make a point to explain that goto is not always considered harmful (and explain that the context of Dijkstra's "Go To ...
jamesdlin's user avatar
  • 189
8 votes
Accepted

What should be included in a best practices C course?

Too much, too fast "First semester". If I parse correctly, you say 60% students are new to programming. You say "The following points knock them out: they don't know how to test, they don't know how ...
kubanczyk's user avatar
  • 195
7 votes

Should teachers enforce standardization of spacing and braces?

I tell my students this. Pick a style and be consistent. You will see religious wars over for(...) { code } and ...
ncmathsadist's user avatar
  • 2,339
7 votes

Attempting to prevent learning of poor techniques when self-teaching

There is more to your question than just "how to program". For that, however, a good guide is to learn who/where a language was developed and emulate the code that those people write. For Scala, for ...
Buffy's user avatar
  • 36.4k
7 votes

What should be included in a best practices C course?

Note: I was under the impression that this question was by a faculty asking for advice on best practices for teaching a course on C. Instead it's a question by a proactive student that is ...
Zhro's user avatar
  • 171
6 votes

How to teach the importance of indentation

A quick exercise Write the most garbled code of your life (I know, I feel your pain) - terrible variable/function names, no indentation, code-golfed lines here and there, weird tricks, no comments, ...
auden's user avatar
  • 4,724
6 votes

How can I show the value of best practices?

Best Practices serves two purposes, allowing future maintainers (which easily could be themselves) to understand what the code is supposed to do, and helping the them avoid errors, and find errors ...
Gypsy Spellweaver's user avatar
6 votes

How can I discourage poor design while using automatic grading of submissions?

Harvard's grading policy for CS50 is worth looking into. There are four components for the grade on problem sets (each of which involves submitting code). The overall grade is calculated as scope * (...
Miles's user avatar
  • 1,266
6 votes

How to teach students not to use jump statements

Make them suffer through debugging spaghetti code. Come up with a few examples that make liberal use of the language features you don't want them to use. 100-150 lines of code with 1 or 2 small bugs ...
Peter's user avatar
  • 9,102
6 votes

What should be included in a best practices C course?

Your list is a bit narrow in one sense. I assume it is well matched to your specific course, but probably doesn't represent "best practice" in general. For example, valgrind is limited to linux, which ...
Buffy's user avatar
  • 36.4k
6 votes

What should be included in a best practices C course?

Lint I would not program in C without a lint tool e.g. gcc -Wall or pclint/...
ctrl-alt-delor's user avatar
5 votes

How can I discourage poor design while using automatic grading of submissions?

First let me say that I think it is a good idea to automate as much as possible, and that there are tools that will help this. The mystery test However my experience with professionals is that there ...
ctrl-alt-delor's user avatar
5 votes

How can I show the value of best practices?

Maybe the easiest way to practice is to have an element of peer review. I find it's much easier as a reviewer to insist on good practice and make 'helpful' suggestions than to follow these rules ...
Sean Houlihane's user avatar
5 votes

How can I show the value of best practices?

You can introduce the idea of best practices. Show them examples of right vs wrong for each of the practices you want to teach them: ...
ItamarG3's user avatar
  • 6,312
5 votes

How to teach the importance of indentation

The purpose of indentation (to express the intended control flow) and the value are subtly different things. For a 5 line script, there is really not much value in indentation or comments - the code ...
Sean Houlihane's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible