27 votes

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

Then I inevitably have students who abandon the good habits they had formed and want to make everything an Object, or declare everything as var. These are very different situations. As you ...
Peter Taylor's user avatar
  • 1,673
8 votes

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

Introducing these sorts of shortcuts can cause exactly the problem that you've outlined. "Oh, goody!" says the misguided student, "Now I can stop worrying about the type!" There are a few principles ...
Ben I.'s user avatar
  • 32.7k
8 votes

Explaining to students why to use double instead of float (unless there's a very good reason)

Luckily this is quite simple to make clear, even if you are steering clear of the IEEE standard. Honestly, even binary is not needed here. I would start by borrowing a page from Scheme, and say that ...
Ben I.'s user avatar
  • 32.7k
7 votes

Teaching "CS integer" vs. "math integer"

This might be an interesting way to do it, but here goes. Give your students a blank sheet of paper. Have them write out "3". Then have them write out $2^{10^{1000}}$. Most will probably stare at you ...
Auden Young's user avatar
  • 4,674
6 votes
Accepted

Explaining to students why to use double instead of float (unless there's a very good reason)

Better yet, is there any way I can show the students such an explanation? (Perhaps an online, interactive demonstration of floating point precision etc. - I couldn't find one) Show them these bits of ...
Kevin Workman's user avatar
6 votes

Concept of variable

Why complicate matters with contrived analogies like hotel rooms and guests? It is much more straightforward to take the analogy of a simple paper "form" (which absolutely everyone in ...
Steve's user avatar
  • 356
6 votes

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

If I learned anything reading Dale Carnagie, if you want to convince someone to do something, don't tell them "Do this because I want you to," tell them "Do this because if you don't, you're going to ...
Slothario's user avatar
  • 161
5 votes
Accepted

Concept of variable

The use of an analogy is to provide a familiar jumping-off point to introduce something new. Since variables are unique features of computing systems, different from how anything else in the universe ...
Scott Rowe's user avatar
5 votes

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

There are a number of issues to be addressed from clarity of the written code to efficiency of the compiled code. For beginners, I think the clarity issue is more important so I'll address that first. ...
Buffy's user avatar
  • 35.8k
5 votes

Explaining to students why to use double instead of float (unless there's a very good reason)

Tell the students they have seven decimal digits of precision in a float, and that the decimal point is placed "somewhere" within those seven digits, depending on the magnitude of the number. Ask ...
Bob Brown's user avatar
  • 409
5 votes

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

If you expect that many of the students will pursue software development careers, it would not be unreasonable to declare style standards for the course, and include it in their grading. When doing ...
bartonjs's user avatar
  • 151
4 votes

Breaking down the operations when auto-casting gets complex

I'd maybe suggest an exercise of splitting these kinds of statements up into multiple variables and lines of code. So take this line: ...
Kevin Workman's user avatar
4 votes

Breaking down the operations when auto-casting gets complex

I suspect that you handle such situations by informally building the parse tree of the expression in your mind. Maybe not all at once, but a bit at a time, perhaps. I'm not a cognition expert, of ...
Buffy's user avatar
  • 35.8k
4 votes

Concept of variable

Using labels as a metaphor over boxes has merit and has been examined. This post looks at it from an early learner standpoint: https://www.felienne.com/archives/6063 There is a good post on this here ...
TooManyCooks's user avatar
4 votes

Concept of variable

You can also use @Steve paper form idea for a second use, namely the importance of naming. I have often given students a paper form with boxes of different lengths, labeled A, B, C, etc. I then ...
Fritz Sieker's user avatar
  • 1,123
3 votes

Abstract data type that has "include" "remove" and "is in" and only those

Carrano, Data Abstraction & Problem Solving with C++: Walls and Mirrors begins by introducing a simple ADT kind of like you're talking about, called a "Bag". But it is not used as a base class for ...
Daniel R. Collins's user avatar
3 votes
Accepted

Example for Introduction to Generics in Java

While uniform collections are the obvious example, you can also build or use a Pair class in which the types of the two components are given by generic arguments. If you don't want to build it, there ...
Buffy's user avatar
  • 35.8k
3 votes

Teaching "CS integer" vs. "math integer"

If your students are mathematically inclined, you could simply think of the variable type as a constraint on the value contained inside of it. For example: int ...
Aurora0001's user avatar
  • 3,506
3 votes

Breaking down the operations when auto-casting gets complex

I think the student's problem is not with types, but first with the parsing of complex expressions (not to be confused with the tracing of it's evaluation). Mentally building the abstract syntax tree ...
Michel Billaud's user avatar
2 votes

Explaining to students why to use double instead of float (unless there's a very good reason)

Actually, it isn't quite so clear. If I run this in Java: ...
Buffy's user avatar
  • 35.8k
2 votes
Accepted

Data and Database modelling books

I highly recommend Database: Principles, Programming, and Performance, by O'Neill and O'Neill. Learned from that book for my first database course and loved it.
David White's user avatar
2 votes

Concept of variable

I don't think you can say any analogy is "right" or "wrong" across the board. Whether an analogy makes sense or not depends on the context of both the teacher and the student, and ...
Kevin Workman's user avatar
2 votes

Concept of variable

I have to teach basic computer skills, applications and using online platforms in advance of programming this year. Since I will do some Spreadsheet work, I plan to initially use a cell to demonstrate ...
srattigan's user avatar
  • 744
2 votes

Concept of variable

I think it is a mistake to do this since it ties the "concept" of a variable, which is a language dependent item to an implementation on a certain kind of hardware. Yes, variables are often ...
Buffy's user avatar
  • 35.8k
1 vote

Data and Database modelling books

I worked as a data modeler at Siebel. One of the books that the Siebel data model is based upon is Data Model Patterns by David C. Hay. The book will not teach you how to build great data models. It ...
bkm's user avatar
  • 161
1 vote

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

Then I inevitably have students who abandon the good habits they had formed and want to make everything an Object This can easily be shown to be a bad approach if you need a class specific property ...
Flater's user avatar
  • 1,311
1 vote

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

There are a few reasons why this is bad, for example it could lead to code issues down the line where you need something from Horse that you don't have on ...
anonymous's user avatar
  • 111
1 vote

Explaining to students why to use double instead of float (unless there's a very good reason)

Simple demonstration of "precision" using handheld calculators. Get a pair of calculators. One cheap model that has a limited number of digits in its display. Models can be found built in to ...
Gypsy Spellweaver's user avatar
1 vote

Explaining to students why to use double instead of float (unless there's a very good reason)

Many compilers will promote floats to doubles, do the calculation, and cast back. I see little or no reason to use floats unless one is dealing with huge matrices of floating-point numbers. I ...
ncmathsadist's user avatar
  • 2,319
1 vote

Breaking down the operations when auto-casting gets complex

You say “when he is finished, he no longer fully understands them.” There is a good practice to write self documenting code. This is done not with comments, but with well named entities (methods, ...
ctrl-alt-delor's user avatar

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