What does a certification program for CS high school teachers need to include? If a high school math or science teacher was going to begin teaching computer science, what do they need to know? I know of many teachers given this responsibility without any training for it. Since most states in the U.S. do not have a computer science certification, new teachers are often left on their own to prepare. A number of one week summer courses exist, such as those provided by the college board, but this is grossly inadequate for a new computer science teacher.

If we were to design an ideal course of studies to take a teacher with little to no programming experience and prepare them to teach a course like AP Computer Science, what should that program include? This question is not just theoretical since programs are currently being designed where none exist.

Here I am looking for two types of answers:

If you are familiar with an excellent program, what does it include?
If you are teaching computer science, what courses do you wish you took before teaching CS and why?

The College of St. Scholastica in Minnesota has a Computer Science Education graduate certificate program. It is a four-course sequence designed to add a CS endorsement to a high school teaching certificate, though no state-issued endorsement exists yet in Minnesota. The courses:

Computational Thinking and Standards for the K-12 Teacher
CS Principles, covering the AP CS Principles course description with additional material covering pedagogy and CS pedagogical content knowledge
Programming and Teaching Java, a Java-based course covering the AP CS A course description with additional material covering pedagogy and CS pedagogical content knowledge
CS Methods and Capstone, covering pedagogy and CS pedagogical content knowledge, CS education research, and development of a CS curriculum unit


Why do computer-science majors learn calculus? I am curious why computer-science majors have to learn calculus to receive their bachelor’s degrees. My father worked as a software engineer for twenty years and never used it. It seems to have little more value in programming than other forms of mathematics. What is it about calculus that makes it a requirement for computer-science majors? Is it just that it's a tradition in STEM fields?

There are several answers:

Answer 1: Not all CS programs

First, not all CS programs require calculus in order to get a bachelor's degree. The Bachelor of Arts (BA) program at Mills College, where I teach, does not require calculus. Instead, we require two semesters of discrete mathematics, which we consider far more useful to computer scientists, because it (at least the way we teach it) includes:

inductive proofs
Boolean logic
proof by contradiction
sets
combinatorics
basic probability
recurrence relations
graph theory
matrices
regular expressions
finite state automata
formal languages

Answer 2: Scientific foundation

That said, getting a Bachelor of Science (BS) degree from Mills or just about any other school requires calculus as part of general scientific knowledge, along with introductory chemistry, biology, physics, etc., none of which we claim someone will necessarily be useful to a computer scientist. These courses are part of the college-wide BS core, not specified by any individual department. The idea is that anyone holding a BS degree should understand the fundamentals of major scientific fields even if they will never apply them in their careers. (Similarly, most colleges require students to take classes in history, even though they are unlikely to become time travelers.)

Answer 3: Historical reasons

Computer science as an academic discipline has not been around that long. Most CS programs started within either Mathematics or Electrical Engineering programs. Both of those fields legitimately require calculus. I went to MIT, where CS was added to the EE department. All CS majors were required to learn both digital and analog electronics, the latter of which requires calculus.

Personal thoughts

In my decades as a computer scientist, including in industry, I never used any of what I learned in the required calculus (I, II, and III), linear algebra, or differential equations. That said, they did give me the background to go into computer graphics, electrical engineering, or machine learning, had I later chosen to.

Whether programs should require calculus is another question.


Colors in Blocks-based Languages I am designing a blocks-based language to use in my classrooms and summer camps. Since I am using the Blockly framework, I am able to choose my own colors for the blocks and am looking for information to guide my selection.

Personally, I find the number of colors in Scratch and Snap! and others to be overwhelming, and I hypothesize that young learners don't rely much on a block's color as much as its shape. But this is pure speculation—I welcome any reports from the front line or pointers to studies about block color.

Particularly, I'm interested in the method of grouping and organising the blocks into the color groups, rather than selecting the colors themselves: how should I select groups in order to help students understand each block's purpose? Are there any proven approaches of grouping certain types of blocks (e.g. flow control) together, or is the choice relatively arbitrary? Does the color choice have more of an impact than the shape and way of connecting blocks together?

Students use the colors for more than just interpreting the purpose of the block.  In my introductory classes, the color assists early-learners with locating the blocks within an extensive collection of choices.

When give a chunk of pre-existing code to recreate, a block's color helps communicate where in the collection to look for it.


Any relevant research in Motivation? I came across another reference to how CS education does not produce bimodal grade distributions etc. Also re-read some stuff about gender issues, that women are not mentored and supported and so on. I have no desire to raise those issues again.

However, I do feel that there is some sort of difference in motivation. Not to do with gender, race, income, etc, but just as a human trait. We have the OCEAN traits in Psychology (Openness, Conscientiousness, Extroversion, Affability / Amiability, and Neuroticism. These seem to be universal. Is motivation something that varies among people? Can differences in motivation affect how hard they study, persevere, self-teach, find alternatives, and other factors that lead to success in studying and in the workplace?

Does Motivation vary? (Not the actual question, just the premise.)

Is Motivation what we need to focus on regardless of any other factors? (The actual question.) Three factors of motivation are Autonomy, Mastery and Purpose. I see those all as being self-defined, relevant only to oneself.

I know that since I was a child, anything I chose for myself as my goal, whether learning about electronics, or resisting my schoolwork, I pursued with the greatest force and energy that I could rouse. Everything else was simply not important. So, when I went to college, I already knew I wanted to learn programming, nothing else mattered. I didn't have mentoring, I barely even went to office hours. I just did it on my own, which is what I did in all my pursuits of personal interest, like radio, or learning photography or whatever. So, I am at a loss to understand why college students do not know what they want to major in, or why they are not motivated to work on their core courses. Why don't they leave college and just do what they actually wish to instead?

My guess is that because I was Introverted (one of the OCEAN traits) I preferentially chose tasks for myself that were intrinsically rewarding when pursued alone, and which could not be blocked by having no access to other people. 'Others' and their preferences were the block, so I "routed around" it.

Please enlighten me. Maybe motivation is bimodal, and is the real issue underlying inequity, etc? if I understand other people better, I can do better.

Understanding people better can enable you to more effectively teach them.

Taken as axiomatic, this can be a helpful thought. It can also be a distraction. The value depends on how it's applied. When trying to understand "people", you can aim to understand people as a collective of unknown size, from unknown backgrounds, and unknown individualities; something you cannot ever "know" or understand. Conversely, you can aim to know the 35 students in your classroom, with backgrounds, experience, limitations, and gifts which you can know, and whom you can begin to understand. At least with respect to how that information affects their performance within your subject matter.

I have no links to research into motivation, and can only suggest that if any were found it would be inefficient to read it, or the conclusions drawn from it. The results would be extrapolations of an imperfect model using statistical analysis gathered by researchers with some pet theory to prove, or disprove. The 'repulsive' statement you found is merely one example of many which can be "concluded" from some observation. While, within the experience of the writer that statement might be true, it could be also be untrue in others' experience. What's left out of the statement are the conditions which define "fail", what consequences there are for failure, what is expected to be gained by success, and how much effort is required to achieve what "change".

If I will be passed over for a promotion unless I gain 6 inches on my biceps and increase my bench-press limit by 100 pounds, and the promotion has a net increase of 15% in pay, I'd personally be willing to "fail" rather than change. Given a different set of conditions, 3% pay increase for learning a new Java framework, I might not consider "failure" as an option.  (I don't know Java, so I'd have to learn that first.) In the second case, to me, the change is more desirable, even though the consequence of failure is one-fifth that of the first.

People, as an amorphous mass, can be classified, categorized, and "pigeon-holed" neatly by any study or research project. People, as one-on-one real individual humans, seldom fit into any neat "system," no matter how well researched, or refined it may be. If a system were ever developed that could classify people, manufacturing lines could be reduced to producing the one version that fit the needs, and wants, of everyone. We would have the 'one' computer system, with the 'one' OS that everyone could use to do everything they needed. The 'perfect' automobile could be made in the correct color, black according to the legend of Mr. Ford, and the Big-Four would be out of business. And, in your case, you could write to last, perfect, syllabus and lesson plan for each course you teach. (I'll not hold my breath for any of these things.)

Interestingly enough, I did have some college classes, and I somehow match part of what you described. I did not know what I wanted to major in. I never did manage to "focus" on the core courses. Nor have I managed to collect so much as an Associate's in anything, despite having nearly 150 semester credit hours collected. (I did manage to earn, by accident, a "certificate" for Linux Professional, which surprised me when it came in the mail after I failed to collect it from the office.) I've been connected to computing, and electronics, for decades, and will always be doing something within those areas. Yet I was not sure that should be my major. Perhaps it would be better to major in business, and use my computer skill within that arena? Of course, it didn't help much that I viewed computers as "fun" either. When ever I do "work" with computers it feels like being paid to play, and I almost feel guilty collecting the check.

The "motivation" you seek to understand exists in everyone. It remains individual as to what can activate, or trigger that motivation, or which subject(s) it might be applied to. The target of motivation may not even be a goal, it could be a journey. Some may be motivated to achieve some tangible reward, or to avoid some imagined consequence. Others could be motivated by the "rush" of doing something, or of experiencing the stillness of doing nothing.

That you don't see, or recognize, the motivation of another does not mean it does not exist. "Absence of evidence is not evidence of absence." (And there ends a 3 hour tour into the rabbit hole of The Demon-Haunted World: Science as a Candle in the Dark.)


Book to substitute "Compilers: Principles, Techniques and Tools" by Ullman et. al. (popularly known as the red dragon book) I am currently following the red dragon book:

But most of the time, I have difficulty understanding the kinds of stuff in the book. Though the content is fine, and I end up asking questions on cs.StackExchange or StackOverflow. Then I thought of reading the reviews of the text and find out whether it is only me who is facing is the problem or there are people like me as well, finding the language hard to understand. Then I came across the review page of this book in good reads and among many reviews, I found one which explains the problem with the text probably. Here it is:

Good content, horrendous writing.
The good thing about this book is it is comprehensive and covers a lot of ground from different vantage points. For example, the parsing chapters also cover the design of lex and yacc apart from basic topics. The type checking and runtime environment chapters had examples from C and ML to cover different scenarios.
Now the bad parts. The book is awfully written and I cannot understand how can a book in its 2nd (or 3rd?) edition continue to be so bad. It was shoddy writing throughout but the prize for the worst writing is these topics:

Discussion of bottom-up parsing where they directly jump to deterministic graph without discussing the nondeterministic version.
Implementation of L-attributed SDTs with an obtuse parser stack.
Implementation of type unification with their shoddy graph data structure.
Implementation of run time system for ML using "display" which is incomprehensible.

Another consistent problem is their horrible use of passive voice. This interacts really badly with their discussion of mathematical aspects. While the use of passive voice might be excusable, its shoddy use is not.
Reading this book often felt like deciphering some ancient text. I needed to translate a lot of obtuse writing into something that can be understood in my head. This translation happens for all readings involuntarily but it was alarming I had to consciously do it for this book.
I am not sure why is this book called a "classic" computer science book. It is more like a kind of book that students are forced to study by their professors. This book is impossible to read unless you are following some other source. I followed Prof. Alex Aiken's lectures
This book might be responsible for the unpopularity of the study and research in programming languages. I agree compilers are not easy but this book has taken a difficult topic and made it incomprehensible thereby doing a disservice to this whole field of study.

I am not criticizing the text or authors. The only thing is that probably the text does not suit a self-learner like myself. Could anyone suggest a compiler text to substitute the red dragon book possibly? A book with easy language, such that one easily understand what the authors tried to mean just by reading a sentence once. This would help a self-learner to focus more on the concept rather than getting lost in finding out the meaning behind the lines.
A book that is lucid and easy to read and equivalent in power to the red dragon book as far as the contents and the examples are concerned.

The "problem" with the dragon book is that it is so complete; intentionally so. Over its lifetime there have been tremendous advances in the theory and practice of building compilers. If you want "state of the art", then you want the dragon book, probably a later (harder) edition, even.
But it is a bit much, as you have seen, for a first course, or an overview of compiling. It is often used in graduate courses, for example, and, even then, in a follow up course to one in Language Principles which discusses much of the underlying theory separately.
While it is hard to find and a bit expensive, one of the best books for an introduction, and separately a bit of real literature in CS, get a copy of Brinch Hansen's On Pascal Compilers. It shows how to build a compiler as well as a machine to execute the code using Recursive Descent Parsing, which is easy to understand and suitable for LL languages (with a few extensions for non LL features).
Most commercial compilers use LR compiling techniques even if the language is LL, simply for efficiency reasons, but the theory is much harder as are the compilers. For state of the art understanding you need to delve into LR, but for a first introduction, LL is enough, and easy to understand.
LL compiling is also called Predictive Parsing, since it is easy to look at a language statement and choose a method for translating it, usually using keywords. The suitable languages for LL parsing are also easy for a human to read and understand. If a language (feature) absolutely demands LR parsing, then it will be difficult for a person to read.
For example, the Dangling Else Problem in if statements is a consequence of the construct not being LL, though  LL parsers usually have special hacks to handle this common construct.
Once you can handle Hansen's book, the dragon book won't be so daunting.


Do you know of a complete textbook for teaching databases? The textbooks that I know about, teaching databases, are not complete. In the sense that they lack a complete set of assignments, homework, projects, slides and instructor manual. Do you know of any new textbook that is complete in this sense?

I've taught a lot of people SQL in person (over 3000), and I've had to cobble together materials out of a bunch of resources to do it.

For Exercises:
http://sqlzoo.net
http://pgexercises.com
https://www.codewars.com/?language=sql

For slides, you can use mine, just fork them and remove the branding (they are CC-licensed, the branding is just there to look nice): https://slides.com/lizh/sql-intro

Make diagrams or have students make diagrams with: https://app.quickdatabasediagrams.com/#/

Usually the way I see SQL courses go:

Start by covering enough to get them through querying- have them start with one of the exercise sets above. You may want to break it down into a few class periods - basic querying and filters, followed by joins, and then more complex joins / functions.

Next, have them model data. If you model some data for them, then present a problem for them to do in groups, they usually get the idea pretty well and can self-grade. Then, have them choose something to model individually.

Students should first try to model some data that has 2-3 relations, then model data with a many-to-one relation, then more complex relationship models (relating through 3 or 4 tables).

Some really great things to model, either as a class or as individual projects:

Books (books are great because you can start with a simple model, then factor it out to third normal form, and then identify where it would vary by application greatly, eg amazon.com vs a library, they need different data models).
Keyboard shortcuts (because you can relate them to applications, and keys)
Transit (routes and schedules and busses, most students are familiar)
Food (you can go a million different ways with this, this is a very difficult data model to do properly)
Content (users, posts, comments, upvotes, block list. Do this one yourself as an example, it's in too many walkthroughs to be a good assignment.)

If this helps, I am the CTO over at enki.com, and we have an open-source CC-licensed curriculum here: https://github.com/enkidevs/curriculum
and a free app students can use to do daily practice with SQL here: https://enki.com/


Book recommendations for self studying Data Structures in depth in an elegant manner I am a student from CS background. I am currently going through "Introduction to Algorithms" By Cormen et. al.
$\quad\quad\quad\quad\quad\quad\quad\quad\quad\quad\quad\quad$
It is indeed a classic and a master-piece from the four authors. Each and every algorithm in it is written in the simplest manner possible. Each and every algorithms have analysis involved in a hardcore manner. Thought it is a fantastic book on algorithm design and analysis and many sources recommend it for data structures as well but I find that the data structures section is quite less in the above book.

I have gone through the data structure book below :
$\quad\quad\quad\quad\quad\quad\quad\quad\quad\quad\quad\quad$
Data structures using C and C++ by Tanenbaum et. al
Though the above book deals with the various topics of data structure I found that many of the implementations of the data structures and their manipulation algorithms have been made unnecessarily complex and it took quite a lot of time to understand certain pieces of codes which otherwise could have been written in a much more elegant manner. This makes it difficult to recall the algorithms in the text which is far beyond intuition at some places. Though the book contains algorithms of the data structure manipulations but at most places the hardcore analysis is missing.

So could any one recommend me a book on data structure which is as elegant as CLRS , simple and lucid, which would help me for myself study. Even if it does not revolve around any particular programming language - it is fine, but if it does it would it be good if the language is a modern one and not the older ones like PASCAL, FORTRAN,... (although even in CLRS 2nd edition they follow the PASCAL like pseudo-code structure, but it is fine as long as it does not go into the nicks and nacks of the features special to these vintage languages)

You might find Data Structures and Algorithm Analysis, by Clifford A. Shaffer, to be helpful. There are versions for C++ and Java available. (The 3rd edition is old already [2013], and the prior editions were titled A Practical Introduction to Data Structures and Algorithm Analysis.)
It does get very in-depth into the field, including the mathematics involved in analysis and proofs. That said, however, my first read through it (2nd Ed.) was very helpful in many ways, and I didn't then know anything about C++.
As a 2013 book, some of the coding might be in a style or format which is no longer considered "best practice." This is likely more true for the manner in which Object Oriented Programming is utilized than for the syntactical style. The material, discussion, and analysis are still as valid as ever.

The link above is to the author's page where the PDF versions are available, along with many resources to accompany the book. Of course, if you must have a dead-tree version, they are still available, new and used, from places such as Amazon.
The author has stopped updating the PDF and print versions of the book in favor of an online version. I have not experimented with the online version, although a quick peek at it leads me to believe that it is available for "in-class" use and for independent study. As such, it might be more useful to you than the PDF version.
As a caution, I've also seen a 4th Edition with the same title, but by a different author. It may, or may not, be an updated version of the same book, done with the original author's help and blessings. Having never read the 4th Edition I cannot say if it's connected at all.

To give a better idea of the content, and layout, of the book, I am listing an abridged version of the books Table of Contents.
Contents
I  Preliminaries

Data Structures and Algorithms

A Philosophy of Data Structures (The Need for Data Structures :: Costs and Benefits) | Abstract Data Types and Data Structures | Design Patterns (Flyweight :: Visitor :: Composite :: Strategy) | Problems, Algorithms, and Programs

Mathematical Preliminaries

Sets and Relations | Miscellaneous Notation | Logarithms | Summations and Recurrences | Recursion | Mathematical Proof Techniques (Direct Proof :: Proof by Contradiction :: Proof by Mathematical Induction) | Estimation

Algorithm Analysis

Introduction | Best, Worst, and Average Cases | A Faster Computer, or a Faster Algorithm? | Asymptotic Analysis (Upper Bounds :: Lower Bounds :: Θ Notation :: Simplifying Rules :: Classifying Functions) | Calculating the Running Time for a Program | Analyzing Problems | Common Misunderstandings | Multiple Parameters | Space Bounds
3.10 Speeding Up Your Programs
3.11 Empirical Analysis

II Fundamental Data Structures

Lists, Stacks, and Queues

Lists (Array-Based List Implementation :: Linked Lists :: Comparison of List Implementations :: Element Implementations :: Doubly Linked Lists) | Stacks (Array-Based Stacks :: Linked Stacks :: Comparison of Array-Based and Linked Stacks :: Implementing Recursion) | Queues (Array-Based Queues :: Linked Queues :: Comparison of Array-Based and Linked Queues) | Dictionaries

Binary Trees

Definitions and Properties (The Full Binary Tree Theorem :: A Binary Tree Node ADT) | Binary Tree Traversals | Binary Tree Node Implementations (Pointer-Based Node Implementations :: Space Requirements :: Array Implementation for Complete Binary Trees) | Binary Search Trees | Heaps and Priority Queues | Huffman Coding Trees (Building Huffman Coding Trees :: Assigning and Using Huffman Codes :: Search in Huffman Trees)

Non-Binary Trees

General Tree Definitions and Terminology (An ADT for General Tree Nodes :: General Tree Traversals) | The Parent Pointer Implementation | General Tree Implementations (List of Children :: The Left-Child/Right-Sibling Implementation :: Dynamic Node Implementations :: Dynamic “Left-Child/Right-Sibling” Implementation) | K-ary Trees | Sequential Tree Implementations

III Sorting and Searching

Internal Sorting

Sorting Terminology and Notation | Three Θ(n2) Sorting Algorithms (Insertion Sort :: Bubble Sort :: Selection Sort :: The Cost of Exchange Sorting) | Shellsort | Mergesort | Quicksort | Heapsort | Binsort and Radix Sort | An Empirical Comparison of Sorting Algorithms | Lower Bounds for Sorting

File Processing and External Sorting

Primary versus Secondary Storage | Disk Drives (Disk Drive Architecture :: Disk Access Costs) | Buffers and Buffer Pools | The Programmer’s View of Files | External Sorting (Simple Approaches to External Sorting :: Replacement Selection :: Multiway Merging)

Searching

Searching Unsorted and Sorted Arrays | Self-Organizing Lists | Bit Vectors for Representing Sets | Hashing (Hash Functions :: Open Hashing :: Closed Hashing :: Analysis of Closed Hashing :: Deletion)

Indexing

Linear Indexing | ISAM | Tree-based Indexing | 2-3 Trees | B-Trees (B+ -Trees :: B-Tree Analysis)

IV  Advanced Data Structures

Graphs

Terminology and Representations | Graph Implementations | Graph Traversals (Depth-First Search :: Breadth-First Search :: Topological Sort) | Shortest-Paths Problems (Single-Source Shortest Paths) | Minimum-Cost Spanning Trees (Prim’s Algorithm :: Kruskal’s Algorithm)

Lists and Arrays Revisited

Multilists | Matrix Representations | Memory Management (Dynamic Storage Allocation :: Failure Policies and Garbage Collection)

Advanced Tree Structures

Tries | Balanced Trees (The AVL Tree :: The Splay Tree) | Spatial Data Structures (The K-D Tree :: The PR quadtree :: Other Point Data Structures :: Other Spatial Data Structures)

V Theory of Algorithms

Analysis Techniques

Summation Techniques | Recurrence Relations (Estimating Upper and Lower Bounds :: Expanding Recurrences :: Divide and Conquer Recurrences :: Average-Case Analysis of Quicksort) | Amortized Analysis

Lower Bounds

Introduction to Lower Bounds Proofs | Lower Bounds on Searching Lists (Searching in Unsorted Lists :: Searching in Sorted Lists) | Finding the Maximum Value | Adversarial Lower Bounds Proofs | State Space Lower Bounds Proofs | Finding the ith Best Element | Optimal Sorting

Patterns of Algorithms

Dynamic Programming (The Knapsack Problem :: All-Pairs Shortest Paths) | Randomized Algorithms (Randomized algorithms for finding large values :: Skip Lists) | Numerical Algorithms (Exponentiation :: Largest Common Factor :: Matrix Multiplication :: Random Numbers :: The Fast Fourier Transform)

Limits to Computation

Reductions | Hard Problems (The Theory of N P-Completeness :: N P-Completeness Proofs :: Coping with N P-Complete Problems) | Impossible Problems (Uncountability :: The Halting Problem Is Unsolvable)


What's the benefit of prohibiting the use of techniques/language constructs that have not been taught? I teach as a private tutor and most of my students are prohibited to use techniques and/or language constructs that they haven't been taught!

There's a really broad variety of stuff that is prohibited like foreach-loops, switch-statements, functions/methods, etc.

What do you think is the benefit of this rule or why do most schools and universities have such a rule?

Rules like this are generally instituted because the teacher is attempting to teach a concept made moot by one of these constructs. For example, as a teacher, if you're teaching bitwise operators and ask students to implement absolute value, it simply makes no sense to permit the students to use whatever library function does absolute value. You're teaching bitwise operators, and the fact that they know of the library function doesn't help them learn bitwise operators.

I believe that because you're asking here, the reason for the prohibition isn't as obvious as in my example, but my guess (without knowing the specifics of the situation) is that the prohibited constructs are not what are being taught so, for that course, the students knowledge of a more advanced concept is irrelevant to the subject matter being taught.


Giving Students a Break My instruction time has specified breaks, but often the students do not take them, even if I urge them to. This results in them working and listening to my instruction while they are overdone. I tell them this is a marathon, not a sprint, and they will have the rest of their lives to sit in a chair in front of a keyboard, but they do not take the break, or they get a sip of water in the hallway and sit back down. This is impeding their learning and making them unhealthy ("Sitting is the new smoking", right?).

Have you found any effective ways to get students out of the chair to take their full breaks, other than having them take up smoking (thus defeating the purpose) or yelling Fire?

I don't understand all the hate this question is getting. I'm guessing the answers depend on the context a lot.

Context of my answer

I regularly hold company trainings. Adult education. These are full day IT trainings, that means 9 AM to 5 PM. In the contract we offer 90 minute blocks with 15 minute breaks between and a 45 minute lunch break.

Importance of breaks

A break is not a waste of time. Researchers disagree on the amount of time an average human can uphold focused attention for, but all agree it is measured in minutes. I have learnt 4-5 minutes at the university, and I have read some researchers claiming it to be up to 20 minutes. But you can't expect an average human to uphold focused attention for hours at an end. It is possible to renew attention, this is where the teacher comes in by changing the rhythm, the tone, the visualization, the exercise. But from time to time, breaks are needed. (The 8 second attention span you hear about is different, it is the burst attention span or whatever it is called.)

It is not just the attention though, but moving/stretching as well. Most workplaces have recommendations, and though there are slight variations, most revolve around the "work for 60 minutes, get up and move for 15". This is not only beneficiary to the health of the individual, but also (many studies point this out) improves work performance.

Answer to the original question

My actual answer is: explain to them why breaks are important, explain to them how getting up, stretching, moving can help them concentrate, but don't try to force them to do so. If sitting is the new smoking, then dealing with it is similar: you can't just forcefully take the cigarette out of their hands. They know their own bodies and what type of break refills them. And they will learn the importance of breaks the hard way.


The importance of writing understandable code 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 often it is because they were simply told "That's how you do it", or by points being taken off assignments due to these things. Such conventions exist to make it easier for others to read and makes it possible for them to understand what it does, without too much effort.

If the students understood why the conventions exist and the reasons for writing easy-to-read code, they would write code which is easier to review. So my question is how can I teach the students the need for those conventions, so that they understand why it's important to write code that is easy to review.

I'd rather they didn't lose points in tests for not following conventions, because then they do learn the conventions but they don't understand the reason for those conventions.

There are a ton of blog posts and several books on the topic of readable code, containing far more eloquent and complete arguments than one can make here (or that I could come up with myself). Depending on their level it's well worth sharing some extracts of well-written texts directly to show the importance of understandable code.

The most fundamental reasoning behind readable code is that people need to read code, not just computers. Or like @ben-i says here:

  First, right from the beginning, and repeatedly, I talk about the
  two audiences for code: the computer and people. These two
  audiences have completely different needs. I come back to this theme
  with every new structure that I talk about, discussing coding style
  and norms with if statements, variable declarations (naming
  conventions), for loops (hey, why do we avoid break statements?), etc.

Novice programmers typically give their total focus to getting code to do what they want: make it compile and then give the right output. That's really hard when you're starting out, and it's understandable that they give 'working' priority over any other qualities like 'readability'. As they mature, programmers learn that making some code work isn't the only goal. Once you can write code that works you realise there are other things to achieve too, which is where all other sorts of software engineering practices come in.

Readability is super important because most code will be read many many times more than it will be written. I think this is the most important message to get across, and it drives all the different aspects like formatting & naming. I suggest teaching and discussing this core concept and keep coming back to it whenever talking about a new aspect.

It's one thing to get students to understand the importance, but another thing to make them bother to do it when 'getting it working' is so much more an immediate problem. To some extent that's fine, but even novice programmers should be taught the value of writing readable code because it makes their own coding easier.

I guess there's a few approaches that can be used in tandem:

Discuss why it's important. Perhaps a sports analogy: when you're starting out with [insert sport here] you just care about hitting the ball (etc). But the top sportspeople in the world spend all their time honing their technique to get better results. Writing readable code is one of the things that professional programmers spend time improving and perfecting all their careers. It makes you better. It makes you faster. It lets you achieve far greater things. It helps you work as a team.
Break down different aspects of readability and give exercises on them, the simplest being to have students write and also review code where the approach hasn't been followed at all, e.g. with indenting, bad variable naming, bad comments, etc. Get them to desk-check the execution or result of some poorly written code versus well-written code.
Have them read & discuss articles about readability & maintainability. Depending on what level the students are at they should given reading about this and discuss it in class, even just to appreciate that it's an important ongoing topic in the CS community.
Mark them down for various aspects of poor readability. Even if they just follow the rules for the benefit of marks that's better than not doing it; gets them into the practice and at some point they'll appreciate it.
Have them review other students code regularly, either in a group or individual setting.
Teach the benefit of readable code as you're writing it. Once you're writing more than a trivial piece of code you always have to re-read it and think about what's going on. It's difficult even for the original author to read poorly-written code; by following guidelines to write readable code they will actually find it easier to write code.


How do people prefer to learn web development - videos or text? I want to create a web development blog where I will teach a variety of subjects that people usually don't talk about.
How people prefer to get content? Using videos or text?
What are the pros and cons of each media?

As a student, I get a lot more from blogs.  Many of the videos I have seen are pretty hit or miss.  With a blog, I can scan it in a minute or so and be able to tell if it holds the answers/info I am looking for or curious about.  With a video, there seems to be a much longer time commitment due to more forwarding, searching and hunting for an overview of the video's quality.

I think it may depend also on what you are trying to do?  Are you trying to relate an entire concept? Or is your approach more targeted towards demonstrating specifics, edge cases, etc?  I think for broader overviews, videos are more helpful from what I have seen with my peers and myself.  Blogs seem to do better with content that has a narrower focus, especially if specific, concrete examples are included.

There may also be the notion of data usage and accessibility to consider.  It is much easier to download a webpage then read it later or offline.  Not much data has to be transferred for that to happen.  Video of course takes much more data to transmit and more room to store.  Those may not be major concerns for everyone but some places I'm sure the difference between the two is enormous.

Whatever you choose, thanks for doing it and helping the rest of us learn, it is appreciated!


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 language that is not widely used. A linter does not exist yet, and I'm wondering whether it would be worth the effort to make one.

Also, does it matter whether the style hints are provided as you type rather than upon saving or compiling the program?

I would love to see quantified studies about this, but personal experience is very welcome too.

Some things I am thinking about for a functional language (examples use Haskell) are listed below, but these are not vital for answering this question. Experience with other paradigms is appreciated as well!

When parentheses are(n't) needed. A common faux pas is to surround every application of a constructor with parentheses ((Just 5)), even when they are not needed, because it is necessary in pattern matches.
Writing int instead of Int, making a type variable instead of a concrete type.
Using where clauses for helper functions.
Suggesting pattern matches where guards where used (i.e., not checking | x == 5 but using a pattern match where x is replaced by 5.
Recursion that may not terminate. For instance, students tend to get confused writing functions that get no parameters, and end up writing things like instance minBound ... where minBound = minBound. (Not really a style hint)

In my experience, immediate feedback is helpful in speeding along development, but rarely enhances understanding.  In fact, I am often frustrated with the immense level of help that is provided to my strugglers, because they wind up moving words around until whatever they've written stops being underlined.

The only exception to this has been for norms that don't cause errors, such as using CAPS for static final variables in Java.  In those instances, it is very helpful to have some sort of indicator that what they've done isn't perfect.

Edit: Now that I've seen your edit with examples, it seems like what you are contemplating is basically all of the stuff that I feel is helpful.  In which case, I believe that it could be very helpful!


Mental Model of Type Conformance/Subtype Polymorphism I'm finding that my CS2 students really struggle with the notions of type conformance and subtype polymorphism in Java. Say we have the following:

public abstract class Vehicle {
    // attributes + constructor
    public void ride() { ... }
    public String toString() { ... }
}

public class Bicycle extends Vehicle {
    // attributes + constructor
    // notice this is an override from Vehicle
    public void ride() { ... }
    public String honkHorn() { ... }
}

They then consider the following problems, with my commentary on common mistake(s) following each problem:

Bicycle b = new Bicycle();
Vehicle v = b;

Students look at this and think b cannot be stored in v, either due to the type difference, or maybe because Bicycle has a constructor with a different number of parameters than the Vehicle constructor, so of course b can't 'fit' inside v.

Bicycle b = new Bicycle();
Vehicle v = b;
v.ride();

Students commonly think that the ride method in Vehicle will be called. I understand why this mistake is made, but those who get this correct still struggle then with this next problem:

Bicycle b = new Bicycle();
Vehicle v = b;
v.honkHorn();

Students now think this is also syntactically valid. Because subtype polymorphism ensures that the method call will use the object's implementation, rather than the variable's, they think that Java will somehow recognize that v is storing an object of type Bicycle, and thus honkHorn is available to be called. It never occurs to them that Vehicle doesn't even have this method, so of course it won't work.

Anyway, they have had two quizzes and now an exam involving these concepts (despite seeing them in class contextualized in other learning material all semester, and theoretically a little at the end of last semester), and a significant number of students are still struggling with this. Any suggestions on how to convey all these concepts? My approach is usually to convey very clear models of how things look in memory, but that doesn't seem sufficient here. Do I just need lots of examples/practice problems? Other suggestions?

The problem is that you don't really have subtype polymorphism here. While the language permits it, it is poor practice to change the interface (set of public methods) as you move down the hierarchy. I'm not speaking of the formal interface but only of the messages that an object is allowed to handle. Your class Vehicle doesn't have honkHorn, but a subclass does.

The problem with this is that if I have an object, I need to know its specific type to know what methods it supports. Some Vehicles support honkHorn, but others don't so I need to test.

This is, at best, ad-hoc polymorphism.

If you want true subtype polymorphism define a class as an interface or abstract class as you have done here, but all subclasses should exhibit exactly the same interface.

Then, if you define a variable to have the interface (abstract class) type, then it can refer to any object of any subclass and it can field any message defined at the top level. You never need to ask instanceof and you never need to cast.

It is, of course, harder to build a system keeping such a pure rule, but it can be done and it saves you a ton of grief later.

One of the reasons we want to build OO software is to let the system figure things out without explicit testing. If you change "interfaces" within hierarchies you are just back to ad-hoc decision making. You are defeating the notion of IS-A that the OO paradigm was built for.

In your example you can't really say that a Bicycle IS-A Vehicle. You can say that it is a Vehicle, but something more, and we have to determine what by ad-hoc means in many instances. Sometimes by declaring variables to have a specific type (rather than a general type) and sometimes by testing.

In terms of "contracts", if you change the contract as you come down the hierarchy, it wasn't really a contract.

Sadly, too many books don't understand this and define meaningless, and difficult to work with, "hierarchies".

One way to avoid this issue, is to define Vehicle as an interface and then define Bicycle as another interface that extends Vehicle. Now your intent is clear. Classes implementing an interface have only the public methods defined in their interface and nothing more. Now you have interfaces of concepts which is what they are really intended to model, and classes of objects that conform to specific concepts. This may be the mental model you seek, actually.

I discussed Polymorphism at some length here: https://cseducators.stackexchange.com/a/4050/1293

Let me add some things here to point to a better way. One of the lessons is that subclassing is generally overused. Some books present it as the "really big thing". Instead, programming by composition is much more valuable. When you create a class give it parts that are instances of some other, simpler, class.

For the immediate problem here. Give Vehicle a method makeSound. Give each subclass of it an instance field that refers to some kind of object that might make a typical sound. For a bicycle object it might be a Horn object. Then when any vehicle is sent the makeSound message it delegates the making of the sound to the object that is part of its composition. Delegation is the big idea here. Now you don't need to change the protocol in different classes. Just change the implementation, but giving different "parts" to different vehicles.

At least one very commonly used book has something like the following hierarchy. First a Point class. A point has some coordinates. Then, for the first (ugh) example of subclassing is a Circle class. This is "easy" to write, since if you subclass Point all you need to add is a radius value. But to a mathematician, is every circle a specialization of point?  It is backwards, of course. Taking it farther, a Cylinder can subclass Circle just by adding a height value. This makes it very easy to type in, but very foolish, both mathematically and from a program design standpoint. If you create a Cylinder, what sort of variable should you use to refer to it. If you don't use a Cylinder variable, then within the next few lines you are very likely to have to cast the variable, or, if you have put such things into a List then you are going to have to type case them (or equivalent) when you look at them again. Don't do that. But what can you do better. Use delegation.

When you build your Circle class, don't make it an extension of Point. Instead, give it an instance variable of type Point. A Circle is a different kind of thing. It isn't a point, but it HAS-A point as a field.

Likewise the Cylinder HAS-A Circle for its base. Much cleaner. The cylinder delegates some of its actions to its base when it receives a message. Likewise the base (a Circle) delegates some messages to its location (a Point).

Now you have a defensible design, but it might not have used subclassing at all. You get reuse (via delegation) and don't confuse the nature of things and require ad-hoc decision making throughout a long program.


Integrating Graph Theory into AP CS A During our year-end exit interviews with our outgoing seniors, the students made an explicit request to include some graph theory within our curriculum.  This seems like an excellent idea, but the only place where we can fit it is in AP CS A1.

Obviously, graph theory is not within the AP curriculum per se, but I wonder if there is some way to shoe-horn at least a bit of it into a lab somewhere.  Even so, I am having trouble finding a spot within the AP curriculum.  Obviously, AP CS A focuses a great deal on arrays, loops, and objects.  There's not a heavy emphasis on recursion (though it is present).  Is there somewhere where graph theory can find some kind of "fit" within an AP class?

1 I'm unable to find a clean, succinct list of topics covered in AP for those unfamiliar, but this teacher's site has a list of unit headings that could serve as a very quick overview.

You may very well have some examples where you can discuss state machines and hence state diagrams, that is, graphs.

For example, if you're creating a game with a computer controlled character, that character might be in different states: pursue, search, attack <-- you can introduce a graph representing the states and transitions.

I wrote about this a bit here: https://cestlaz.github.io/posts/2012-12-17-layers-of-a-lesson.html

If you have a class that goes beyond the APCS-A curriculum and do more recursion, you can look at a maze solver (as I do), knights tour, etc - this lets you discuss searching the state space graph - DFS (and allude to alternatives including heuristic search and such), paths, etc. You can also talk about circuits and cycles (knights tour variants)


The order of subjects in beginner's curriculum This year I'll be an unofficial teacher assistant in the CS class of 9th graders.
Background
This question is about a curriculum for introducing students to programming in java.
The students are in 9th grade (14-15 years old) and are not expected to have any background whatsoever in computer science (usually some do have, but that's not relevant to the curriculum. Differentiating it is something relatively easy at this stage).
This curriculum spans 2 terms (1 year - Sept. to June), and is meant to build a firm foundation for students. The subject is compulsory in 9th grade. I have some doubts regarding the ordering of the subjects in the curriculum.
How it stands
Students are initially introduced to computers in general.
The first lesson is always brainstorming: "What is computer science?". It's established from there that programming ("computer science is writing code" is usually a response of a few students) is writing something, and then converting it into binary (it's expected that they know that the binary numbering system exists). The students use the remaining time ($\pm$10 minutes) to write the famous:
public static void main(String[] args){ //we don't explain this line
    System.out.println("Hello, World!"); //sometimes we use a Hebrew alternative:
    System.out.println("!שלום, עולם");//which is literally the translation
}

That's the first lesson. From here, I'll list the subjects (each one is a subject, and not a separate lesson; lessons are ignored, I only address the subjects of the curriculum) taught (the language used to teach is Java)
   0. (First Lesson) introduction and simple printing of text

Simple Eclipse console Input\Output and user input (print what the user inputs etc.) as well as variables (just primitives, and just int,double,char and String).

Mathematical operators: +,-,*,/ as well as %. The curriculum has an option to teach increment  as well as +=, -= and the rest.

Conditionals: if, if\else and nested ifs. Also boolean is introduced.

switch-case. Not much to say about this at this level.

Math library. This is one of the things that caused me to doubt the order of things in the curriculum.

for loops and various uses. Arrays are not taught in the curriculum at all

while loops.

Nested loops.

functions. yes, functions:
static returnType functionName ( parameters)
{
    //operations
    return returnValue;
}

That's it.
Doubts
I spotted a few issues in the curriculum. First and foremost: Where are all the arrays? I want to include arrays, but I'm not sure where\instead of what.
Teaching for after arrays seems better than before, because then I can show the foreach in the same lesson. They are essentially the same (but not 100% equivalent. Concurrent modifications is something beginners aren't ready for). So I am uncertain about the order of the subjects.
Secondly: Functions. Again, why? I want to remove them from the curriculum (students learn about them in the following years anyway, as part of OOP), but this might do more damage than good. Students might want to know, after an entire year, what exactly is the meaning of the public static void main from lesson 1.
Functions can explain that, but other than that, it's pointless at this stage (because they'll learn it anyway, should they major in CS).
So, does the order of subjects in the curriculum, as it stands, make sense (keeping in mind that arrays are not covered at all)?
Note: this question is not a duplicate of this one, simply because I already have a curriculum, and I am asking for a review of it. I'm also asking about specific aspects of my curriculum, and not general "hand wave-ish" things.

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 try to minimize hand waving as much as possible in the early parts of a CS course to help students build their confidence in navigating code.

While Eclipse is commonly used in industry and higher academia, an introductory course isn't industry or higher academia. So we use an IDE that is more appropriate for the new learner. We utilize BlueJ to begin demystifying Java from the very first day of class. Thanks to BlueJ, we don't have to discuss main or making tester/runner classes to run our code. In our post-AP CS course we can introduce IntelliJ or Eclipse, once the students can comfortably grasp the idea of multiple classes and project directories.

Our decision to introduce objects early was inspired by Dr. Kolling's book's sequencing and the fact that Java is the language taught in AP CS. Others may chime in by saying they think objects should be introduced late. I disagree for the reasons previously mentioned. Should we leave AP and teach Python or Javascript, I would wait until later in the course to introduce OOP. That being said, here is our general outline:

Introduction to OOP

What is a class and what is an object?

Writing Java Classes

What makes up a Java class?
Fields
Constructors
Methods

Conditionals
Logical Operators
Java Math and the Math Class

At this point it's September and my students can navigate an entire Java class and the hand waving of public static void main(String[] args) is gone. That's hugely important and beneficial.

Classes as Data Types for Other Classes

Encapsulation

Strings
1D Arrays

Looping

2D Arrays
The ArrayList Class
Inheritance, Abstract Classes, and Interfaces
Algorithms

Recursion
Searching
Sorting

Keep the students in mind. Remember where they are coming from and that your goal isn't to turn them into CS researchers or software engineers in a single year. Expose them to the content in an order that appropriately challenges them, while avoiding the statement "You can ignore that for now" as much as possible.


Effective ways of teaching regex to students who know Java My students are knowledgeable about Java but need to know something about Regular Expressions. Many students find them difficult and intimidating. The students don't need to know every detail, but do need to know enough to work effectively and learn more.

What are effective ways of teaching the fundamentals of regular expressions in Java or otherwise? I'd like the students to understand how it works, and not only what each pattern does.

This year it's been decided at my school (I'm a teacher assistant this year) to teach the students a bit about regular expressions. We teach in Java.
The students have never faced anything like regex in the past. The students I've asked (we have a test group - we test new ideas on them for feedback. A diverse group in terms of level and background1 consisting of 3-4 students) seem to find regex very difficult (we just gave them the pattern list and explain each pattern).

1background in terms of knowledge in the field.

Many students find them difficult and intimidating.

Then the challenge is to make them fun and engaging and (ideally) interactive. I myself have undertaken the challenge here and there of teaching myself regex, and two resources rose to the top in my own learning: RegexOne and Regex Crossword.

RegexOne is great as a lesson-by-lesson tutorial. Students can type and see in real time what tests cases their regex does/does not match. There are 15.5 lessons and 8 practice problems. The practice problems draw from relevant use cases, such as extracting a phone number, trimming white space, or reading a log file.

Regex Crossword mixes regex with logic: students have to fill in a square grid and track how gradually more complex regular expressions interact with each other. (That sounds a bit vague, but an example like this one makes it clear what I mean.) The crosswords tend to have fun themes/solutions. There are many crosswords to solve, including ones with great complexity, so students will have to spend lots of time working at it if they'd like to complete all the puzzles.

When it comes to working in class, it'd be pretty easy to work with some of the smaller crosswords in a non-digital manner. You could put one on the board at the start of every class as a warm-up or print/copy some of your favorite from the site. Maybe even have students work in groups and complete to solve a series of puzzles in the fastest possible time.

Between these two resources, students will at least have a pretty good start to working with regex.


Active learning for boolean algebra I've been thinking about active learning, and I am inspired by Heather's answer to my earlier boolean algebra curriculum review.  This may also be a good question for math teachers who have experience teaching algebra.  How do you avoid lecturing, and get the kids doing a lot of activity, even when there is so much material to cover?

So, here is my actual question:
What are techniques to get at boolean algebra using active learning?

Build logic gates out of dominoes.

Start off by showing this video from Numberphile in whole or in part. In it is a demonstration of how to use dominoes to model logical operations of a computer. It begins with a simulation of an AND gate and writes out its corresponding truth table. This is followed by the same process with XOR, which then allows for the construction of a half adder and in conclusion a full adder. (You may also share this video with students, which contains an elaborate, 10000-domino construction. Per the YouTube description, "The result was a Domino Computer capable of automatically adding numbers. It can take any two four-digit binary numbers and return the five-digit binary sum.")

Then challenge students to build elementary logic gates themselves (you might need a lot of dominoes, but I bet it would be worth it in the long run). You could start by having them come up with designs for AND, OR, NAND, NOT, XOR, etc. on their own. Depending on how this goes, consider using this resource to help guide the design of gates in dominoes.

After students create these gates, consider giving them longer Boolean expressions to model and solve using dominoes. This would also be a clever way of showing how DeMorgan's Law works.

The level of complexity knows almost no bounds with this approach. I could see some students, especially those with a love for computer science, who would thrive doing a hands-on, constructive activity like this.


Hand-on ideas on tutorial on setting up a cloud-based server A long shot, but perhaps somebody here can help.
I'm planning a workshop (=3 hours, mixed presentation bits + "hands-on" parts, ~30 people). It includes a (brief) section on setting up a simple server on DigitalOcean. Some of the participants will be directly interested in this and would probably benefit from leaving the workshop with an account and server set up. Some will not.

I'm wondering if there's any/a best way to deal with this.

I want to show, concretely, how one would set this up. But I don't want to spend 15 minutes clicking through an interface with everybody staring. Ideally this would be a hands-on part.
I don't want to force those participants to set up an account if they don't need it (they'd need their credit cards)
I don't want to have half the people setting it up, the other half wasting their time.

My only idea so far is to make this dependent on the number of people actually interested in setting up an account, and allocating a final part of the workshop for this. Those not interested can leave earlier. But it doesn't sound optimal either.

Does anybody have any better ideas? This related question did something similar but is basically too much presentation.

Let me give an idea, though it will shoot down your proposal, I guess.

Face to face time with students is precious. Use it only for those things that are best done that way. Three or four hundred years ago lecture was very efficient since even books were unavailable and very expensive. A hundred years ago books became reasonable for a student to purchase so lecture changed a bit and the book and its exercises took on a larger role.

Today, as you suggest, we can do live demonstrations of things and have interactive sessions. But the time with students is still precious. If you want to demonstrate something or have students do something in a lab where they follow your direction, you should make sure that the topic is something that is really important and advances your main teaching goals. Setting up servers isn't likely to be in that category unless the course itself is about server management.

The problem with work-along demos is that the students, if there are more than about ten will get out of sync. Some of them will be confused. Some of them will, when typing or otherwise interacting with the machine, miss an essential instruction from you and get lost. They will get blocked if they see something unexpected, and if it is new to them, the unexpected is expected. They will come up with questions and wait, fairly passively, until their questions are answered.

If you are doing something truly essential, then all of these difficulties are worth it in the long run. But for the inessential and even for some essential things use handouts or web pages. Use official documentation that you point to, perhaps supplemented. Give them a way to ask their questions in a way that doesn't intrude on face time. I found a mailing list dedicated to each course as a way to do this. Especially when other students are encouraged to answer student questions.

Use the "big impact" methodologies for the "big impact" ideas. Face time is the biggest of all. It is often even a waste to use it for lecture - a broadcast mechanism, rather than a personal one that might be used instead.


What is the CS Analog To Learning One's Multiplication Tables? I apologize; I know this question is sort of open-ended and if I could think of a way to make it more specific, I would.

What would you consider a piece of CS so fundamental that it would be analogous to an elementary student learning his/her multiplication tables?

I think maybe looping code, maybe data types, and/or conditional statements.  I'm looking for pointers to any scientific literature on this topic and any input anyone cares to share.

What are the absolute fundamentals that every developer must master regardless of paradigm (OOP, FP etc) or language?

Feel free to close this if it's too broad but if you do vote to close please suggest how I can narrow the question as well.

"Analogous" could mean different things, depending on which analogy you choose to make. To me, the key thing about learning multiplication tables is that you are memorising the answers to some simple questions which will appear as subproblems to many other things you have to do; so that you don't have to derive the answers again each time those subproblems occur. @Buffy's answer describes some of the fundamental abstract concepts which programmers certainly need a solid understanding of, but I would not count things like "sequence" and "alternation" as problems for which we apply solutions from memory; so I infer that @Buffy sees a different analogy to the one I do.

For the analogy as I see it, there are some commonly-occurring subproblems in imperative programming which we do use memorised solutions to. I would think of @Buffy's fundamental ideas as analogous to the ability to do multiplication, and the understanding of when/why to multiply; they should be learned before it makes sense to memorise the answers to multiplication questions. Likewise, understanding what sequential, conditional and iterative statements are and when/why to use them in a program should precede memorising how to apply them to solve particular problems.

To give some idea of the kind of subproblems and memorised-solutions I mean, the below list is not at all complete, but should help to illustrate by example:

Q: How to iterate over just some elements of a collection? A: Write a loop over the collection, and an if statement inside the loop to "filter" for just the elements you want to iterate over. The code for processing each element should go inside the if statement.
Q: How to find the sum of a collection of numbers? A: Initialise a variable sum = 0, and use a loop to do sum += x for each x from the collection.
Q: How to count the number of occurrences of something in a collection? A: Initialise a variable count = 0, and write count += 1 each time that thing is detected to have occurred.
Q: How to find the "best" (maximum, minimum, etc.) thing in a collection? A: Initialise a variable best to be the first thing from the collection, and write a loop over the remaining elements. Each time a new element x is observed, check if x is "better" than the current best, and if it is, update best = x.

These memorised solutions to commonly-occurring subproblems are closely related to the ideas of "roles of variables" as described by Sajaniemi and "plans" as described by Soloway & Ehrlich; I use the word "plans" to describe them. I'm not aware of any comprehensive list of them; I was able to think of some, which I've written about in Python and used for teaching undergraduate students (with limited success - perhaps we didn't spend long enough for the students to memorise the plans by repeated practice). I have written a similar document for Java which I don't have to hand immediately, but I can post it later if there is interest.


Teaching C++ to students that know Java I am now teaching an OOP course to 2nd year undergrads. This is actually a course in advanced programming in Java. In the next semester, I am going to teach the same students, a C++ course. From what I know, C++ and Java are quite similar - there are differences, but they can be covered in 2-3 hours, which are one week of teaching. This leaves me 12 more weeks, and I wonder what else to teach.

I looked at the syllabus from previous year and it looks quite similar to my current Java course: OOP, overloading, generics, unit-testing, software design, etc. I don't want to teach the same course twice in different languages...

One idea that I had is to focus, not on teaching the language itself but on teaching specific practical applications in which C++ has a clear competitive advantage. For example, if game-programming is usually done in C++, then I can focus on game-programming. So my first question is: what kind of applications are written in C++ substantially more than in Java?

And my second question: what other new topics can I include in this C++ course?

[NOTE: in case this is relevant, the same students currently take a course in C].

Actually, the similarities between C++ and Java are fairly shallow and the differences are very deep. The syntax of both is derived from C, but the underlying ideas are very different.

The biggest difference is that an "object" in C++ is built on the stack, like a struct, not on the heap. It takes additional work and a lot of understanding to become comfortable with the differences. If you do create objects on the heap (with new) you need to understand the differences between pointers and references and these can be the source of hard to debug errors. And you need to be absolutely pure with deallocation. Every object needs a known lifetime to the programmer, whereas Java handles all of that automatically.

C++ has no garbage collector for heap objects, so the memory management problem needs to be solved for every application, unlike Java where it is solved once by the run-time system automatically. Smart pointers in C++ can help a bit with this but are not a complete solution. Memory leakage for non-trivial applications is a serious issue.

The visibility of things is also fundamentally different, with "friend" classes complicating the mental models of complex systems.

Don't underestimate the difficulties. You will likely have a lot of work to do to get the students comfortable with quite different mental models and with practices and idioms that keep them safe.

James Gosling once described Java as C++ without the guns, knives and clubs. You will be trying to program with all of those pitfalls, when the students, coming from Java, have little experience with them.

Their experience with C, if deep enough, will help with the memory management issue, but not with the complex (i.e. dual) object model of C++. You should become familiar with good memory management tools and practices if you want to do non-trivial things in C++.

I was once stopped dead in a C++ project by a deallocation error for 24 hours. The solution required a 1 character change in a file. One character of progress per day is very bad, though I was an experienced programmer and actually knew why it was failing.

Your own experience with C++ seems shallow from the statement of your question. I'd suggest that you work hard on that before you attempt to teach such a course. Especially, build something that requires sophisticated memory management and test everything as you go. You can't think of C++ as just mis-spelled Java, nor Java as just mis-spelled C++. The conceptual differences are many and deep.

My own experience as a programmer (and author)` is that Java helps me program correctly, but C++ fights me constantly for every inch of ground. I could build some beautiful things, but the fight was constant and brutal.


How do I convince students to use Boolean algebra? I have taught Boolean algebra in an upper-level discrete math course for CS majors. I showed them how, using just the axioms (distributive property, etc.), you can derive other properties (such as De Morgan's Law). Then I assigned them to try it, and most of them happily (or grumpily) worked through the algebra. But one student proved the statement exhaustively using a truth table, instead of using algebra. That is not what I had wanted him to do, but I was at a loss on how to justify it to him. Since Boolean variables can only have 2 different values, proving a Boolean algebra equality can always be done exhaustively. Or am I wrong?

Well, for one, computing a truth table doesn't scale: generating one takes exponential time, with respect to the number of variables you're using.

You can perhaps "subtly" drive this idea home by asking your students to manipulate some proposition that contains 7 or 8 variables (which would require creating a truth table with 128 or 256 rows). That would require an exhausting amount of work -- the benefits of using algebra should hopefully be more obvious, then.

To make the problem more tractable for the people who are using algebra, you could perhaps engineer the original statement so some of the variables end up "vanishing" (e.g. they simplify into something like p || !p).

I think it would also be worth explaining why it's useful to be able to systematically simplify or manipulate boolean expressions in the first place -- for example, you could explain that when you're designing circuits, you have a vested interest in minimizing the number of gates used to keep costs down (as well as potentially minimizing the number of unique gates used).

And finally, another idea is to just simply tell your students why you're asking them to learn this material in the first place. For example, you could say that you're trying to prepare them to write proofs later on in the course (assuming that's what you're doing). After all, a large part of writing proofs is about correctly manipulating and applying definitions, and that's exactly what you're asking the students to do now.

Generally, I think sharing your gameplan is a good way of getting students on-board (albeit sometimes reluctantly).


Assisting students with large programming assignments takes too long in class In university, I was a student in an operating systems programming course in C. Assignment help was offered in tutorials. Students would usually present the tutor(s) with run-time errors and an enormous amount of code. The tutors took 20 minutes to figure out the mess and offer help. In a 50 minute class of 30, most students went neglected, while some scored private tuition. Assignments were large and students were forbidden to view each other's code.

This was a serious problem. What could teaching staff do to address this?

The problem, in my view, is a misplaced assumption that students should never see one another's code and that seeing it would somehow or other "pollute" the student's mind in some way or make grading invalid.

A clear solution, provided that you can give up that assumption, is to have the students work in pairs in the tutorial, giving help and advice to one another. A more radical approach, that I also favor, is to have students work together to develop the code in the first place.

It has been observed (I have seen the video) that when students work together they seldom need outside help and call for tutor help only rarely. When students work alone and wait for the tutor they are mostly idle while waiting.

The reason for this is that, while both students in a pair may have problems, they seldom have the same problems and so can support one another's learning. When a tutor's help is needed, there has already been a deeper analysis of the issue at hand, since there were two minds working on it.

If you worry less about grading, and less about some students "slacking" you can do a better job overall, especially for those who are interested in learning. Students can learn from one another. It isn't essential that they learn  only from the instructor.

My experience, also, is that when a "better" student helps another, both benefit from the experience. The helper gains deeper insight by having to verbalize an understanding that may be only partly formed.

When abrasive personalities get in the way of pairing, the one that is abrasive needs to learn better behavior in any case if he/she is to be successful in the long run. Instructors need to watch for this, of course, and offer advice as needed.


Difficulty of algorithms homework problems I have a question for educators, from the perspective of a TA. I'm happy to post my question elsewhere if it's not appropriate for this site.

Homework problems in algorithms classes often involve finding clever tricks that the professors find elegant or interesting. However, it seems like most of the students who solve these problems well are students who are familiar with the tricks already, from prior experience. Students who don't know the tricks end up going to office hours, where the TA has to guide them through most of the solution, and the students are left confused about how they could possibly have derived the solution independently.

This seems like a discouraging pattern, especially because, in the end, research usually involves deep logic and understanding, but students come away feeling like algorithms is simply full of these impossible, clever leaps. Is there a way to help students catch up on these tricks and tools without giving away the answers?

Homework problems in algorithms classes often involve finding clever tricks that the professors find elegant or interesting

That seems like a strange way of teaching algorithms. It shouldn't involve trying to make the students recreate brilliant ideas from scratch (most people won't re-invent Dijkstra's algorithm when asked to find the shortest path through a graph), but rather teaching them which building blocks exist, showing them how (simple) problems can be solved using these building blocks, and then offering them related problems whose solutions are similar.

  However, it seems like most of the students who solve these problems well are students who are familiar with the tricks already, from prior experience.

In my mind, the thing your professors do get right is the idea that algorithm design isn't a algorithm itself. I believe it is to a large degree a question of experience. You build a repertoire of "tricks" that work, and then you apply them in new circumstances. What kind of "tricks"? An important aspect is about knowing what kinds of data structures fit the problem.

  Is there a way to help students catch up on these tricks and tools without giving away the answers?

As I've said, I believe programming/algorithm design is a craft, not a science. Having mentioned Dijkstra, I don't believe in his approach to algorithm design. He was very methodical and mathematical and seems to have looked at algorithms as basically a mathematical problem to solve. While this is certainly true and often offers valuable insights when dealing with difficult problems, I don't think most people work like that. If programming is a craft, then it is best learned by imitation and lots of practice.

Unfortunately, we don't have nearly enough time to let students practice, but one thing you can do is tell them how important it is to look at how other people solved problems, and provide them with good resources they can use to learn by imitation. Here's a nice one: Beautiful code.

So, to actually answer your question:

Make sure the students have a good working knowledge of the basics (e.g. how to iterate over a list, how to manipulate list entries etc)
Present a sequence of problems that lead up to the final problem. For the preliminary problems, explain what kinds of data structures are used and why, and how the algorithm operates on them.
Encourage the students to look at other people's code. Good candidates are algorithms which solve a certain problem in a way that is applicable to a lot of other domains. (For example, I first learned about atomic commits by reading a description of how subversion worked. This came in handy when I thought about how to implement database transactions. It was also closely mirrored in the way git builds hash trees, which again is closely mirrored by the bitcoin blockchain).
Finally, explain to them that you can just show them the way, but just like learning to play a musical instrument, or a sport, they'll have to invest their own time if they want to become any good.


How can I help students develop intuition about a programming language? As an tutor for introductory CS classes, I often come across students that have a very rigid understanding of a programming language up to what they have been taught so far. This most often manifests itself when they ask the question "I can do that? I thought that...". I've most often seen this when showing students that branching and looping statements can be nested. It has even occurred when dealing with parenthesis and order of operations in mathematical expressions. As a concrete example, in Python many containers allow access via brackets:

# dictionaries
foo = dict()
foo["a"] = 10
foo["a"]
# deques
bar = deque('asdf')
bar[0]
# and many more...

These students usually repeatedly struggle with this every time a new construct is introduced, as they fail to see how certain concepts from one part of the language extend to the other parts. In this case, it is that brackets are used for accessing elements.

In short, how can I influence the student's thinking process from "This language only allows me to do this" into "Can this language do this?", and help them expand upon what they have already seen and understood?

I think this is a structure of knowledge problem. I suspect the disconnect is that you have organized your knowledge in a way your students haven't.

You understand that strings, lists, dicts, and deques are all something called containers. You also understand that all containers can be accessed with []. Therefore, it's straightforward to consider that [] could be applied to any new container you come across.

But do your students understand this organization of types in terms of containers? I bet they don't yet. They are still thinking about each type as an individual entity, disconnected from others.

Experts' knowledge is organized much more effectively than novices'—— that's what it means to be an expert. (Cite: Relevant section from How People Learn, summary from Cal State Northridge)

On the other hand, novices' understanding is tightly tied to shallow features like syntax. It will take a while for them to see the deeper organizational features.

You can help your students become more like experts by explicitly helping them organize their knowledge. If it's not overwhelming for the students, teach them what a container is and what all containers have in common. More generally, connect concepts together to help support students' development of those expert-level connections.

Good luck!


Pedagogical issues with Stack Implementation I am new to teaching the particular syllabus I have been asked to teach and I am confused by the approach given for several of the algorithms. For example the stack implementation based on the course materials given below seems very convoluted. I'm curious to hear if others would share my concerns if they had to teach about stacks in this way, or if they can offer any insight into the advantages of this approach.

The concerns I have which I'm curious to hear your opinion about are:

Using the call by reference approach makes the push and pop calls
very unwieldy
The algorithm appears to be O(n) rather than O(1)
The algorithm is hard to follow (IMO)
It is possible to implement a stack in a much simpler fashion, which
would allow student to focus more on conceptual understanding of the
behavior and use of stacks, and to see the link between the concept
and the implementation more clearly.

# NullPointer should be set to -1 if using array element with index 0
NULLPOINTER = -1

#Declare record type to store data and pointer
class Node:
        def __init__(self):
                self.Data = ""
                self.Pointer = NULLPOINTER

def InitialiseStack():
        Stack = [Node() for i in range(8)]
        TopOfStack = NULLPOINTER  # set start pointer
        FreeListPtr = 0  # set starting position of free ist
        for Index in range(7):
                Stack[Index].Pointer = Index + 1
        Stack[7].Pointer = NULLPOINTER  # last node of free list
        return (Stack, TopOfStack, FreeListPtr)

def Push(Stack, TopOfStack, FreeListPtr, NewItem):
        if FreeListPtr != NULLPOINTER:
        # there is space in the array
        # take node from free list and store data item
                NewNodePtr = FreeListPtr
                Stack[NewNodePtr].Data = NewItem
                FreeListPtr = Stack[FreeListPtr].Pointer
                # insert new node at top of stack
                Stack[NewNodePtr].Pointer = TopOfStack
                TopOfStack = NewNodePtr
        else:
                print("no space for more data")
        return (Stack, TopOfStack, FreeListPtr)

def Pop(Stack, TopOfStack, FreeListPtr):
        if TopOfStack == NULLPOINTER:
                print("no data on stack")
                Value = ""
        else:
                Value = Stack[TopOfStack].Data
                ThisNodePtr = TopOfStack
                TopOfStack = Stack[TopOfStack].Pointer
                Stack[ThisNodePtr].Pointer = FreeListPtr
                FreeListPtr = ThisNodePtr
                return (Stack, TopOfStack, FreeListPtr, Value)

def OutputAllNodes(Stack, TopOfStack) :
        CurrentNodePtr = TopOfStack # start at beginning of list
        if TopOfStack == NULLPOINTER :
                print("No data on stack")
        while CurrentNodePtr != NULLPOINTER : # while not end of list
                print(CurrentNodePtr, " ",Stack[CurrentNodePtr].Data)
        # follow the pointer to the next node
                CurrentNodePtr = Stack[CurrentNodePtr].Pointer

Stack, TopOfStack, FreeListPtr = InitialiseStack()
Stack, TopOfStack, FreeListPtr = Push(Stack, TopOfStack,
FreeListPtr, "first item")
Stack, TopOfStack, FreeListPtr = Push(Stack, TopOfStack,
FreeListPtr, "second item")
Stack, TopOfStack, FreeListPtr = Push(Stack, TopOfStack,
FreeListPtr, "third item")
Stack, TopOfStack, FreeListPtr, value = Pop(Stack, TopOfStack, FreeListPtr)
print(value)
OutputAllNodes(Stack, TopOfStack)
```

Actually, the code is terrible, but I don't think its purpose is to illustrate a stack so much as to illustrate in a very rudimentary way how heap allocation works. (Worse than "terrible", it isn't "pythonic").

But you are wrong about the efficiency. Only the initialize function is O(n). Push an pop are O(1) as should be obvious.

But no serious code should print as a solution to a failure condition. The program itself should fail in some predictable way. Likewise no general implementation of a stack should hard code the maximum size. As such, this code teaches very bad programming habits.

The reason I don't think it is intended to represent a stack structure is the tuples that are returned from push and pop. Normally push is a mutator returning nothing and pop is an accessor returning only the top value in the stack.

Also, a stack as an abstraction should encapsulate the free list pointer (i.e. next free slot if any) and this reveals it.

The capitalization of variables is also oddly done for a Python program.

I agree that it is hard to follow, but that is a consequence of the above.

One thing positive that I will say about the code and how it might be actually valuable pedagogically, has to do with a philosophical interpretation.

When you modify a stack (or anything, really), one way to think of it is that you have a different stack - a new thing that didn't exist before. This code emphasizes that view of mutation. So to push onto a stack, you supply a stack, etc, and you get back a stack. A stack goes in and a stack comes out, a conceptually new thing.

So, it works if that is your main lesson, but less so as a stack per se.

But it is valuable only if you want to emphasize that view of mutation. But this is at odds with the normal (philosophical) view of an encapsulated data structure - that its identity is maintained in the face of change.

However, it is valuable for students to consider both views as different programming languages stress one over the other. Haskell, for example, has the "new value" idea built in rather than the "modified value" that you normally see in OOP. In Haskell if you push onto a stack, you get back a stack.

I'll also note that there is a Pedagogical Pattern called Toy Box that suggests that one can introduce a complex topic with a trivial implementation that get across key ideas without going into the complexity. While I might prefer simpler code to show how a heap grabs blocks but must know where they are, this code might be considered an example of a Toy.

Another pedagogical pattern is called Spiral and implies that teaching can introduce simple versions of complex topics early before students are ready for the full explanation. Then later, when it is time to learn it in detail (another loop in the spiral) they have been primed to integrate it into their thinking.


Framework vs Vanilla JS for students I'm serving as a tech lead for a student group's charity project. We're building a website which puts a bunch of homelessness resources in one place. There are two goals to the project: create a useful website, and let students learn as they build it.

The group is comprised of all levels of college CS student. Most have never done web dev or worked with any of the associated technologies. People get uneasy when I mention using a JS framework.

I want to make sure they get out of it what they came in for -- which by all reports is learning -- but I'd prefer that they enjoy it and don't quit (which would be totally fair, cause they are volunteering their time).

The group has been asking why we should use a framework. I say

testing
reusability
dealing with state

They feel that learning multiple things at once could be bad, and that this would be overkill. Honestly, I'm not sure if it would be overkill. It could be. But learning vanilla JS is certainly less valuable than learning React.

Am I being dense? More importantly, would the project better reach it's goals by using a framework, or not?

I believe that after getting to know html and css, starting with Vanilla JS or with a framework are both the same thing to a new student that knows nothing, he'll be learning new things from the beginning so if you think learning a framework is more valuable than starting with Vanilla JS then go ahead start with a framework.

When it comes for professional working, most of the jobs require working with frameworks.

Now some people will ask "but how do you want to teach them a framework without giving them the basics of JavaScript?". That's a wrong question. Again, to a new student they both aren't related. Vanilla JS is not considered the basics of a framework, the basics is JS yes but why not learn JS through the framework. PS that's how i learned about the new ES features, started with react native directly.


Computer Science vs IT vs Digital Literacy In 2012 shutdown or restart published by the royal society, recommended that UK schools have 3 parts to computing. No longer the single amorphous blob that was ICT. (Some things from ICT, would no longer be taught.) These 3 parts should be Computer Science, IT, and Digital Literacy (that paper says that its meaning for IT, is not the same as others have used it).

I have no problem understanding what Computer Science is and what it includes, however I continue to struggle with understanding what IT and Digital literacy are.

“Digital literacy is not a ‘subject’ in itself – neither are reading and writing – but is an essential skill for all in the modern age.” … “‘Office’ applications such as word processing,” — So learning learning to use office applications at a high level, is it IT or Digital Literacy or both?

I also think a lot of other teachers struggle with this. I have heard teachers saying “We don't do that any more. No we don't do ICT any more.” or “Isn't it a shame that we don't do that any more, now that there is no ICT.”. In a lot of instances I think that what they are talking about would be IT or Digital literacy, under the new scheme.

There are other cases, where I see teachers planning to teach computer art, and wonder is this not art? (A lot of this could be leftover from the ICT days.)

So the question is what is the difference between Computer Science, IT, and Digital Literacy? with examples.

E.g. Where do these fit in?

Learning:

Computer art.
Computer animation.
Typing training.
Unix operating system[Linux foundation certification].(https://training.linuxfoundation.org/certification).
Systems admin.
Computer Maintenance.
Network admin.
Basic training: opening files and programs, saving, loading, file system structure, …
Use of a work processor.
Computational thinking.

Note I have intentionally included some examples that may not fit in ether, and some that an arguably do.

When we were drafting the English national curriculum, we found it easier to think in terms of the foundations, applications and implications of computing, all three of which really should be included in any broad and balanced approach to the subject. You can map these to computer science, IT and digital literacy if you wish, although you would need to accept a rather broader definition of digital literacy than that used by the Royal Society

Foundations would be about the underpinning principles of computer science (logic, algorithms, data representation, abstraction), as well as their practical expression through programming and more generally in computational thinking.

Applications is about skills in using digital technology to get useful work done, including collecting, managing, analysing and communicating data and information and creative work in a range of digital media.

Implications is about a critical understanding of the impact of digital technology on individuals and society as well safe, responsible and ethical use. I'd include intellectual property, privacy and security here too.

I've an illustration of all three in response to the question 'How does Google work?'

Foundations: big data, Page Rank, Big Table / the Google File System (GFS) etc

Applications: type your query, click the button (well, these days it starts searching as you type), but also filtering results, advanced queries etc

Implications: profile, filter bubbles, advertising, smart creatives, separating costs and revenues for accounting purposes etc