138

Actually returning early should be the norm. Return as soon as you can. There are at least two reasons for this, of which the first, efficiency, is the least important. But if you return early then needless statements won't be executed. Nor will you need to devise some special code to get to the end just so that you can return. However, the biggest and ...


50

Edit: This relatively high voted answer seems to be confusing to some, as it does not seem to give a clear answer. TL;DR: yes, doing tests on paper is usual at least in my university, at least many years ago. My anecdotal experience means to give a background where this might be coming from, together with the title "CS!=coding". The last section at the end ...


50

100% yes. In beginning courses, it's practically a cognitive requirement. Let me see if I can break down for you why it is so important. It comes down to what we can know that the student knows. Let's say we have a student who is a rather mediocre coder and who, to be honest, really has no idea what is going on in class. We're going to give him a problem ...


48

Teach your students about the return early philosophy. Teach your students about the single return philosophy. Tell them this debate is not settled. Explain to them that different software development teams have different opinions and different standards, and that it's important for them to have both these tools in their toolbox for their jobs. Explain the ...


37

This is really a separate approach from my first answer, which has received some push-back. It's worth noting that many of these loners are simply students who are substantially ahead of the curve. One way to really want to engage such students in pair programming is to pair them with each other. This will create something of a Dream Team. Give them the ...


33

The best way to show your students that their work is vulnerable to SQL injection is to demonstrate it. I'd suggest that you challenge the students to "hack" each others projects using SQL injection. You could then give bonus points for the students who are able to find the most vulnerabilities and for the students who didn't leave that attack vector open. ...


30

Here's an analogy that I've used for several years, and that students seem to understand. It doesn't focus on the rules, but why we have public and private and protected. "Most of you know that I live down at the beach. If you find yourself riding past my house, and it's hot outside, you might come to my front door, knock and ask if you could have a soda. I ...


29

The best way to deal with this kind of student is to head it off at the pass. If you can get the student at the beginning, you can often prevent the problem from festering in the first place. I have a student coming in next year who I have already been warned will have this problem, and I plan to show this to my class on the first day: I will then say ...


28

Is it a wrong approach, giving your students the choice? Or is it wrong to force them never to return early? This is a false dichotomy. Sometimes multiple returns are clearer, and sometimes (rarely) a single return is clearer. You should encourage ("force" is a rather strong word) your students to use the technique which makes the most sense for any given ...


24

One good overall educational strategy is to teach the same thing to students repeatedly, using a Spiral approach, in which each turn of the spiral teaches at a deeper level. Don't expect the students to completely get much of anything at the first mention of it, but reinforce the ideas and deepen the knowledge. You can do this for many things in one course, ...


22

Although most of the answers here seem to be in agreement that coding tests should be done on paper, I would like to offer a different opinion. Any test that includes coding would benefit the student, and most likely the teacher, if it was done on a computer with an IDE for the appropriate language rather than on paper. Since the question contains the tags ...


21

I have 3 tiers of labs. First are the required labs. They're worth 100 points each and every one must do these. If they don't do one, it goes in the gradebook as a zero. These are also the labs that I think are the best of each topic for practicing what they need to work on. My calendar is based on how much time I expect 90 plus percent of the students need ...


19

Speaking as a former student and as a coder: yes. Perhaps there's an element of in-my-day geezerism here, but under the assumption that by "on a computer" you mean "in an IDE" I'll point out that when you have to write it out, you don't get: syntax highlighting autocomplete as-you-type compiler checking new project wizards ("What was the signature for main ...


16

A couple suggestions - The classic xkcd comic about Bobby Tables: Shown, complete with the explain xkcd article can provide a nice, humorous introduction that will get them to start paying to attention. Sites like hack this site are completely legal and allow users to experiment and learn about vulnerabilities (in this case, using them to solve levels ...


16

You have an opportunity for several things here: You can make it a small-team effort rather than a whole-class thing. Say, a team of about 5. The team reviews everyone's code in sequence so all get to participate. Instead of a "code-review" it can be a "code-quality-workshop". The team has to write up the results of the review, with an addendum by the ...


14

As a student who went through 4 years of undergraduate in computer science, writing all my exams on paper, I do think there are advantages to a paper exam. If you need an IDE to tell you the things that are missing, then do you really know your material and syntax?. Having an environment to test your code over and over isn't really practical for examination ...


13

What my teachers used was the following example, which is pretty simple and most people understood. Your father orders a pizza. The delivery guy arrives and expects payment. The wallet containing the money belongs to the object father If the wallet is private, then you have to get your father to open it and pay. If the wallet is protected, you can go and ...


13

On the first day of class, I ask students how Google search can work -- returning an answer to any query over billions of web pages in a fraction of a second. Usually someone mutters "magic". I say, "That's right. What else would you call it when putting together words and symbols enables you to control powerful entities?" Computer programs, I argue, are ...


12

Speaking as a former student, a coder & a teacher: yes. In addition to the points raised by G. Ann, I would add the following: Problems on tests are typically far simpler than full real world problems. It's reasonable to expect increased attention to detail (missing semicolons, etc) when there are fewer details to attend to. In a writing class with ...


12

Speaking as a former student, a former competitive programmer, a real world programmer, yes. Forcing student to write code on paper is not pointless. It has following benefits: Giving you syntax awareness, avoid computer generated code. Therefore giving you deeper understanding of the concept. You will find a way to write shorter code, since you can't copy-...


12

Introduce test-driven development. TDD and agile methods of development are very popular at the minute, and for good reason — you know, ahead of time, exactly what each part of the program must achieve, and you can confidently say that the program will work as intended as long as your tests are thorough. I think that sometimes, the confusion begins when ...


12

We teach AP CS assuming that our students come to us with no prior computing background. Being that the language for AP CS A is Java, we plan our sequencing accordingly. We don't follow the approach of starting with Hello, world. and user input because I think it (main, System.out.println, and Scanner) produces too much of a cognitive load at once . I always ...


12

When I learnt Eiffel, I realised that a single return at the end of a function is the way to go. Eiffel does not have a return. You just set the value of the Result variable, and it is returned at the end of the function. The Eiffel style of programming makes this natural. When I learnt Scheme, I realised that return early was the way to go. In scheme we ...


11

Maybe some complementary points to what as already been said (as a CS assistant professor, giving both theoretical and practical courses). Even for practical courses (those which involve coding), writing code on paper is good. The point is not to fill your page with boilerplate code (and I cannot stress that enough). Writing sequence of Java imports or ...


11

If you search 'computerphile SQL injection' on google, it should bring you to the link below. The man in this video explains SQL injection very clearly and uses a practical example as well by breaking into a vulnerable website he created for the video's purposes. https://www.youtube.com/watch?v=ciNHn38EyRc PLEASE NOTE HE USES MySQL in this video. He ...


11

Ooh, this is one of my favorite lessons! I don't introduce package private and protected in the same lesson as private and public, because there are 3 principles that I want them to absorb that ultimately motivate the entire system. My lesson introduces a few more ideas than just permissions (it's really how I get started with Ojects), but the key ideas of ...


11

I might push back against the core idea here, and this gets to the idea of the central mission of the course of study. Within my course, teamwork is not a primary goal upon which I will assess my students. This is not to say that I don't value it. I think that there is great value in paired programming, but I approach this only as a salesman, not as a ...


11

Here are some notes I wrote when I first introduced this concept at the college level. The example came from Alex Thornton, a lecturer here at UCI. I observed him talk about this in his class, and wrote it up for my students. Extra advantage: it uses the O(1) complexity class, which sometimes throws students. Suppose that you want to get from point A to ...


10

There are lots of great activities at CS Unplugged that do not require a computer. Excellent activities in their own right, you don't have to wait for the days when systems are out. Well worth exploring these resources. This resource is provided by the Computer Science Department at the University of Canterbury, New Zealand, and shared under Creative ...


10

You said he refuses to work, but has mastered the material. How do you know he's mastered the material? I've had students like this in the past. They'll finish 2 weeks worth of assignments in a day and a half. Talk to them. See what interests them about programming. The few times that this has come up, the student had something specific they wanted to ...


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