views:

116

answers:

8

I teach an introductory computer science course where there are some programming assignments.

The question is, what should we demand from the students other than correctness (i.e. the program works and does what we defined it should do) and originality (i.e. the student wrote it by himself).

+3  A: 

If the student goes the extra mile in his work. So a working program that has:

  • Good clean indents
  • Good code reuse
  • Good comments
  • Fails correctly on errors
  • Uses sensible variable naming

The difference between code that works and code that works well is well worth a better grade IMO.

Ólafur Waage
can you give details?
flybywire
I added some detail.
Ólafur Waage
+2  A: 
  • Proper structure
  • Appropriate comments, in proper English
  • Proper indentation
  • (Somewhat) efficient implementation (no O(n^3) when an O(n) solution is possible...)
  • Orinigal solution
  • No compile warnings
  • Idiomatic code (when coding in Python, don't treat it as Java, and vice versa.)
Stephan202
+1  A: 

All of the comments are (a) in the appropriate language [for me, English], and (b) apply to the code they wrote and are (c) meaningful, relevant and helpful.

In particular, I teach Java (and a little Python) and because of Javadoc (and epydoc) comments matter more than ever.

S.Lott
+1  A: 

That's a difficult list to demand dryly... ask for more comments and the code will get drowned out... ask for meaningful variable names and they'll become so long the code will become unreadable.

I think clarity is a good one, but may need to be explained further. As Joel says, all code should be written for the programmer maintaining it in ten years from now (as it will be if it was successful). Make it clear how many of these programs you're going to be marking and that clarity will help you and their mark. Of course it's subjective, but that is the point. The code should be written for you.

I guess it also depends on the assignment. If the assignment is slightly unstructured it can leave the brightest students room to shine. Maybe they'll come up with solutions that surprise, or delight you. But the important thing is that they showed initiative and researched possible solutions. Initiative is often the difference between a working and a dysfunctional program, or a mediocre website and a great one.

Josh
+1  A: 

In production code (I'm not saying I'm a teacher myself) I want it to be terse: I want just enough code to fully do the job ... YAGNI and "as simple as possible, but no simpler". That usually includes no copy-and-paste (prefer a common/reused subroutine to a copy-and-pasted replicated fragment).

ChrisW
+1  A: 

Personally I would also set up source control (subversion is commonly used) and require them to use it. I would then make everyone do at least one change to someone else's work. You'll have to set up subversion so each student has his own repositorry and doesn't have rights to any one else's (no point in giving the ones who did the project last the advantage of lookng up what others did.) Of course that means to assign each to work on someone else's code means, you will have to move the code to each person's repository.

You gain a couple of things from this, very few grads are familiar with source control which is a must in a production environment, so making students use it is a critical job skill. Second, you are going to make them see and interpret other people's code. This will make them more aware of maintainiblity of the code, but when they are writing it and when they have to work with code they didn't write. Just make sure when you give each person the code they are to change for the new requirement that they don't know who write it originally.

HLGEM
This is a great and worthy idea but probably an impractical drain on the teacher's time. The real difficulty would be if some student doesn't finish project 1, you can give their repository to another student for project 2.
jmucchiello
+2  A: 

When I last did practical supervision, the directive was that each lab question had to have a written design in order for the code to be marked. When the supervisors were asked for help with code, often the first thing I would ask is "where's your design? let's look at that". A lot of the time when students were getting totally lost it would be because they either didn't have a design, or their design was fundamentally flawed.

By the end of the semester, the smart students realised that investing some time in doing good designs meant that they spent way less time coding (and overall, beat the people that jumped right in without thinking). This approach carries over well to written exams. There's nothing worse than having to erase/white-out/cross out hand-written code because you didn't think through your design properly!

We weren't too strict on what a design consists of, but I accepted flowcharts, pseudo-code, small textual descriptions, etc.

Catchwa
+1  A: 

One thing I wish more programming classes would do is somehow make students to reuse code from earlier assignments. In most college assignments, as soon as you're done, you throw the code away and will never see it again, so it doesn't matter if it's rubbish. Many college students have never had the experience of needing to work on code which they wrote and haven't seen for a while.

Nearly all of the lessons in code maintenance, debugging, clarity, commenting, etc. are quite easily taught once you've had this experience.

AHelps