lectures about "programming methodology"

A

Arne Vajhøj

Keep in mind that this course is probably for people who have never
heard of a programming language before. Excessive pedantry may serve to
confuse rather than elucidate, as I have found when TA'ing
introductory-level computer science courses.

Successful teaching of beginner programmers has very little to do
with correct and complete definitions of things.

Being able to make the stuff interesting and to simplify things
to where the audience can understand it is critical.

Arne
 
A

Arne Vajhøj

Well, I hope you are not annoyed yet. But I just spotted the
first major software-methodology error! He explained the
scope of a variable as the lifetime of the variable. It was
even displayed as text: »Scope: lifetime of variable«. This
really hurts!

For those of you, who have not yet learned the distinction
(untested code ahead), after:

class Object
{ /* begin of scope of i */
final int i; public Object( final int i ){ this.i = i; }
/* end of scope of i */ }

and then in »main«:

{ { final Object o = new Object( 4 );
java.lang.System.out.println( o ); }

{ final Object o = new Object( 7 );
java.lang.System.out.println( o ); }}

, after execution, there were two instances of »i« (with
values 4 and 7) that had the same scope (as identifiers),
but different lifetimes (as variables), and two instances of
»o« which indeed have different scopes (as identifiers).

A scope is a region of the source text. Identifiers
have a scope.

A lifetime is a period of time during the execution
of a program. Variables and objects have lifetimes.

This has no special relation with Java, this is
software engineering (or »programming methodology«).

I really don't see that as software engineering.

It is a CS exercise in definitions with little practical
benefits.

Arne
 
E

Eric Sosman

On 5/5/2013 2:37 PM, Stefan Ram wrote:
I decided to watch lecture videos from the Stanford
University[...]

Second, I believe that Harvard is more known for Law, Medicine,
Business, Economics than for IT. [...]

Hey, Arne: What school did you attend, and what's its
reputation for geography?

Oh shit.

That was about 3000 miles off.

:-(

Hey, well, I'm sure glad *I* never make silly misteaks! ;-)

FWIW,

- Andrew Yao received his first PhD from Harvard.

- Leslie Valiant taught at Harvard.

- Christos Papadimitriou taught at Harvard.

- Michael O. Rabin teaches at Harvard.

- Kenneth E. Iverson received a Masters degree from Harvard
and taught there for half a decade.

- Stephen Cook received Masters and PhD degrees from Harvard.

- Dennis M. Ritchie received undergraduate and PhD degrees
from Harvard.

- Ivan Sutherland taught at Harvard.

- Butler Lampson did his undergraduate work at Harvard.

- Fred Brooks received the PhD from Harvard.

- Edmund M. Clarke taught at Harvard.

- E. Allen Emerson earned his PhD from Harvard.

If these names seem unfamiliar, look up "Turing Award" and
"Knuth Prize."
 
S

Stanimir Stamenkov

Mon, 06 May 2013 21:16:16 -0400, /Arne Vajhøj/:
None of these items seems particular relevant for teachings
students programming.

Not at a high school in the middle of nowhere. And not at Harvard.

Why was Harvard brought in? Stefan originally mentioned Standford:
 
S

Stanimir Stamenkov

Tue, 07 May 2013 08:50:18 +0300, /Stanimir Stamenkov/:
Mon, 06 May 2013 21:16:16 -0400, /Arne Vajhøj/:


Why was Harvard brought in? Stefan originally mentioned Standford:

Just saw in another reply it was a mistake.
 
S

Sven Köhler

I really don't see that as software engineering.

I assume, Stefan is worried that these ideas could stick - regardless of
whether you consider that software engineering or not.

Let "lifetime of a variable" be an attempt, to describe scope "in
layman's terms". However, it gives the students the wrong idea -
especially because there is an actual lifetime of a variable and it is
not identical with the scope. Later on in the lecture, when students
will have to understand object orientation, this wrong idea might make
it difficult for the students to understand important things.

BTW: It is also possible to defend his description of the scope, namely
if you limit it to local variables only (Stefan's counter example was a
field). However, I don't know the lecture. It might be the case, that
fields haven't even been introduced.


Regards,
Sven
 
S

Stefan Ram

Sven Köhler said:
BTW: It is also possible to defend his description of the scope, namely
if you limit it to local variables only (Stefan's counter example was a

For local variables the two concepts differ too. One example
can already be seen in my code, when one reads the local
parameter »i« as a local variable. The most famous example
is the factorial (untested):

int f( final int i ){ return i == 0 ? 1 : i * f( i - 1 ); }

. To understand this, it is vital to understand that »i« has
only a single scope, but can have many (in this case:
nested) lifetimes.

A method is like an object where the method call is the
construction and the object is auto-destructed at the end of
the call. There even is a name for this object: it is called
the incarnation of the methode (like: instance of a class).
So nested calls can produce many incarnations of one method
at the same time.
 
S

Sven Köhler

For local variables the two concepts differ too. One example
can already be seen in my code, when one reads the local
parameter »i« as a local variable. The most famous example
is the factorial (untested):

int f( final int i ){ return i == 0 ? 1 : i * f( i - 1 ); }

. To understand this, it is vital to understand that »i« has
only a single scope, but can have many (in this case:
nested) lifetimes.

That is correct. But then again, I'm not sure how this professor will
explain it. To be consistent with his definition of scope, he might
explain to the students, that there are many "incarnations" of i, each
"living" from the { to the }, i.e. the scope. In his way of thinking,
this might be consistent with saying that the scope defines the lifetime
of i (namely each incarnation of i).


Regards,
Sven
 
D

Daniele Futtorovic

I decided to watch lecture videos from the Stanford
University about »programming methodology«, which actually
teach Java.

I was somewhat surprised that the lectures of the renowned
Stanford university do not have such a high overall
quality at all.
<snip />

Stefan, allow me to join the crowd in defence of the quack you have
unearthed. After all, we all know that ambiguity doesn't matter in
programming, because the compiler can guess our intent and make things
just right. And getting people interested is all that matters. I mean,
we've all had this colleague, the enthusiastic slob, and we've all loved
to maintain his code. And finally, it is only natural that if, after
having paid for the transmission of knowledge, students want to know how
it /really/ works, they should take the initiative and turn to freely
available resources on the 'net. Perfectly normal.

Nothing to see here, carry on.
 
M

markspace

int f( final int i ){ return i == 0 ? 1 : i * f( i - 1 ); }

. To understand this, it is vital to understand that »i« has
only a single scope, but can have many (in this case:
nested) lifetimes.

OK, I have to disagree with this. At minimum, I disagree that
"lifetimes" is the correct word here.

"Copy" is a better word than "lifetime." So is "stack frame." By the
time one wants to talk about recursion, introducing correct terminology
is the best way, imo. We just had a discussion here on c.l.j.p about
concurrency, and folks who can't keep track of what's on the stack and
what's on the heap have a hard time of it. Learning correctly is
important in school.

But I also agree more with the class instructor. "Scope" is the correct
term here. The scope of i is the body of the method f. That its value
may exist elsewhere is completely orthogonal to a discussion of scope.
 
S

Stefan Ram

markspace said:
"Copy" is a better word than "lifetime." So is "stack frame." By the

A »stack frame« is one special mode of implementation.
The correct - while less known - term is »activation record«.
 
S

Stefan Ram

markspace said:
"Copy" is a better word than "lifetime." ....
"Scope" is the correct term here.

These are all valid words, albeit all with a different meaning.
It is not about whether to /use/ a specific word or not.
It is about /what/ these words mean.

A lecturer cannot just make up a new meaning for theses
words anymore, because they all already have an establish
meaning in software engineering which can be found in many
textbooks, ISO norms, the ANSDIT or the Wikipedia. And,
surprisingly, those sources all agree for these words!
 
D

David Lamb

I know that you are particular precise about thing, but I'm pretty sure,
he will teach that arrays have elements. And he pretty much never
mention the term "anonymous variable" to describe these elements.
To be honest, the notion "anonymous vairable" is really not necessary to
understand how arrays work - and to be honest, your posting is the first
time I read that term.

I've never heard the term "anonymous variable" but I've heard of
"computed names" and "l-values" (for "left hand side of the assignment
symbol", and contrasted with "R-values"). Admittedly all of this was in
non-Java contexts.
 
D

David Lamb

I really don't see that as software engineering.

It is a CS exercise in definitions with little practical
benefits.

Whoah, scope versus lifetime is a pretty fundamental distinction.
Admittedly it was more fundamental in old block-structured languages
like Algol, but still...
 
S

Stefan Ram

Well, I hope you are not annoyed yet. But I just spotted the

Here is how to get a next int value from an object with a
non-static int field »counter« in Java (according to the
lecture!):

public int nextValue() {
int temp = counter;
counter++;
return temp;
}

. I do not yet know if the lecturer thinks that this is more
simple for than students (compared to »return counter++«) or
if he himself is not aware of the value of »counter++«.
 
A

Arne Vajhøj

Tue, 07 May 2013 08:50:18 +0300, /Stanimir Stamenkov/:

Just saw in another reply it was a mistake.

Yep. For some reason I thought it was Harvard.

Arne
 
A

Arne Vajhøj

On 5/5/2013 7:48 PM, Arne Vajhøj wrote:
On 5/5/2013 2:37 PM, Stefan Ram wrote:
I decided to watch lecture videos from the Stanford
University[...]

Second, I believe that Harvard is more known for Law, Medicine,
Business, Economics than for IT. [...]

Hey, Arne: What school did you attend, and what's its
reputation for geography?

Oh shit.

That was about 3000 miles off.

:-(

Hey, well, I'm sure glad *I* never make silly misteaks! ;-)

FWIW,

- Andrew Yao received his first PhD from Harvard.

- Leslie Valiant taught at Harvard.

- Christos Papadimitriou taught at Harvard.

- Michael O. Rabin teaches at Harvard.

- Kenneth E. Iverson received a Masters degree from Harvard
and taught there for half a decade.

- Stephen Cook received Masters and PhD degrees from Harvard.

- Dennis M. Ritchie received undergraduate and PhD degrees
from Harvard.

- Ivan Sutherland taught at Harvard.

- Butler Lampson did his undergraduate work at Harvard.

- Fred Brooks received the PhD from Harvard.

- Edmund M. Clarke taught at Harvard.

- E. Allen Emerson earned his PhD from Harvard.

What can I say.

Why make one mistake when it is possible to make two in the
same sentence.

:)

Arne
 
A

Arne Vajhøj

I assume, Stefan is worried that these ideas could stick - regardless of
whether you consider that software engineering or not.

Yes, but he very explicit called it software engineering.

Arne
 
A

Arne Vajhøj

Whoah, scope versus lifetime is a pretty fundamental distinction.
Admittedly it was more fundamental in old block-structured languages
like Algol, but still...

Fundamental for software engineering??

Arne
 
T

Thomas Richter

I just watched another lecture and noticed the following:

He said something to the effect that the type »int« was there
to store an int value. I would say that an int /variable/ is
there to store a value, while the /type/ int can also be the
type of an expression (like »2«) that is not necessarily
stored anywhere at run-time.

He said that a variable had a name. This is not always true
in Java (he referred to Java, since he is exclusively using
Java). In Java there also are anonymous variables, like the
variables of an array.

Stephan, with all necessary respect, but this sounds very nit-picking to
me. Ultimately, you are correct, but making it this precise is probably
not going to help anyone in class. It typically confuses students more
than it helps.

This said, and looking back at the courses I participated, I learned
most where I found that the teacher was making errors, and where I was
able to follow *despite* such errors because it kept me thinking. I also
had classes where everything was polished, and everything worked
correctly, but while there I always believed to understand everything in
class, I also noticed that the presented information vanished very soon
from my brain.

Thus, please excuse, but a lie for pedagogical reasons is at times more
enlightening than spelling out everything correctly at first glance. As
a teacher, it may make sense of coming back later and explaining
students that, "well, in these and that circumstances, you need to
understand something extra I haven't told you before".
I am actually watching this to learn English pronunciation
of programming terms (otherwise, I just would read a text),
and what I /did/ like was that for the word »char« he gave
the pronunciations of /kA&/ and /kæ&/ (where A is the open
back unrounded vowel and& is the schwar), which I also use
(/kA&/). Bjarne Stroustrup says it was /tSA&/ (where tS is
the voiceless palato-alveolar affricate), well, maybe that
is valid for C++ programmers ...

In my experience, Americans are much less "language lawyers" than people
in Germany (expecting from your name that you have a German backgound -
at least I have), so one definitely shouldn't be too picky about this
either. Specifically, the cultural background in the US is very diverse,
especially at universities and even with teachers.

So please excuse superfluous or missing hyphens and pronunciations that
are "off" the official one. If there even is such a thing.

So long,
Thomas
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top