views:

406

answers:

12

Hello.

Unfortunately, (written) midterms are necessary in most university CS programmes in the world. They tell us how well our students (and ourselves as teachers) are doing. Needless to say, designing midterms for a C Programming Language course is not easy. For instance, when we program for real, we have a myriad of information at our disposal: websites, books, cheat sheets to "remember" the syntax and so on.

My question is this: did you find any way, during your years at school or training, where you said: ok, this midterm evaluation of my programming skills is tough, but fair.

For instance: I found "find 5 problems with this code"-type questions hard but interesting and telling.

Are there any others?

Thanks.

+5  A: 

I personaly liked "find a way (or ways) how to make this code better (faster, save memory, different algorithm)" and of course we always had to say WHY. This made me think how some things work (sorting algorithms for example) and i learned a lot thanks to these challenges.

PeterK
+2  A: 

Questions regarding pointers, such as dereferencing them correctly are very good.

Also, differences between arrays and pointers, how they are stored in memory etc...

I would also ask for an example of when using a local static structure is a good idea and why.

Yuriy Y. Yermilov
A: 

We has somtimes parts of a program where we had to "fil in the blanks"
like:

float sqrt(float val)
{
/*... write code for this function */
}

int i[34];
for( /* fill in to loop the complete array */
{
}

also explain what is the printout from

typedef union { char[4] c,int i} MY_U;
MY_U j;
j.i = 0x12552351;
printf("my char = %d\n",j.c[3]);/* often arch dependent */
eaanon01
A compilation error.
anon
@Neil, wasn't the code were left incomplete purposely?
YeenFei
@Yeen I was referring to the second "question" which had an obvious syntax error in it, since corrected. Now it merely exhibits undefined behaviour.
anon
+3  A: 

How about the "What does this code print?" questions? The difficulty of this can vary very much, but I like this questions really. You can use Arrays, strange functions and special constructs of the language.

Juri Robl
Those are really just "what does this code do?" or "where does the control flow go?" questions; "what does this print?" is just an easy way to see if they know the answer to the real question
Michael Mrozek
I don't think these are good questions. When you are programming, you have the computer to run your code. When you do these questions, you are using your brain to run the code.
chpwn
@chpwn Yes, but if you can't picture what the code is doing in your head you're probably not writing it very well
Michael Mrozek
@Michael It depends. Sometimes, these are really tricky, and getting the output exactly right out of just your brain can be difficult.
chpwn
Please if you do the "what does this print" don't put ; at the end of a for statement. I was caught by that in first year. Sure it's a valid question, but I got a bad photocopy and the ; was faint. It didn't really show that I learned anything, only that I missed a squiggle.
baash05
+2  A: 

Universities are not there to teach programming skills. Period.

Academia should give the scientific background to students and encourage initiative, research and personal experimentation with algorithms, projects, ideally products. But teach programming, that is a skill that has to be acquired with own efforts.

Neither of the two universities I attended ever provided me with a "programming challenge". I was glad to be out of each of them since they were only holding me back.

Developer Art
I agree that universities should encourage intiative and research, but I disagree with the part about universities not teaching programming skills. I think that earlier classes are not too challenging if you already know programming, but they fundamental for you as a programmer,such as data structures. Not only are they important, but if you actually do the homework they are great practice to sharpen the programming skills. And I dont know you but later classes such as Compilers (in my class our compiler had to actually generate an executable), Advance OSs or AI, are quite challenging
Francisco Noriega
@Developer +1 Teaching programming on a CS course - never. On a vocational course - yes.
anon
@bangoker: What you listed is very important, I agree. But it's not what I understand as field programming, it is rather CS. By programming I mean... well, programming, patterns, architecting things, layered architecture, exception handling, source control, a little bit of project management etc.
Developer Art
@Neil Nowadays people go to uni to improve their chances of getting a job. No-one is going to to on a course that doesn't teach them how to program. That said, some universities use programming as a method of applying theorems (Try the Simplex Algorithm in your head with more than 5 iterations) and others are Java Schools.
Yacoby
@Developer Art, yeah I agree, most classes are not as challenging or focus on coding things like that....I can only think of one class for me that was indeed like that,compiler class hehe that little MoFo was a few thousand lines of code, and our teacher, who also worked as a real programmer, taught us to do it in modules/object that were then used by other pieces (a lexic analyzer, a parser, a syntactic analyser, etc)I think that was my first project done in true OO design, were I actually understood OO and not just structured programming inside god classes :P
Francisco Noriega
+3  A: 

Questions like "What's the time and space complexity for the following code..."

For me, complexity analysis questions did the trick. They are not too difficult, and not too easy, but comes in handy in real world problems when you need to decide on the "best algorithm" as a starting point. And the best thing is that the answer is almost always definit

Xavier Ho
Francisco Noriega
+2  A: 

Some of my favorite questions were the ones you suggested: find X number of errors. What's great about those too is you can assign different point values for different errors and such depending on how hard they are to catch and how deep of an understanding you would need to even understand the error, let alone catch it. I also preferred questions that had more to do with high-level concepts rather than coding ability such as class diagrams, design pattern questions, etc. Losing points for something a compiler would have caught is a pain, although, there is something to be said for teaching people to do it right the first time rather than relying on the compiler...

Chris Thompson
better yet, optimize this bit of code... give extra marks for reuseability ... findJohn vs find("john")
baash05
A: 

I think that programming courses written tests should focus on understanding the programming concepts, such as recursion, data structures, or whatever was covered in the course, rather than the specific language used in the course. Of course, you may add some specific questions about the language, but in this case the answer is more of an explanation/ multiple choice than coding.

I believe this because, as you said, when actually coding you always have tons of reference material + compiler info.

I really hated a teacher of mine that used to grade like this: No errors= 100, 1 error = 75, 2 error = 50 (fail). Where something like forgetting a semi colon or misspelling a variable could be an error too. That to me is stupid as it doesn't measure your programming skills.

So, i guess in short I would say: Asks questions about the programming themes seen during the course but don't be tyrannically mean about little syntax mistakes, and then add in some questions about some of the language's features.

Francisco Noriega
A: 

We had to write traces of C++ programs. Each constructor, destructor, assignment operator and copy constructor had corresponding output, a bogus program with inheritance and some operations was given. Not entirely generalizable to C though I'm afraid.

But as it (exclusively) concerns C, explaining or writing down some exotic types are always interesting. Function pointers with const pointer-to-char arrays returning yet another function pointer.

These are the kind of questions I got in university for a course strictly about programming, I see people suggesting questions that would more belong in an algorithms or data structures course but I suppose those aren't really the ones you're looking for.

Pieter
Not a good exercise for C++ either - it';s actually almost impossible to predict when a C++ compiler with a good optimiser will call constructors and destructors. It's certainly not worth trying to do so.
anon
A: 
  1. I like those "find 5 problems" but the nature of the syntax errors should be elaborated on, sometimes you're going through looking for semicolons and such and keep overlooking the mistake.

  2. It takes longer than a semester to know a language from memory. I suggest giving your students documentation of the relevant functions in the standard C library, instead of learning off the order of the parameters etc. Being able to quickly find what you need in documentation and interpret it is a valuable skill (and a skill that many experienced programmers forget they had to learn). I often find there is a significant gap in productivity between those that can use a search engine well and those who can't.

waitinforatrain
+1  A: 

Many of the suggestions above are great.

One that I appreciated was not actually in a programming class but a physics class. We were given all the tools(formulae) we needed to solve the problems in the form of a reference that we were free to use to solve the problems. It brings you closer to a "real" environment where you can actually check this stuff, though it isn't perfect.

Just keep in mind that normally we'd have a compiler and a multitude of tools to check syntax and other stuff so an actual pencil coding task isn't going to be very meaningful. Getting people to write out pseudocode for an algorithm(preferably one that they have to think of for themselves) on the other hand is a good, fair test.

juhanic
caf
A: 

Don't give users problems that are solved by the compiler or standard libraries, like syntax errors or sqrt, unless they're subtle, e.g. int* vs int[].Task them to design data structures with unusual complexities for given operations- for example, a string with O(1) concatenation. Give them programs that are bugged in subtler ways, too, or memory leakers.

DeadMG
@DeadMG: Rope is part of SGI's STL. Or just use a linked list of chars. O(1) string concatenation is boring.
Brian