Questions tagged [coding-style]
Questions regarding code style (i.e. topics like indentation, naming, vertical alignment) and how to teach it
14
questions
30
votes
13answers
2k views
How to teach why indentation is important
I'm trying to teach why indentation is important, but the student doesn't indent. I asked why he doesn't indent, then he answered "That's because it’s a hassle."
It's OK to say "you should indent", ...
23
votes
10answers
4k views
Should teachers enforce standardization of spacing and braces?
On open source projects and industry teams, there are often detailed style guides about how many spaces should be used for indents, line continuation, etc., and whether braces should go on their own ...
14
votes
11answers
611 views
How can I show the value of best practices?
As someone who likes to advocate for best practices like correct use of VCS, indentation, sufficient commenting, and testing, I try and integrate them when I teach. But for all of these things, my ...
14
votes
3answers
678 views
Do automatic style hints help students to understand the language they're learning?
Do automatic style hints (like those provided by linters) significantly increase the student's understanding of the language they're learning? I am asking because I assist in a course that uses a ...
13
votes
11answers
3k views
What should be included in a best practices C course?
At our University, we have in the first semester a very difficult C Introductory Course, that consists of presenting a shortened version of the language specification: What are for/while loops, if ...
13
votes
6answers
2k views
Attempting to prevent learning of poor techniques when self-teaching
A big problem of learning alone is that you don't always figure out the preferred style for a language, the most "pythonic" (in the case of Python) way to do it, or how to write code in keeping with ...
12
votes
9answers
1k views
How to teach students not to use jump statements
We all know goto is the spawn of satan. To learners though, it seems easy and quick. In simple, short program codes having a goto or two won't turn the code into unreadable spaghetti code. So students ...
11
votes
7answers
528 views
How can I discourage poor design while using automatic grading of submissions?
Automatic grading is great for saving time on marking programming tasks, so there's more time to focus on actual teaching, but I've noticed a few flaws. Since work is essentially marked based on ...
8
votes
4answers
392 views
The importance of writing understandable code [duplicate]
Many students do not see the purpose of following conventions (indentation, naming, comments, etc.) which make the code much easier to read and review.
Students can learn to follow conventions, but ...
7
votes
5answers
631 views
How to teach to write optimized code
While reviewing someone's code I found many problems, such as writing lots of loops instead of a single loop.
For example let's take the case of basic square matrix multiplication.
Both matrices ...
7
votes
4answers
150 views
Teaching identifier naming conventions
Currently the only thing I'm teaching for the naming of identifiers is "be consistent". Then I go ahead and use the Hungarian notation consistently, and show them a few other conventions.
Is there a ...
5
votes
3answers
188 views
Suggestions for encouraging good Coding Practices?
From an instructor perspective (Middle School or High School), Is there a method, or a set of guidelines, for grading early coders' projects that could enhance good coding practices as the students ...
3
votes
2answers
67 views
Advise on a class project
Me and my friend are both in high school taking a “PLTW” Engineering class, where our goal is to design a solution to any problem and work on that solution over the course of the year. We’re reaching ...
2
votes
2answers
69 views
Projecting the In- class demo screen
I want to do an in-class demo for students.
I am wondering if there's a way I can project my code editor for students to see, and still have a document with written code (like a cheat sheet) which ...