# The Question Sandbox

This question should serve as a sandbox for in-progress questions. Any question submitted here will automagically be shown in the Guidance Office. We need this space because it's hard to actually work on questions in the Guidance Office, and having a drafting space would be very useful.

Some rules:

• It must still conform to the site rules (not spam, not rude/abusive, etc.)
• Once you put your question here, try and say something in the guidance office to make yourself reachable to users who want to help you. They can also contact you in the comments. That chatroom has a direct feed from this meta.

Some guidelines:

• Feel free to stick your perspective tags on the last line with the format: [tag:recursion] [tag:databases] [tag:robotics] (etc.)
• Feel free to put your title on the first line with the format: # This is the title

# What does it feel like to be bad at Computer Science?

I really love and identify with this post: What it Feels Like to be Bad at Math.

HS teacher Ben Orlin talks about facing failure as a college math student in senior level Topology. The course material wasn't clicking, and as he tried to mentally avoid his own failure, he started showing behaviors he now notices in his own "worst" students: avoidance, fear, excuses, procrastination, and more. Quoting Ben:

Chalk [poor student behavior] up to sloth, disinterest, out-of-school distractions – surely those all play a role. But if you ask me, there’s a more powerful and underlying cause.

Math makes people feel stupid. It hurts to feel stupid.

It’s hard to realize this unless you’ve experienced it firsthand. Luckily, I have (although it didn’t feel so lucky at the time).

....

I tell my story to illustrate that failure isn’t about a lack of “natural intelligence,” whatever that is. Instead, failure is born from a messy combination of bad circumstances: high anxiety, low motivation, gaps in background knowledge. Most of all, we fail because, when the moment comes to confront our shortcomings and open ourselves up to teachers and peers, we panic and deploy our defenses instead. For the same reason that I pushed away Topology, struggling students push me away now.

When have you failed in learning Computer Science, and what did it feel like?

• Do you want to add to the end - something like "How did you get past it, if you did?" Or "Did anyone find a way to help?". Something similar? Jul 18 '17 at 18:01
• I think that's similar to @BenI's comment in the Guidance Office. I guess that makes it more "answerable", but it also seems like a different question to me.
– nova
Jul 18 '17 at 18:04
• @Buffy rolled back change because it's a direct quote--- not sure phrasing should be changed there
– nova
Jul 18 '17 at 20:50
• This question still seems to me to be a list question as currently posed.
– Ben I. Mod
Jul 18 '17 at 21:20
• I think it's 100% a list question
– nova
Jul 18 '17 at 21:31
• This is related to Carol Dwek's research, on positive/negative mindset. Oct 30 '17 at 9:06
• @ctrl-alt-delor Growth and fixed mindset, but yes! Very much so!
– nova
Oct 31 '17 at 12:37

## What is a good first program that is nothing like "hello world"?

If you are like me, you hate, loathe, and despise the "hello world" program. If that is the case for you, then you probably are not also teaching C to beginners.

What is a good alternative for a first program for students that bears as little resemblance as possible to "hello world"? Pick whatever language you like for this.

What sort of background or scaffolding is needed for your program to work as a first program. What advantages does it have over "hello world"?

## How do you build on your start? Where do you go next? How does the first student exercise build on your first program?

Note that if you are teaching C then "hello world" is perfectly fine first program since it does embody much of the language in a small space. It is also a program that can be simply extended, giving the student a bit of experience with both syntax and C concepts.

However, In Java, Scheme, or Python, the "hello world" shows you almost nothing of the language and provides no real base on which to build. In fact, it requires meaningless boiler-plate syntax (in Java) that begs for explanation but to little real benefit.

tags ,more?

• I feel, as I've said in chat, that this is opinion based. Aug 10 '17 at 8:31
• I like it. It's basically "what's a better version of hello world?"
– nova
Aug 10 '17 at 13:42
• I do turtle graphics in python and scratch. I have also been experimenting with giving them a working program, and getting them to change it. So a much more complex program, to start with. Start with reading and modifying, not with create from scratch. Also “Hello, World” only makes sense, to me, if done in the context of Unix command line. Oct 30 '17 at 9:00
• Agree, completely. Oct 30 '17 at 10:51

Note: This is intended as a radical edit of nocomprende's original post here. I've entered it this way so as to preserve the original.

# Project ideas for student programming exercises

Students in the first programming course can learn a lot by creating project programs around various example problems. Assume that the students know how to program, something about one and two dimensional arrays, and perhaps a few basic data structures. Here are two examples, both of which stress arrays:

• Tic Tac Toe (game and Tournament)

Create a series of progressively smarter algorithms, perhaps using inheritance to include the simpler cases under more advanced ones. Tournament plays every strategy against all others 10,000 times and charts the results.

• Conway's Game of Life (standard and with variations)

Create a game board and implement the rules. Permit boards of various sizes and implement a simple way to set the initial conditions. A good discussion of the Game of Life can be found on Wikipedia

This question is an attempt to gather a collection of such ideas to be used at varying levels of difficulty. What are good ideas that you have used?

Different projects, of course, have different objectives. Say something about what you are trying to achieve with your project and point to any available materials that another professor might adapt/adopt.

Tags:

• Is this asking about projects to help with understanding of multi dimensional arrays? Or something else? Oct 30 '17 at 9:03
• Could be that, or anything, really. Polymorphism... Focus on project. Oct 30 '17 at 10:50

# Project ideas for student programming exercises

Students can learn a lot by creating project programs around various example problems. Here are some that I thought of, or have created demos for myself:

• ASCII Art
• Maze Maker
• Tic Tac Toe game and Tournament
• Database (5-10 tables) for a personal interest
• Count Change - iterative, differential, recursive
• High - Low Guessing game

I would like to gather a collection of such ideas to be used at varying levels of difficulty in various paradigms (Console, Windows, Web, etc). What are good ideas that you have used?

(Background info: Maze need not use any of the standard algorithms. A Solver is currently beyond my abilities, or interest anyway. ASCII Art involves 2-D arrays and nested loops. Tic Tac Toe - I created a series of progressively smarter algorithms, using Inheritance to include the simpler cases under more advanced ones. Tournament plays every strategy against all others 10,000 times and charts the results.)

Different projects, of course, have different objectives. Say something about what you are trying to achieve with your project and point to any available materials that another professor might adapt/adopt.

• List Question! But, someone encouraged me to ask it. You-all can beat it to death now, I am letting go.
– user737
Aug 15 '17 at 16:13
• We don't like list questions, but one of the metrics on area 51 is answers per question. 😕 Oct 30 '17 at 8:51
• This could be very useful to help people advice pupils about project ideas. Nov 20 '17 at 18:42

Subject: How to Get Good High School CS Teachers

So, my school has opened up a position recently, and I have been told that it has been historically very difficult to find strong candidates. I am worried that we won't have a great pool of applicants. How can we recruit, at a very local level, teachers into this field?

• Depends a lot on the needed qualifications. The local pool may be small. Since, I think, your standards are pretty high the pool might be even smaller. I suspect you will need to do quite a lot of training for anyone. That, actually widens the pool, if you have the time. Aug 16 '17 at 20:15
• @Buffy Do you think the question is even topical for the site? I couldn't decide.
– Ben I. Mod
Aug 16 '17 at 20:39
• It seems a bit marginal as is, honestly. Aug 16 '17 at 20:40
• Another possibility for recruiting, is that maybe there are people like yourself who were former students (4-5 years ago) and want to stay in the area. You might be able to draw on a pool of graduates either for teachers or for recommendations. Aug 16 '17 at 20:42
• @Buffy In what way? (I want to fix and post)
– Ben I. Mod
Aug 16 '17 at 20:47
• Seems a bit narrow. Especially as you say "at a very local level". If you broaden it a bit more people might have an answer. Note that HS recruitment is probably different from university. But you may also have laws that apply about breadth of search. If so, some mention is needed. Aug 16 '17 at 20:56
• This is the educators part, as opposed to the well explored education. Aug 18 '17 at 9:19
• If in the UK, then help people to know that they can get £25k to do their teacher training. Oct 30 '17 at 8:55

Subject: If we stopped testing CS students, what sorts of assessments could we use to evaluate their progress?

I have been reading Mathematical Mindsets by Jo Boaler. She builds on Carol Dweck’s work on fixed vs. growth mindset, and basically tears apart the way we teach math in the US (she’s from the UK). In addition to other things, she says we produce students who are fearful of and severely dislike or hate mathematics due to traumatic early exposure to timed, stressful testing. She aims to fix the problem, one teacher at a time.

Boaler wants teachers – specifically math teachers, but I believe we can extrapolate to programming – to stop traditional testing. She offers several alternatives as suggestions (some of those being self-assessment and peer assessment).

My question is, let’s say we buy into this for teaching CS (which comprises, I know, more than programming, but most of us are programming teachers) – how would it look? How would you, could you, assess your students?

Tags: testing, best practices

## The Moore Method in Computer Science: Possible? Desirable?

The Moore Method was created by R. L. Moore at UT Austin and the U of Pennsylvania to teach advanced mathematics courses.

Some aspects of the method are
* No textbooks or external aids
* No collaboration
* Minimal Lectures, mostly definitions
* Frequent student presentations of their work

The basic idea was to pose a question or state a theorem for the students to work on. All they could use was their previous work. In effect each student developed a deep mathematical system entirely on their own.

Mostly the Moore method, which is still in use in a few places, has been used with small classes of highly motivated students.

## Can the Moore Method be applied successfully to Computer Science courses? Has it been?

To narrow it a bit, a Data Structures and Algorithms course might be an appropriate vehicle for such an approach. The professor could give students the formal definition of some structure or algorithm and the students would be required to develop the structure/algorithm entirely on their own without reference to any other source, including the internet or each other.

In mathematics this method is well known to be wildly successful in creating great mathematicians who credit the method for changing their lives. But it is also well known to be risky and to not work for everyone. It is surprisingly instructor intensive, as the students may not wind up doing the expected thing. In mathematics we value new theories, so proving a theorem in a new way is a highly desirable outcome. Is the same sort of thing valued in CS? What would such a course look like.

At the moment this is a thought experiment unless someone knows of an actual use. In the latter case, I would like to know the structure used and the outcome whether successful or not. Is this a valuable direction for further study?

• Gosh, maybe it should be called the Lesse Method? Jun 14 '18 at 17:00

# What are possible curriculum designs suitable for people changing fields into Computer Science.

Assume that a person holds an undergraduate degree in some field other than CS, perhaps not even a technical field (art, music, ...). What sorts of curricula are available to such people if they want to become CS professionals.

• Note (caveat). I would ask this question primarily so that I can answer it. I have a few different designs but others may have more.

1. A residential program at an established college or university. The program could be at an undergraduate or (preferably) a post-graduate level.

This is an expensive option, of course and it requires your presence, but it has the following benefits: You study with a group of scholars including faculty and other students. You have immediate access to a research library. You get an established credential upon completion.

2. A partial face-to-face and partial online program with an established institution. A typical program might require your presence on-site for one or two days a month.

This option might be somewhat lower cost, though travel and lodging must be considered. It has most of the advantages of a full residential program but permits you to have a life elsewhere, though a busy one. However, don't consider such a program to be "part time." It can be very intensive, requiring daily communication (via the internet) with classmates and faculty. There are programs that require face-to-face interactions for longer periods (say in the summer) but less frequently, though these are probably less likely to be suitable for someone who must maintain employment while studying.

3. Something like a full on-line program. This could be run by a university or a profit-making institution.

This gives you the most freedom of location and has (probably) the lowest cost, but you may not end up with a suitable credential, depending on the sponsor. It also gives you almost no access to the "community of scholars" that many consider important in learning. It is surprising how important a "coffee room" is to an academic department. Without the community of scholars you need to be completely self motivated as you get little support from colleagues within the process.

## Highly Speculative Questions

Some curricula have highly unique features. Innovations can be small or large. They may be courses, student activities, teaching methodologies, etc. Others might want to emulate them if they only knew more. What is unique about your curriculum? Why do you think it is important? Should other people try to emulate what you do? How can they get started?

### What does a person with an undergraduate degree in CS still need to learn to be employable in the computing field?

Some recent CS graduates feel unprepared. Some may be unprepared. What is missing from a typical undergraduate program, or not sufficiently emphasized, that a person needs to know for successful employment in a computing profession. The gaps may be technical or not. What evidence do you have for the gaps you suggest? How can a person fill the gaps?

### More to come.

That is all I have at the moment. Feel free to add your own. These questions might press the boundaries of our charter and may never appear.

• "employable in the field" - which field? Aug 10 '17 at 10:42
• I thought of adding, "Why can't we all just get along?"
– user737
Aug 15 '17 at 19:30
• I think computing is far too broad a field to make that an answerable question. Even "software development" would probably be too broad. Aug 30 '17 at 14:55

# Teaching Around the Clock

First, a few assumptions. Most classes meet a few times a week, maybe just once. The students probably work outside of class. But they often have questions as they perform outside tasks.

## How can you organize your class using computer communication so that you seem to be always present to answer questions?

If a student gets stuck they have various alternatives for getting un-stuck, of course. But, perhaps, some of them are improper. Copying other student's work, for example. You probably hold some office hours, but those aren't convenient for many (maybe for most), and they don't permit seamless continuation of the student's progress.

Today there are a lot of computer-mediated communication links possible, from email to full video. What have you used to effectively communicate with your students when you are not in the class room?

I doubt that anyone would expect a solution in which you really are available around the clock. But you have control over some variables that can make your presence felt even while you carry on otherwise.

My own goals are to make it seem like I'm always present - or at least as if a student can get an answer immediately. I don't want answers given to one student to be denied to the rest of the class. I want to be able to fix errors I make. I want students to be able to contribute when questions arise.

I've used wikis and email lists pretty effectively for this. What are your suggestions and caveats? I'm especially interested in modern, but low cost (free), methods.

• This question might want to specify university level (or at least it seems like it's headed there), and could be a little less leading. (It sounds like you have an answer in mind already.)
– Ben I. Mod
Sep 19 '17 at 21:06
• I have answers, but wonder if there is something more useful for the modern age. Probably university is a good idea, but only if in HS you meet more frequently. A five day a week class may not need it. Sep 19 '17 at 21:48
• Nice question and I encourage my students to e-mail with questions at any time am so far I have been able to answer then within a few hours of asking. The real problem though is not being available but being available in person. I asked my daughter why students her age don't like to send e-mail questions and she said she would rather wait and do it in person. Jan 6 '18 at 15:36
• Email has a flaw that it is a two-person conversation that others in the class may not benefit from. That needs to be overcome, so that all can benefit from the questions of others. In particular, if you give hints to some, but not all, it can be seen as unfair. I prefer many-many conversations for all class interactions. Jan 6 '18 at 16:07

This is about an issue I have, but can not form a question that could be answered.

I sometimes have to teach touch typing as part of Digital Literacy. I like this idea, and I like doing these mini-classes (usually 10-15 minutes, within a 1 hour class). I get the pupils to put their jackets over their keyboards and hands, and look at the screen.

However I am in two minds about teaching querty. This keyboard layout was invented in the era of mechanical typewriters, to make the mechanics possible, and to avoid jamming. This layout is no longer needed; research shows that most people fail to learn to touch type on querty; better layouts exist, that are optimised for the human (as opposed the mechanics); and it is trivial to change the layout, on most devices. (You can not easily change what is printed on the keys, but when you touch type you do not look at the keys.)

The difficulty in choosing to teach a different layout is political, not technical. I have people tell me “Go with the flow, you can not change the world.” But this is a problem that does not need everyone else to change. I changed the layout on my account, no one else needs to be involved. There is a button in the tray, in case another teacher needs to use my account (though them using someone else's account would be in violation of the computer miss use act).

If I am the only teacher that teaches another layout, then I feel that I am doomed to fail, as there will be to much pressure from other teachers for the pupils to switch back to querty.

So I am wondering what should I do. Should I try to persuade the school that we should teach touch typing using a more optimal layout? Or should I just give up? Has any one got any experience with this?

I feel that if we can not change something as simple as this: benefit to the person that adopts the change; no need to convince anyone else. Then how can we change important things, such as $CO_2$ emissions.

Tags:

Digital-Literacy

• A few days ago I started reading Mindstorms — Seymour Papert, I read about what he calls the QUERTY affect. This is where ideas last longer than they should. They persist through myth e.g. “There must be a good reason”, “The layout is to make it easier”, “Every other way/layout is harder”. These myths are wrong, and stop the idea from dying. There seems to be a lot of these zombie ideas in computing at this time. Nov 12 '17 at 13:47

# Introduction — question idea follows

I (as you may have guessed) think that the following two thinks should be taught in school.

## 1. The Unix operating system:

Not just as a case study, though this is of value, but also as a working system. That is schools should use Unix on all of there computers. (When I say Unix I mean all Unixes not just UNIX™. So that would include GNU.)

Why do I believe this?

• It gives more control of their computing to the students.
• It is easier to see the connection between what you do, and the computers response.
• There is the right level of abstraction: Not working at the machine level, but not so abstract that one can not understand what is going on.
• It is a simpler system that the common, ones used today.
• It makes case studies easier as pupils have more experience.
• It is (While old 1960s technology), the most up to date system that is available.
• It is used on all 500 of the top 500 supercomputers, it is used on more than half of the web, it is used by most of the internet infrastructure, it is the worlds fastest growing OS.

## 2. We should teach Free Software — that is software where the user has freedoms.

Why do I believe this?

• Students should be free to use the software the way they want to (subject only to the law, and school policy). They should be free to do this today, and to continue after they leave school.
• Students should be free to study other peoples code, and make changes to it. You learn to write by first reading, and them making changes to existing code. (You will not read everything, but the teacher will guide you in what to read.)
• Students should be free to show off their changes, and share with others.
• If a student brings food to class, they must share. If they bring software to class, they must share. Therefore they must have permission to share.
• If we have not got the freedom over the software, then we are a slave to it.
• Without freedom, we are teaching students to be consumers and customers.
• Without freedom, we are the marketing department to software corporations.

## Therefore

Use Gnu/Linux in schools. Gnu/Linux is Free Software and it is Unix. It also has the advantage that the price is close to zero, and is cheaper/easier to administer.

## The question idea

I know that this solution solves a lot of problems, that I have in the classroom, but I struggle for a question.

Ideas:

• Ask how we promote Gnu/Linux and Free Software in schools.
• Ask questions to which the answer is Gnu/Linux or Free Software.

The problem I have is:

• People see Gnu/Linux an foreign, and hard to learn. “If Windows is meant to be easy, and it took me all this time, and I still struggle, then how can I learn Gnu/Linux.” Answer: “I leant it once in 1991, in the mean time you have re-learnt Windows 3 or 4 times.” Answer 2: “It is easier to learn, as it is more consistent.”
• People see Free Software as pragmatic. Or as a thing concerning programmers only. I see it as nothing to do with programmers, it is about user-rights.

• I don't necessarily share your politics here, but perhaps a question that would suit you would be, "how can I show that Gnu/Linux is not hard to learn?" (Be prepared, though, for some to answer that it is.)
– Ben I. Mod
Nov 22 '17 at 4:43
• As stated the question calls for just opinion. I have different opinions. I'm fantastically productive on a Mac, for example, though I also have a unix system and a windows system which I seldom use. I also note that Fortran is the language of choice on many supercomputers. Do you also recommend we use that, more or less exclusively? Fortran is used due to the extensive history there of optimizing array operations. Nov 25 '17 at 14:52
• @Buffy Popularity is only one point, and probably the least important. Its only relevance is to counter the argument that we should teach Microsoft, as it is popular. I want to teach Gnu, as it is easier to learn, and it does not date so quickly. I also wont to teach Free Software, because I want students to be able to install software at home, and after they leave education. I want them to learn that they can decide what their computers do, they don't have to have malware, that is installed as part of the OS / applications / or by OEM. Education is about becoming free. Nov 26 '17 at 13:38

# Pedagogical advantage of this code

This code taken from https://cseducators.stackexchange.com/a/3936/204 by @peter. Where he states: “A student can absolutely take a C-style approach to this, making little to no use of the object-oriented paradigm of Java.” Then showing this as the alternative.

public class Temperature
{
// data members/instance variables
private String scale;
private double temp;

// constructor
public Temperature(String scale, double temp)
{
this.scale = scale;
this.temp = temp;
}

// getters
public String getScale()
{
return scale;
}

public double getTemp()
{
return temp;
}

// setters
public void setScale(String newScale)
{
scale = newScale;
}

public void setTemp(double newTemp)
{
temp = newTemp;
}

// conversion methods
public double cToF()
{
return temp * 9 / 5 + 32;
}

public double fToC()
{
return (temp - 32) * 5 / 9;
}
}

public class TemperatureRunner
{
public static void main(String args[])
{
Temperature hotDay = new Temperature("F", 101);
System.out.println(hotDay.getScale());
System.out.println(hotDay.getTemp() + " F");
System.out.printf("%.2f C\n", hotDay.fToC());

System.out.println();

Temperature coldDay = new Temperature("C", -10);
System.out.println(coldDay.getScale());
System.out.println(coldDay.getTemp() + " C");
System.out.printf("%.2f F\n", coldDay.cToF());
}


Software Engineer objections to this code:

• I thinly discussed structure: getters/setters on everything.
• Verb names for query functions (Though this is common in Java: this was introduced by Java-Beans, to ease machine parsing)
• Mutable: not thread safe. Even with locks, would not be thread save, as there are two setters, that can be interleaved. Mutability also leads to other bugs, that will exhibit long before student gets to concurrency.
• Implicit preconditions on cToF, and fToC (e.g. can call CToF on an F ).
• Scale is not used. Client is handling formatting, and Scale.

I don't see what is gained by this code, and it is much larger than the C code.

I had a go at re-writing it, to be more OO.

public class Temperature
{
//data
private String scale;
private double temp;

// constructors
public Temperature(String scale, double temp)
{
this.scale = scale;
this.temp = temp;
}

//functions
public double cToF(double c)
{
return c * 9 / 5 + 32;
}

public double fToC(double f)
{
return (f - 32) * 5 / 9 ;
}

//converters
public Temperature asF()
{
if (this.scale == "F")
{
return this;
}
else
{
return new Temperature("F", cToF(temp));
}
}

public Temperature asC()
{
if (this.scale == "C")
{
return this;
}
else
{
return new Temperature("C", fToC(temp));
}
}

//formatters
public String formatted()
{
return String.valueOf(temp)+scale;
}
}

public class TemperatureRunner
{
public void run()
{
Temperature hotDay = new Temperature("F", 101);
Temperature coldDay = new Temperature("C", -10);

System.out.printf("%S\n", hotDay.formatted());
System.out.printf("%S\n", hotDay.asC().formatted());
System.out.printf("%S\n", hotDay.asF().formatted());

System.out.println();

System.out.printf("%S\n", coldDay.formatted());
System.out.printf("%S\n", coldDay.asC().formatted());
System.out.printf("%S\n", coldDay.asF().formatted());
}
}

public class Main
{
public static void main(String args[])
{
new TemperatureRunner().run();
}
}


This can also be used as a basis for teaching other features. I evolved it into this (with the addition of an enum, and some final & static:

public class Temperature
{
public enum Scale {
F ("°F"),
C ("°C");

private final String units;

//Constructor
private Scale(String units){ this.units = units; }

//getter
public String toString() {return this.units;}
};

//data
private final Scale scale;
private final double temp;

// constructors
public Temperature(Scale scale, double temp)
{
this.scale = scale;
this.temp = temp;
}

//functions
public static double cToF(double c)
{
return c * 9 / 5 + 32;
}

public static double fToC(double f)
{
return (f - 32) * 5 / 9 ;
}

//converters
public Temperature asF()
{
if (this.scale == Scale.F)
{
return this;
}
else
{
return new Temperature(Scale.F, cToF(temp));
}
}

public Temperature asC()
{
if (this.scale == Scale.C)
{
return this;
}
else
{
return new Temperature(Scale.C, fToC(temp));
}
}

//formatters
public String formatted()
{
return String.valueOf(temp)+scale;
}
}

public class TemperatureRunner
{
public void run()
{
Temperature hotDay = new Temperature(Temperature.Scale.F, 101);
Temperature coldDay = new Temperature(Temperature.Scale.C, -10);

System.out.printf("%S\n", hotDay.formatted());
System.out.printf("%S\n", hotDay.asC().formatted());
System.out.printf("%S\n", hotDay.asF().formatted());

System.out.println();

System.out.printf("%S\n", coldDay.formatted());
System.out.printf("%S\n", coldDay.asC().formatted());
System.out.printf("%S\n", coldDay.asF().formatted());
}
}


You could also add methods to add and subtract temperatures. You may ask why not expose the insides and let the user of the class do it. The purist answer is that it breaks encapsulation. The pragmatic answer is that then some one will try multiplication or division (and get it wrong). I often here people say that 30° is double 15°, it is not.

[I am not a Java programmer, so sorry if this is not the best. However all code is compiled and tested.]

So is there any pedagogic value in the first? Does this value out way the harm of having to un-learn the bad practice? What am I missing?

Added by Buffy: Here is a much simpler Temperature class. I think it is probably suitable for an early example.

public class Temperature{
public double getF(){return temperatureF;}

public double getC(){return (temperatureF - 32.0) * 5.0 / 9.0;}

public void setF(double tempF){
temperatureF = tempF;
}

public void setC(double tempC){
temperatureF = tempC*9.0/5.0 + 32.0;
}

private double temperatureF = 32.0;

/* Could be improved with a check for a legal temperature (i.e. >= absolute zero) */
}

• If anyone can use this to make a question, please feel free. I will not be upset. @peter Nov 14 '17 at 15:21
• I use this same example in the our MVC section as well. Feb 4 '18 at 21:05
• @MrBradley not of that comment makes sense to me; What is your MVC section? Feb 4 '18 at 22:08
• @Buffy I don't like the names in your code. When one speak/writes English, one does not say what is the Fahrenheit of the room. And you does not say what is the getTemperature. Therefore we should not use get. And we would be better of using better English nouns such as temperature. Unfortunately I needed to use enumerations to achieve this. Feb 4 '18 at 22:12
• I agree, in fact. This code was written while trying to adhere to the netbeans "standard" for naming - which I agree is terrible. But that is its history. A name like asFarenheit is better. If t is a Temperature, then T.asFarenheit(); reads pretty well. But the get-set convention is an abomination. Feb 4 '18 at 22:20
• I have nothing against the name set, only their over use. get is a bad name. Feb 4 '18 at 22:22
• I remember being told optimise for readability. A college was struggling with this. While talking to him, I realised that he was often caught in a dilema, of different types of readability. After some discussion, and thought. I realised a solution. Optimise for readability of your clients code over that of the service (class/method). While we want both to be readable, if there is a conflict prioritise the first. Focus on the first when choosing names for classes, methods, attributes. Choose methods and objects that will help you to write better client code. Feb 4 '18 at 22:31
• The temperature class is a good example for a number of reasons: - You can test for correctness (testing classes) - You can display results in the console, - You can add a small GUI around - allowing you to introduce the Model-View-Controller pattern Feb 6 '18 at 1:54

I'm posting here instead of directly because I'm not sure this question is acceptable within our current meta. I'm convinced that it is useful, but I am curious about whether others think this question should be acceptable on the main site.

# Object-Design Traps

I'd like to create an activity in which I give a series of badly designed interfaces to help alert students to common traps in object design. Students would have to hunt for the error and show where it violates a principle of SOLID. I have never created a lesson like this before, and I could really benefit from the experience of people who have watched students (or younger engineers) struggle to learn how to design objects well.

The question, then, becomes what common traps should I alert the students to?

• The Open-Closed principle is a minefield. If you interpret it wrongly and ignore SLID, you wind up overusing inheritance in bad ways. The naive view is that inheritance is good and so inheritance from concrete classes is fine even when you change the "interface" or the semantics. The five principles work together in a better view. Feb 9 '18 at 16:42
• I'm not sure that students can grok the real lessons of SOLID without help. A guided activity is probably best. Probably as a team based group discussion. Probably with access to the web for examples and caveats. Feb 9 '18 at 16:45
• Many programmers ignore the Law of Demeter (often guilty myself) in the heat of battle. Doing so seems innocuous and it is hard to recognize immediately in many cases. I don't know of IDE support for it. Feb 9 '18 at 16:46
• Rather than just interfaces, you may want some classes. Even an app and the activity is to Refactor it (using testing, pairing, etc) into a better design. Feb 9 '18 at 16:50
• I'll note that there is another way to "extend" without using inheritance. You can embed one object inside another (a field) and have the container provide services, some fulfilled by the wrapped object. Decorators do this in a simple way. Feb 9 '18 at 21:05
• My concern with this question is that it seems like a list question. Multiple answers could end up equally valid and no single answer seems like it could cover the issue well enough to discourage other ones. This is because there are multiple traps. But I'm new here so maybe list questions are ok. It's also not clear if what qualifies as an "object design trap" is a failure to follow the OO paradigm (which is not universal) or simply a design failure that happened while following OO perfectly fine (which happens quite a lot). Feb 9 '18 at 22:11
• @CandiedOrange List questions are still, 8 months in, in an ambiguous place. We are more accepting of them than many sites, but not always, and the line has never been entirely clear. We're sort of waiting for someone to have a big "A-HA!" moment that clarifies good list from bad list within our context. If you search the CSE meta for list, you'll get a lot of discussion. This one in particular might be interesting at this moment.
– Ben I. Mod
Feb 9 '18 at 23:02
• @BenI. Ok done. Feb 10 '18 at 2:25

# NodeJS and javascript libraries are overwhelming students

I started teaching NodeJS to some of the students in the computer science major at my school (these students know the basics of Java and OOP).

The idea is for them to make a small web project (such as a grades and averages calculator or a display for a timetable etc.) using javascript.

I plan to teach about javascript, client-server separation, http requests etc. The main problem is the vast number of JS libraries in existence. I intend to emphasize that most of the code is already written. E.g. the code for creating nice graphs exists in charts-js, and responsive client side frameworks (angular, react) exist.

This project is also meant to teach the notion that programmers rarely write programs from scratch, and that they should often see if there exists a library\framework that give a functionality they need.

However, with Javascript, the vast number of libraries makes it somewhat difficult to know which ones to pick. It's not impossible, but I'd rather students not waste time on that.

I ran this by a handful of students, to see whether students actually get overwhelmed. From what I saw, students are likely to waste time reading up about the library they are checking (somewhat like reading a review for a PC before buying it). Research is great, but the amount of wasted time was quite big.

So, what can I do to teach them how to "sniff" the "correct" library more efficiently? In other words, how can I teach them which metrics are significant (and why those metrics are important) when deciding whether a library is useful? Bearing in mind that the time it takes is to be considered, I'd prefer ways and metrics that are generally faster (e.g. reading up the documentation of a library is somewhat slower when compared to checking npm's download in the last day)

1Unless they program in Scratch.

• Hmmm. How would you do it yourself? If you are effective at it, then show them how you approach it. Otherwise give them a list of resources you have found with some added metrics that you would find useful. It needn't be comprehensive, but complete enough to cover their own needs at the moment. Feb 25 '18 at 13:09
• @Buffy fair point. But do you think the question is good as is? Or should it be changed? Feb 25 '18 at 13:15
• If I've just given a complete answer, then it isn't very good as a site question. I don't use javascript or any of its libraries so can't help with details, but the question is only good if there is more to say about it. See my just posted thingy here for a way to think about one aspect of this sort of thing. Feb 25 '18 at 13:17
• @Buffy it isn't a complete answer. I'll make some changes to make it clearer what I consider an answer Feb 25 '18 at 13:21

Subject: How do you teach students to do code reviews/inspections and what do you have them look for?

I'd like to start introducing my second semester programmers to code reviews. Should they inspect just their own, or others? What should I have them look for? A checklist for each team or individual would be ideal. What are your ideas? Here's some of mine: meaningful names, effective use of white space, no magic numbers, no repetitive code (move to a method), good organization of methods/classes within a file (are they grouped logically?), good organization of files within a project (again, broken up logically), no dead code or commented out code, no meaningless, useless, repetitive, or obsolete comments, functions that do only one thing, functions that have only parameters they need, all boundary conditions are checked, no inconsistency in way of doing things. And none of these really even address OO aspects of good class/hierarchy/abstraction design. What would you add/delete/modify?

## How can Take-Home Tests be validly used in CS?

One option in testing is to permit students to take the test at home on a schedule of their own choosing. The testing "period" might be a day or a week, and would certainly have some rules attached concerning collaboration. I assume that the rules would not (could not) be so restrictive as to forbid use of books and notes, nor even the internet.

The advantage, if any, is in reducing risk for the student of freezing up during an exam, or just having a bad day physically or emotionally.

How can this be made to work? What sorts of questions can be validly asked? What courses can it be validly used in? What sorts of students can this be used with? Any other conditions?

tags: testing, best-practice

Subject: Culminating projects in programming language classes

I know many instructors end their programming language classes with a culminating project to have their students apply what they've learned over the semester. Is the culminating project a necessary feature of all programming language classes (note that I refer to classes that are not themselves projects, such as compilers)? Is the absence of a culminating project a problem, or a disservice to students?

If a culminating project is administered, is it assigned to students individually or in groups? (How many students make a good group?) Are students allowed to come up with their own idea for the project, or are they provided suggestions from which they choose? Is a list of minimum requirements for the project provided?

If culminating project is not required, why not?

Tags: project, lesson-review

• At the very least the question in parentheses should be split off into a separate post (although I suspect it may already have been asked). IMO each of the questions in the middle paragraph should be asked separately. Apr 11 '18 at 9:39

Teaching how big a function should be

I've recently been working with students to develop abstractions and algorithms for the AP CSP Create Task (task instructions here). For the languages (C and Python) I use, this involves defining functions. One area where students get hung up on is how big to make a function and what that function should do in terms of "managing complexity" (College Board language).

I also talked with another teacher recently who was teaching functions. The task called for defining a function other than main, so one student copied all the code from main, put it in a function of its own, and simply called that function from within main. If that's all that is done, that's clearly not why functions would be advantageous to design.

This relates to another topic we have addressed here: printing v. returning. Ultimately, the determining of how much a function should do is both an art and a science.

What are strategies you have used to teach students how to break their code into well-defined functions?

• "... how big to make ...". In this context big isn't well defined. I think you mean a statement/line count. But there are better complexity measures. See:en.wikipedia.org/wiki/Cyclomatic_complexity. I prefer functions with McCabe complexity = 1 and can achieve it with polymorphism (though not in C) and recursion. However most of the resulting functions have a line count of less than 4. Apr 19 '18 at 21:00
• Of course I can't use switch and do that, but even in a trivial switch the complexity need only be the number of cases. Apr 19 '18 at 21:09
• @Buffy I mean in terms of breaking a program into sub-tasks. It might be 1-2 lines; it could be a bit longer. I do like that complexity measure you mentioned, but there’s no way my beginning students would use that (based on first glance). Unless there’s a way of making it beginner-friendly. I will clarify “big” when I officially ask this. Apr 19 '18 at 22:55
• There is an online tool you can use. You paste the code into a form and it gives you numbers. I can't remember if it gives other complexity metrics as well. Apr 20 '18 at 0:39
• so has a tag for cyclomatic-complexity, I can't seem to find the online tool. SO post says that Eclipse has a plugin for it. Apr 20 '18 at 0:46
• How long should a function be? To paraphrase Abraham Lincoln: "long enough to reach the 'return'." Aug 1 '18 at 20:44
• I love this question
– Ben I. Mod
Apr 26 '18 at 3:49

# Once implicit typing is introduced, how can I impress upon students the importance of not abusing it?

I typically have the same students two semesters in a row, for programming I (VB.NET) and programming II (C#). In our early, impressionable time together, I stress to these students (high-schoolers) and show them by example (I write lots of code for them) the importance of writing clear, readable code, which is partly achieved by explicitly specifying types for all variables (indeed, at first I do not tell them there are other options)

However, at some point, I have to reveal to my students that they can, indeed, declare a variable as an Object (i.e. Object x = new Horse("Silver");) and that it can hold anything; or, that they can declare a variable as var (i.e. var y = "foo";) and that the compiler will figure out what type it is. Some of them discover this on their own, of course.

Then I inevitably have students who abandon the good habits they had formed and want to make everything an Object, or declare everything as var. I am always torn about how insistent to be that they revert, because I know the use of var in C# is controversial in the industry. (See the SO discussion use of var in C# for an example). Plus, the more savvy students are hanging out in SO anyway, and they see the profligate lack of explicit typing and other good programming habits in some questions and answers there.

My question is, since these students are still learning, and since it is my classroom after all, should I emphatically require that they always explicitly specify types unless absolutely necessary? And, if I do require it, how can I explain the (in my opinion) sloppiness they sometimes see in online communities?

[tag: data-types]

• please check that my added examples are accurate for C# Apr 28 '18 at 22:39
• those look good Apr 28 '18 at 22:53
• I think the question would be clearer if it were more consistent in the use of terminology. There's already enough confusion over the difference between strong vs weak typing and compile-time vs runtime typing without compounding that by talking about implicit and strong typing as opposites. I suggest s/strong/explicit/g Apr 29 '18 at 20:19
• @Peter Taylor I agree with you about that confusion, but I am reluctant to change the wording because, even though I did not mean the question to be solely about C#, that is the language of focus, and it is called a strongly-typed language by its designers - see docs.microsoft.com/en-us/dotnet/csharp/programming-guide/types Apr 30 '18 at 0:52
• TBH, I think you're reinforcing my point about confusion. I don't read the question as about choosing one language over another, so whether or not C# as a language is strongly or weakly typed is irrelevant. In fact, if C# is unambiguously strongly typed then that comment contradicts the part of the question which talks about "profligate lack of strong typing" in C# code. MS documentation seems to support me by contrasting implicit typing with "giving an explicit type". Apr 30 '18 at 6:09
• While thinking about that reply, it did also occur to me to ask: what about other uses of type inference? E.g. does the omission of generic type arguments in method calls fall under this question? Either way, it might be worth making it explicit. Apr 30 '18 at 6:15
• I'm OK with changing it to explicit. I just don't want to create noise by getting into a discussion about terminology. And yes, the same situation applies to method definitions. Apr 30 '18 at 11:43

# Why do so many novice programmers make the same, silly mistakes?

When answering questions on StackOverflow, we often see the same silly mistakes over and over. Some examples:

• A loop that's meant to accumulate results (calculating a total, appending to an array/list, etc.), but the programmer puts the initialization of the accumulator variable inside the loop so it gets reset every iteration, rather than putting it before the loop.

• A loop that's searching for something in a collection, and should report "not found" if it fails. The incorrect loop typically looks something like this pseudo-code:

for element in collection:
if element matches criteria:
report found or return value
break
else:


The result of this is that they get lots of "not found" reports along the way, but they never figure out by themselves that they can use a variable to keep track of whether the target is found so they can report failure at the end. Yesterday I responded to a question where the programmer "solved" that problem by putting break in the else branch as well, so his loop didn't actually loop, it just checked the first element.

I wrote a canonical question/answer for this problem: Searching array reports “not found” even though it's found.

• Recursion without using a return statement when making the recursive call, as in Recursive function does not return specified value. (Maybe this doesn't really belong in the list, recursion is often a hard concept for many programmers to pick up.)

I'm not a professional CS teacher (I just play one on the Internet), so I don't get any personal interaction with beginning programmers. I just wonder why these same mistakes happen so often. Is there something conceptually difficult about these algorithms?

I've occasionally tried asking the questioners what was going through their head when they were writing the code, since the errors seem so obvious to me. They can never explain their thinking, usually just saying something like "I just started programming a week ago, I don't know what I'm doing." If I press, they just get defensive and think I'm undermining their intelligence; maybe I do have an underlying feeling that someone who can't get these simple things right doesn't have the requisite logical thinking that it takes to be a decent programmer.

I'm hoping that real educators might be able to satisfy my curiosity. I suspect most of them are self-taught, so I'm not sure if curriculum is to blame. Do educators see these same errors among their students?

• I'll guess that as stated this is out of scope. It calls for opinions more than solutions. Yes, we see these problems, but that doesn't give you much information. How to deal with this situation is deeper and in scope, I think. The thinking patterns aren't obvious to novices, but good teaching is supposed to get people past the novice stage. Elementary coding patterns, for example is a (partial) solution. Learning to "desk check" without making unwarranted assumptions, etc. And if they really did just start a week ago these are completely natural mistakes. Jul 5 '18 at 17:27
• I'd take a different tact than @Buffy, and suggest that this is topical, but too broad. There were a lot of different examples that you gave, and each one would have different reasons for common mistakes. I might also tack on some sort of, "and how can I help these beginners to understand this better?"
– Ben I. Mod
Jul 5 '18 at 23:19
• @BenI. Are you suggesting that it would be more appropriate if I asked separate questions for each specific mistake? There seems to be a fundamental misunderstanding behind all of them, not thinking about the order that things happen. Jul 6 '18 at 2:50
• @Barmar Oh, I see where you were going with that. I guess I'm not convinced that those are the only possible reasons for the confusions you've mentioned, and you didn't explicitly mention execution order. All 3 examples would be excellent on a question about execution order, though I might make that more explicit in the question body.
– Ben I. Mod
Jul 6 '18 at 14:51
• @BenI. Well, it only really applies to 2 of the 3 examples, and I'm not so sure if it would apply if I looked for more. Another common one is a = b + 1; b = 1; do something with a;, but I think this reflects a basic misunderstanding that an assignment describes an equivalency (as in math) rather than an action. Jul 6 '18 at 15:47
• @Barmar I think it's topical as long as it is limited. Otherwise, it becomes, "why don't beginners understand anything?", which would be too broad.
– Ben I. Mod
Jul 7 '18 at 4:47
• The brain did not evolve to think sequentially or logically. Without a lot of training, it never really "gets it". I had students still messing up assignment, references, IF statements etc after a year of solid, daily programming education. Only a few people really think well in this mode, just like only a few people are any good at any particular thing. The real problem is that most of the things people could be good at do not pay as well as the narrow range of things that only a few people can be good at. Solve that, and everyone will be happy. I think we should just ditch the 'money' thing. Jul 7 '18 at 13:00

# How to increase student motivation

I have long been perplexed about how many people seem to lack a specific motivation or goal for their lives (at any given point anyway). Questions on this site often address the issue of and there is a lot of research on the topic generally and in the classroom situation. But I have not seen a lot of conclusions about how to increase motivation, aside from general engagement with the students, and I have not read anything conclusive about why students who are old enough could lack direction or goals.

Because I cannot fathom being without a direction in life (and mine has changed many times), perhaps I can effectively inquire in to how this could happen and what to do about it. Some ideas I have had about the lack of goals are:

• learning is too easy, questions answered immediately
• too many possibilities for what to study
• results too far off, as schooling lengthens and work recedes to the far future
• many tempting distractions, like social media and video games
• social pressure against study, academics and work
• discouragement about the future of work and self-determination

I am sure that many other reasons can be proposed. But what would cut through all of these excuses and impell students to decide on a goal for their education? People are motivated either intrinsically by a desire to learn the subject, or extrinsically by a goal that they study to achieve. Negative motivations seem not to have much effect because they are abstract and people don't give them much thought. Also, extrinsic motivations often ultimately fail, as the many 'successful' people who become miserable can attest.

Clearly, the study subject has to be interesting to the student, or they have to be able to visualize a future that learning the subject will help them achieve. There has to be something they want. Now the list above starts to mean something: people have long argued that students should be undistracted and largely work alone so that they can focus. An extreme example would be a monastery. Can we achieve focus while still allowing students to live in the 21st century? Only if they have a goal that is sufficiently compelling to overcome the obstacles they face.

If we rule out extrinsic motivations, the question reduces to: how can we get students interested in a subject that is taught at their school? We could teach more subjects, and more "up to date ones", but schools are already tight on budgets which prevent hiring teachers, even to teach popular and legally mandated courses such as CS. (This is why 1984 WAS like 1984: there were not enough seats, so the entrance requirements went up and up.)

Can nearly any subject be made interesting? Yes! I would like to propose a third method:

Be an interesting person, and be genuinely interested in the students, as it says in "How to Win Friends and Influence People".

When I was in school, I found myself working quite hard on courses that I thought I would never care about, because I cared about the teacher, because she cared about me. Is this something that we can standardize for computer science education, and not end up with disaffected groups?

• There seems to be more than a question here, so you probably want to whittle it down as a question on the main site. It also might be a duplication of other questions with the student motivation tag. Take a look at what is already there before posting. Part of what you write above is an answer, actually. Jun 14 '18 at 17:15
• Posting a self-answered question is acceptable, and even encouraged. As part of the refinement you can extract the "answer" part from the question and reserve that for posting as the self-answer. That allows others to focus on what the question is to make their own answers, which might enhance or counter your own. Jun 14 '18 at 17:32
• Subject-wise, this is certainly an issue instructors very often have to deal with. Sometimes the "answer" is analogous to the horse-and-water proverb. Nevertheless, any improvements that can be made to increase the "direction" of students is a good tool to have. Jun 14 '18 at 17:35

# Web development introductory lesson

I'm going to be teaching a group of total beginners about web development, with ruby on rails as the back end. Because of limitations with the computers I have access to, at least for the first couple sessions, I'm going to have to teach HTML/CSS/JS because these are windows computers, and I need to speak to the administrators of these computers about getting ruby and a proper code editor.

I have an hour for this first lesson, and my plan is to start with a "Hello World" in HTML and maybe styling it a bit, and thus introducing them to how HTML and CSS interact.

The students will be using notepad because we don't have code editors installed on these computers. These students are US high school age.

Here is my plan:

• 5 mins: Let people come in, choose a seat, turn on a computer, get logged in, etc.
• 10 mins: Explaining that HTML is HyperText Markup Language, and introduce them to what "Markup" means, and explain that "tags" indicate the structure of the document.
• 10 mins: Ask them to open notepad and write out <h1>Hello World</h1>, save it as "home.html" and open it in their browser. (I assume this will take 10 minutes because inevitably someone will have issues saving/finding/opening the file).
• 5 mins: Give them some examples of HTML tags and their purpose (and write them on the board), specifically unordered list, paragraph, and headers.
• 10 mins: Ask them to make a list of what their hobbies are with a title and subtitle. They can get help from the people sitting near them.
• 15 mins: Explain what an attributes are, and how CSS works and give some examples.
• 5 mins: End the class telling them that next week we'll learn more about HTML and start working with CSS, and letting them know they're welcome to do some work at home if they like (I can't assign homework, this class is voluntary).

Some concerns I have are:

• My timing. Do my estimates sound OK?
• Should I be starting with HTML? I can't start with ruby, but would it be better to start with JavaScript? If I started with JavaScript, I could work from the browser's built in console instead of messing around with notepad.
• Is it useless to take the second half of the lesson to introduce topics that we won't talk about or practice until the next week?

# Motivating Problems for Iterators

In teaching AP Computer Science A, there are only a few interfaces that we encounter along the way: Comparable, List, and Iterator, and the last one can actually be dodged, since all that the kids need to be able to do is to understand a foreach loop from a procedural standpoint.

I'd love to have kids implement the Iterator interface, perhaps for an odd data type of some sort, but I am having trouble thinking of clean motivating examples that aren't already in the Java standard library. Has anyone else approached this problem before?

• A Bag is a DS like a Set except that the same object can be a member several times. The cardinality of a bag is the number of elements, with replications counted as distinct items. So, not the number of distinct elements. An iterator over a bag should execute cardinality times before becoming exhausted. Dec 14 '18 at 21:48
• And, of course, note that an Iterator needs to fail if its underlying collection is changed. Dec 14 '18 at 23:09

**What are the important ideas and skills of Object-Oriented-Programing that will help me understand and do it better?

Suppose I need to teach OOP to myself or others. What should I focus on so that students will come to a good understanding of it and develop the appropriate skills.

In particular:

How should we (students and myself) conceptualize a running OO program?

What is the place of polymorphism?

What is the place of composition?

How much complexity should there be in any given class?

How much complexity should there be in any given method of a class?

How can we develop skill?