Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / May 2004

Tip: Looking for answers? Try searching our database.

Somewhat of a big lie about OO in java book?

Thread view: 
RobertMaas@YahooGroups.Com - 13 May 2004 08:43 GMT
The textbook for my java class (sorry for pun) is:
Introduction to JAVA (tm) Programming
by Y. Daniel Liang, Fourth Edition
ISBN 0-13-100225-2
On page 206, at the start of the chaper on Object-Oriented Programming,
he says "Object-oriented programming places data and the operations
pertain to them within a single entity called an OBJECT;"
If you're talking only about static variables and static methods, and
we're talking about a Class object, that's correct, but in general we
deal with instances of a class which each contain their own set of
instance variables, but the instance methods relating to them do *not*
have a complete set within each object, rather there's a single set of
instance methods within the class, so the variables and methods are in
separate objects, each individual instance object vs. a single Class
object. The diagrams at the bottom of that page and top of next page
only emphasize the lie.
I like some things about this book, but this is one thing I detest,
lies like this. Anyone agree with me?
Andrew Thompson - 13 May 2004 08:05 GMT
...
> The textbook for my java class (sorry for pun) is:
> Introduction to JAVA (tm) Programming

I thought you had made a typo with 'JAVA', but..

> by Y. Daniel Liang, Fourth Edition
> ISBN 0-13-100225-2

<http://images.amazon.com/images/P/0131002252.01.LZZZZZZZ.jpg>
..certainly speaks a thousand 'JAVA's.

...
> I like some things about this book,

What does it get right?

>..but this is one thing I detest,
> lies like this. Anyone agree with me?

I would toss it, except for the fact it
is your 'class' text. (no apologies for pun)

Signature

Andrew Thompson
http://www.PhySci.org/ Open-source software suite
http://www.PhySci.org/codes/ Web & IT Help
http://www.1point1C.org/ Science & Technology

Roedy Green - 13 May 2004 08:26 GMT
>I like some things about this book, but this is one thing I detest,
>lies like this. Anyone agree with me?

He is probably a professor.  They learn to talk that way.

Try my explanation. See if it makes any more sense.

start at http://mindprod.com/jgloss/static.html and chase the links.

Signature

Canadian Mind Products, Roedy Green.
Coaching, problem solving, economical contract programming.
See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.

RobertMaas@YahooGroups.Com - 17 May 2004 18:55 GMT
> From: Roedy Green <look-on@mindprod.com.invalid>
> Try my explanation. See if it makes any more sense.
> start at http://mindprod.com/jgloss/static.html and chase the links.
> static variables and methods might better have been called
> perClass variables and methods.

I agree static variables being called perClass variables would be less
ambiguous, would get to the point rather than beat around the bush.
But static methods and instance methods are both defined once per class
and are effectively constant on that basis, don't have multiple
incarnations on a per instance basis, so calling them perClass methods
wouldn't totally clarify their essence.

> They are the opposite of instance variables and methods that work on
> a particular object.

Instance variables don't work on an object, they exist as part of an
object and access to them is obtained only via that particular object,
and only via the object.variable syntax (from anywhere) or implicitly
or via the this.variable syntax (from within a constructor or instance
method while being applied to the object).

Instance methods *do* work on a particular object in the sense of use
of the variable name by itself implying this.variable, and in the sense
that the whole point of an instance method is in fact to work on that
object, like if it ignores the object it's working on then it's a
dunzell (StarTrek TOS jargon, a part that serves no useful purpose).

> There is nothing static (unchanging) about them.

The term "static" applied to variables in programming languages, refers
to their memory location being unchanged, or at least existing
continuously from when first created until end of session, not their
contents being unchanged (constant, final). Static variables really are
static in that sense. But both static and instance methods are likewise
static in that sense. It's only the stack frame, or thread frame, etc.,
of a method that gets re-allocated each time the method called and
deallocated upon return, and that's the same for any function or method
in any language that uses stack frames (hence supports recursion in the
usual way). (Note "own" in some languages means static and local, i.e.
a local variable that exists permanently rather than in the transient
stack frame. perClass variables in Java are essentially shared-own
variables, like lexical-closure variables in CL except that they are
accessible from the entire class which is usually the entire
compilation unit which is usually the entire file just like static
variables in C. perClass in java, or perCompUnit in C, would be more
clear. But then I guess in the context, where they are respectively
defined directly in a class or directly in a source file, calling them
just "static" is clear?)

> Newbies tend to overuse static variables. Consider what would
> happen if your code were used by several threads simulaneously.
> With shared static variable they would trip over each other.

Yes, this is a good point. Static variables should be used to keep
track of total statistics of a class, or keep compute-once-use-forever
constants, or anything else where there is only a single value shared
across all threads of any method whatsoever within the class. Changes
to these variables should be synchronized, for example if two different
threads want to increment a counter one thread should get the old value
and add one and store that new value before the other threads gets the
old value which should be the value *after* the first thread has
updated it rather than the very original value.

> a Dog variable may point to a Dalmatian object, but not vice versa.

Correct, and the way this is enforced is curious: At compile time it
won't let you down-cast implicitly, gives you this error message (B
derives from A in this case):
 Incompatible type for =. Explicit cast needed to convert A to B.
So you do an explicit downcast in the source code:
       A a1;
       a1 = new A();
       B b1;
       b1 = (B)a1;
and that compiles just fine, and it would run just fine if a1 really
were an instance of class B that just happened to be sitting in a
variable of class A, but in this case that's not true, so when you try
to run it you get:
 java.lang.ClassCastException

> You will often hear Java referred to a language with static type
> checking. The types of all references are checked for consistency at
> compile time.

As you see above, java has both compiletime and runtime type checking,
the first based on what you *seem* to be doing on just glancing at the
source code, and the second based on what's *really* happening, what
the types of the objects really are. In fact you could defeat
compile-time type checking by declaring all object variables of class
Object, deferring all type-checking until runtime, if you wanted to
spend more work trying to track down wrong-type bugs, and if you were
willing to explicitly down-cast every object passed to any method that
requires a more specific type in order for the compiler to figure out
which overloaded method to use.

> Static Web Pages
> The word static is used in a fourth context. It refers to web
> pages the server sends out unchanged. Dynamic pages are
> modified or even composed from scratch before sending.

Nitpicking: If a CGI script constructs a brand-new Web page every time
it's invoked, but in fact it *always* constructs exactly identical Web
pages, would that be dynamic in fact but static in spirit? What if it
returned identical Web pages merely by copying an existing static Web
page? What if it merely referred the client to an existing static Web
page on some other server? Ah, fun for thought but not worth answering.

Summary: with a few fixes your Web page would be fine.
Roedy Green - 17 May 2004 20:22 GMT
>I agree static variables being called perClass variables would be less
>ambiguous, would get to the point rather than beat around the bush.
>But static methods and instance methods are both defined once per class
>and are effectively constant on that basis, don't have multiple
>incarnations on a per instance basis, so calling them perClass methods
>wouldn't totally clarify their essence.

If you were designing the language over, or inventing a SCID skin over
Java,  what would you use as a keyword instead of "static"?

see http://mindprod.com/scid.html

"class" is already taken.  How about "once",  but that has another
clever meaning in Eiffel that might some day make it to Java.

How about "common" as in common to all objects of the class. This name
would be meaningful to newbies.  It even has a little FORTRAN
heritage.

I would have liked to been allowed the explicitly declare "instance"
methods and variables so that it was clear they were truly instance,
not just that I forgot the "static". It would also allow code to line
up better e.g.

public  common   final  int x;
default instance var    int y;

And it would give official names for the defaults to use in
conversation.

Signature

Canadian Mind Products, Roedy Green.
Coaching, problem solving, economical contract programming.
See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.

VisionSet - 13 May 2004 09:12 GMT
> The textbook for my java class (sorry for pun) is:
> Introduction to JAVA (tm) Programming
[quoted text clipped - 14 lines]
> I like some things about this book, but this is one thing I detest,
> lies like this. Anyone agree with me?

Personally I like to think of methods being per object rather than per
class.
The same method is executed in parallel for many objects.  So there are as
many instances of the methods as there are objects.

--
Mike W
Chris Smith - 13 May 2004 17:47 GMT
> Personally I like to think of methods being per object rather than per
> class.
> The same method is executed in parallel for many objects.  So there are as
> many instances of the methods as there are objects.

I disagree with this interpretation.  It's just as possible to have only
one object, but execute a method thousands of times concurrently on that
one object.  (Providing the method is not explicitly coded to prevent
this, as with the 'synchronized' keyword.)  Hence, I find that
explanation more likely to confuse than help.

Signature

www.designacourse.com
The Easiest Way to Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation

Roedy Green - 13 May 2004 19:50 GMT
>> The same method is executed in parallel for many objects.  So there are as
>> many instances of the methods as there are objects.

First there is only one copy of each method.  Each object has a hidden
pointer to a hidden object with a list of "active" methods for that
class, and the superclass.  From that it can figure out where to get
its methods from -- this class or one of its ancestors.

Second there is only one thread to start, so no matter how many
objects you have only one method as a time executes. You can create
new threads, but there is never one thread per object, except for a
few special classes.

Signature

Canadian Mind Products, Roedy Green.
Coaching, problem solving, economical contract programming.
See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.

Chris Smith - 13 May 2004 20:47 GMT
> >> The same method is executed in parallel for many objects.  So there are as
> >> many instances of the methods as there are objects.

Roedy, despite your introduction saying "wrote or quoted", it would only
take a tiny effort to get your attributions right in the first place.

Signature

www.designacourse.com
The Easiest Way to Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation

Roedy Green - 13 May 2004 21:56 GMT
>Roedy, despite your introduction saying "wrote or quoted", it would only
>take a tiny effort to get your attributions right in the first place.

I don't think it matters.  What counts is what is said, not who said
it.

Signature

Canadian Mind Products, Roedy Green.
Coaching, problem solving, economical contract programming.
See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.

Andrew Thompson - 14 May 2004 05:52 GMT
...
>>Roedy, despite your introduction saying "wrote or quoted", it would only
>>take a tiny effort to get your attributions right in the first place.
...
> I don't think it matters.

Again, Roedy.  People are different.  
I was quite surprised that 'Chris'
said that.

Further, at times when I am skimming,
I may jump over what a or b in a
converstion wrote, to read only the parts
written by a single person.

I would ask you to please put more attention
to it.  If we were to follow your scheme of
'anonymous' it would make best sense to leave
all attributions off, rather than have them
incorrect.

> What counts is what is said, not who said
> it.

Perhaps a good point, but if a reader consistantly
finds the posts of one person to be accurate and
informative, while the posts of another trivial
and sarcastic,they may prefer to read the former and
ignore the latter.

To put in even finer edge on it.  Would you want
people to believe that things *I write* were written
by 'Roedy Green'?  I do not imagine you would be
comfortable with that, or that it would best serve
the reader (..,you *or* me).

Signature

Andrew Thompson
http://www.PhySci.org/ Open-source software suite
http://www.PhySci.org/codes/ Web & IT Help
http://www.1point1C.org/ Science & Technology

Roedy Green - 14 May 2004 07:33 GMT
>Perhaps a good point, but if a reader consistantly
>finds the posts of one person to be accurate and
>informative, while the posts of another trivial
>and sarcastic,they may prefer to read the former and
>ignore the latter.

I am so annoyed with how flaky the attributions scheme is.  I can't
stand the thought of wasting time frigging around with something so
hopelessly inept.

It should be automated so that it CAN'T go wrong.

see http://mindprod.com/projmailreadernewsreader.html

I don't think you will persuade me.  I pay no attention to them
myself.  

Signature

Canadian Mind Products, Roedy Green.
Coaching, problem solving, economical contract programming.
See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.

Andrew Thompson - 14 May 2004 07:45 GMT
(attributions in posts)
> It should be automated so that it CAN'T go wrong.

Agree fully.  Pity it's not.

> see http://mindprod.com/projmailreadernewsreader.html
>
> I don't think you will persuade me.  

Probably not. [ ;-) ]  But before I leave the
subject I thought I should just state specifically
that I feel that..

"Correct attributions server the reader, the
OP and other contributors to the thread best".

[ ..I have certainly badly stuffed up
attributions myself, ..and been on the
receiving end of full-on abuse for things
I _never_ said (HTML group).  :-/ ]

Now ..checks subject.. OO?  Oh!  :-O
Outta' here.

Signature

Andrew Thompson
http://www.PhySci.org/ Open-source software suite
http://www.PhySci.org/codes/ Web & IT Help
http://www.1point1C.org/ Science & Technology

Gordon Beaton - 14 May 2004 11:31 GMT
> I am so annoyed with how flaky the attributions scheme is. I can't
> stand the thought of wasting time frigging around with something so
> hopelessly inept.

Most people have no troubles with it. Anyway do you think you are
improving the situation by ignoring the convention? You have in the
past attributed things to me that I haven't written, and I don't like
it. I am confident others who have been misquoted feel the same.

> I don't think you will persuade me. I pay no attention to them
> myself.

Some people feel that way about red lights and speed limits too, but
agreed upon conventions can be good for everyone, even if you
personally find them inept or inconvenient.

/gordon

Signature

[  do not email me copies of your followups  ]
g o r d o n + n e w s @  b a l d e r 1 3 . s e

Roedy Green - 14 May 2004 17:49 GMT
> You have in the
>past attributed things to me that I haven't written,

No I haven't.  I simply mention the author of the message I am quoting
on.  I say that he either said this or decided it was worth restating.

You can't get the attributions without researching. Since I never
read the quoted material 99% of the time, I can't see putting putting
out the effort.  If it is important to you,  you can research it
yourself.

I feel embarrassed FOR people when they complain about not being
attributed. One of the key skills in programming is to get your ego
out of the way.  To stop fussing about attributions is a good start.

The proper solution is a scheme where attributions are automatic, and
ZERO text is embedded in the message doing the quoting. The reader,
not the writer, gets to decide just how much of what he has read
before he is prepared to look at, and has the full text always
available to scroll if needed. I want messages digitally signed to
stop counterfeiting, while still allowing noms de plume.

Signature

Canadian Mind Products, Roedy Green.
Coaching, problem solving, economical contract programming.
See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.

Daniel Sjöblom - 14 May 2004 18:10 GMT
>>You have in the
>>past attributed things to me that I haven't written,
[quoted text clipped - 10 lines]
> attributed. One of the key skills in programming is to get your ego
> out of the way.  To stop fussing about attributions is a good start.

FWIW, I agree with Gordon. I don't mind if I am not quoted, but I do
mind when it looks like I have claimed something I have not.
Signature

Daniel Sjöblom
Remove _NOSPAM to reply by mail

VisionSet - 13 May 2004 21:58 GMT
> >> The same method is executed in parallel for many objects.  So there are as
> >> many instances of the methods as there are objects.
[quoted text clipped - 8 lines]
> new threads, but there is never one thread per object, except for a
> few special classes.

And you quoted a little too little:

VisionSet wrote:
> Personally I like to think of methods being per object rather than per
> class.

*I like to think of*

As in I know it isn't really the case, but personally it helps me to think
of it that way.

If you think of it as the one method per class than it can seem a little
confusing that the method can be a)executed concurrently amongst different
objects and b) that execution carries its own separate set of local
variables.

So I don't see anything wrong with what I wrote, especially if you explain
the proviso that the memory footprint is of just the one method.

I found OO totally baffling when I started 3+ years back, though I never
found this method definition business a difficult concept in the slightest.

And Roedy I have to agree with Chris please try and reply to the person you
intend to, you do this all the time :-))

--
Mike W
RobertMaas@YahooGroups.Com - 23 May 2004 03:30 GMT
> From: "VisionSet" <spam@ntlworld.com>
> If you think of it as the one method per class than it can seem a
> little confusing that the method can be a)executed concurrently
> amongst different objects and b) that execution carries its own
> separate set of local variables.

A class can have several *different* methods defined, but in any one
running of a single program there is only one copy of each such method.
Remember when you learned about recursion? (I hope you did!!) Remember
how there was a single piece of compiled code which was the recursive
function, but when you called it from outside a set of local variables
was allocated on the stack, and then when it called itself recursively
a second set of local variables was allocated on the stack, and when
that recursive call returned the second set of local variables was
deallocated, and when the toplevel call returned the first set of local
variables was deallocated? Each such stack frame represents one
invocation of that function that has started but hasn't yet returned.
The same thing happens in java when you use an object to call a method,
and within that method it needs to call itself on another object. The
same thing happens when you run multiple threads, except the various
stack frames are on different stacks instead of successively on a
single stack.

Remember: For a given method within a given running program, there is
only one copy of the object code (bytcode in the case of java), but
zero invocations of that method initially and transiently one or more
invocations as the program enters (calls) and leaves (returns from)
that method.
Eric Sosman - 24 May 2004 17:02 GMT
>>From: "VisionSet" <spam@ntlworld.com>
>>If you think of it as the one method per class than it can seem a
[quoted text clipped - 7 lines]
> Remember: For a given method within a given running program, there is
> only one copy of the object code (bytcode in the case of java), [...]

    If a method is JITted there'll be at least two copies.
Possibly more, if the JIT chooses to in-line some method's
code within another method (I don't know whether contemporary
JITs actually do this, but it's certainly conceivable.)

    A multi-processor NUMA machine might choose to copy a
method (bytecode and/or JITted code) multiple times so that
every processor can access the code "locally" instead of
"remotely."  (Again, I don't know whether any contemporary
JVMs do this -- but it's not a new technique and one can
certainly imagine it being used with Java.)

    Here's the acid test: Can a piece of Java detect whether
a method exists in one or in many forms?  If the difference
is not detectable, arguing the truth or falsity is chancy ...
"A difference that makes no difference is no difference."

Signature

Eric.Sosman@sun.com

Tom - 13 May 2004 13:55 GMT
> The textbook for my java class (sorry for pun) is:
> Introduction to JAVA (tm) Programming
[quoted text clipped - 14 lines]
> I like some things about this book, but this is one thing I detest,
> lies like this. Anyone agree with me?

I think you are making a mountain out of a molehill.  Yes, there is
only one set of methods stored in memory.  Big deal.  That saves
memory, since the code for the methods is identical.

The point is that in OOP, an objects instance variables and instance
methods are joined-at-the-hip, unlike procedural languages where the
data and methods are separate.

I wouldn't waste too much time worrying about a minor inaccuracy.
RobertMaas@YahooGroups.Com - 30 May 2004 05:03 GMT
> From: tom.cowdery@bigfoot.com (Tom)
> in OOP, an objects instance variables and instance methods are
> joined-at-the-hip, unlike procedural languages where the data and
> methods are separate.

I don't consider joined-at-the-hip to be an appropriate way of thinking
about it, given that a separate set of instance variables is created
every time an object is created (via 'new'), and modifying one of them
is possible at runtime and does *not* affect other copies of the same
variable, whereas if somehow you could modify an instance method *all*
objects of that class would suddenly experience the new method
behaviour. A class, static methods and variables in that class,
instance methods in that class, are all single, all joined at the hip,
whereas instance variables are per-object hence not joined in the same
way.

> I wouldn't waste too much time worrying about a minor inaccuracy.

Oh well, at least we agree the statement in the book was inaccurate.

I wonder if any students reading that book actually got misled and then
were confused when later text contradicted that inaccuracy? Fortunately
I was already past that point in understanding when I read that part of
the book hence recognized the mistake upon reading it instead of
believing it. But another student might have read that without already
knowing the topic, and so might have been misled.

By the way, does anybody know an OO language where the statement in the
book would be literally true, for example if there's a per-object way
of amending or advising an instance method, for example turning on
trace of a method *only* when it's invoked from some particular object?
Chris Smith - 30 May 2004 16:23 GMT
> I don't consider joined-at-the-hip to be an appropriate way of thinking
> about it, given that a separate set of instance variables is created
[quoted text clipped - 3 lines]
> objects of that class would suddenly experience the new method
> behaviour.

That last clause is very questionable.  There is no way of modifying
active code in Java, so it's pointless to speculate what the effect
would be if you could do it.  It would be possible to implement either
effect, but from a pure OO standpoint the expected behavior would be to
change the behavior of the method only on that one object (because
objects own their behavior).

This is, in a sense, an application of the same principle from boolean
calculus that makes it true to say "if the world ended yesterday then
I'm the king of Narnia."  When you start out making assumptions that are
known to be false (such as that you can change the behavior of a method
in Java), then you aren't going to reach interesting conclusions.

> Oh well, at least we agree the statement in the book was inaccurate.

I, on the other hand, still don't agree.  If you insist on confusing
implementation with the OO model, then your interpretation of the
author's words is indeed very inaccurate.  I've already explained how
the authors words, when applied to the OO model that Java implements,
are perfectly accurate.

> By the way, does anybody know an OO language where the statement in the
> book would be literally true, for example if there's a per-object way
> of amending or advising an instance method, for example turning on
> trace of a method *only* when it's invoked from some particular object?

Sure... JavaScript is an example of a language where it's possible to
change the behavior of an object.  That allows you to directly observe
the OO model, and confirm more easily that objects do indeed own their
behavior.

It's interesting to note that in a typical JavaScript implementation,
there is *not* a copy of each method in memory per object.  Only if a
method implementation is modified is a new copy of the method created.  
So you've got an extension of essentially the same implementation (that
is, one copy of the method per class, with only the one exception that a
method may on rare occasions be copied because an object's behavior was
modified after the object was created), demonstrating conclusively that
in the model, object own their behavior.

Signature

www.designacourse.com
The Easiest Way to Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation

Chris Smith - 13 May 2004 17:59 GMT
> On page 206, at the start of the chaper on Object-Oriented Programming,
> he says "Object-oriented programming places data and the operations
> pertain to them within a single entity called an OBJECT;"

Yes, that's true.

I believe you're confusing model with implementation.  It's not
specified in the general OO model, nor in Java, whether there is only
one copy of a method's code held in memory, or one copy per object, or
anything else.  The one-copy case is more likely than the per-object
case for performance reasons... but that's an implementation concern
about the existence of code; the ownership of a method is a different
matter.

You'll often hear OO people proclaim that an object owns its "state",
"behavior", and "identity".  What we mean by an object owning its
behavior is that the behavior depends on which object you're working
with.  Basically, that's polymorphism.  You can interact with two
objects in exactly the same way, and they may act differently because
they are different objects.  (Your author's use of the term
"operations" instead of "behavior" is somewhat ambiguous because the
former could be interpreted as the client interface, i.e. the set of
possible operations, which is not owned by the object at all.)

Note that this doesn't conflict with methods being defined in classes.  
In Java, they definitely are (though there are other class-less or
prototype-model OO languages where this isn't necessarily the case
either).  Another way of putting it is that the point really relates to
locating knowledge.  When code A interacts with object B, is the
behavior determined by prior knowledge from A, or from B.  In an OO
language (and using OO language features... hence, not with static
methods in Java, nor with non-virtual methods in C++), the answer is B.

I hope that clarifies things.  In essence, I think your author is right.

Signature

www.designacourse.com
The Easiest Way to Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation

Qu?bec - 14 May 2004 03:07 GMT
Real chaos.
There is a fight: a priest comes by and preach, receive a fist on the nose
an join the fighters, so does the police, the army, etc. when getting near
to the chaos'black hole.
Ok, brigth guys, I am all mixed up. Java is confusing?

Jean
===================
If static method = one method for every instances?
If instance method = one method   per  instance?

One instance per thread at a time?
If more than one instance per thread deadlock is probable?

<First there is only one copy of each method.
Per instance?
<Each object has a hidden pointer to a hidden object with a list of "active"
methods for that class, and the superclass.
Instance?

< From that it can figure out where to get its methods from -- this class or
one of its ancestors.

- hidden object ?????????????? by the compiler??? Why?
a list of  -other-  "active" methods or duplicated methods?

instances===Vision
<Personally I like to think of methods being per object rather than per
class.
<The same method is executed in parallel for many objects.  So there are as
<many instances of the methods as there are objects.
instances=====Roedey
<a variable, part of an Object. These might better be called perObject
variables since each instantiated object <of this class will have its own
private copy of this variable.

The same for methods?
RobertMaas@YahooGroups.Com - 15 May 2004 00:02 GMT
> From: Andrew Thompson <SeeMySites@www.invalid>
> What does it get right?

One thing I liked is how it started with a simple construct and then
showed how using it in more complicated cases was ugly but there's a
more powerful construct that makes the code better, progressing from
simple IF to IF ... ELSE to nested IF ... ELSE IF ... to select case.
For example:

Good:
if (x<0) ...;

Bad:
if (x<0) ...;
if (x>=0) ...;

Replace above with:
if (x<0) ...;
else ...;

Nested OK:
if (...)
 if (...) ...;
 else ...;
else ...;

Ugly:
if (...)
 ...;
else
 if (...)
   ...;
 else
   if (...)
     ...;
   else
     ...;

Better:
if (...)
 ...;
else if (...)
 ...;
else if (...)
 ...;
else
 ...;

Not the best:
if (n=1)
 ...;
else if (n=2)
 ...;
else if (n=3)
 ...;
else
 ...;

Best:
switch (n) {
 case 1: ...;
         break;
 case 2: ...;
         break;
 case 3: ...;
         break;
 default: ...;
}

I would hope an introductory tutorial on control structures in LISP
would likewise start with simple (if test action) then introduce (if
test action otheraction) then nest them a little, then replace deep
nesting with COND, then replace special case of COND with
(case n
 (1 ...)
 (2 ...)
 (3 ...)
 (otherwise ...)
 )

(Same hope for tutorial for any other language that has these same
kinds of control structures.)

Another thing I like is that he has lots of NOTEs that explain side
things that readers might worry about. Most of these are premature in
some sense, but it's still nice to see the topic mentioned in a NOTE at
first opportunity rather than just left hanging until several chapters
later.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.