This week's giveaway is in the Testing forum.
We're giving away four copies of TDD for a Shopping Website LiveProject and have Steven Solomon on-line!
See this thread for details.
Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!

Jim Toy

+ Follow
since Oct 17, 2002
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Jim Toy


I think I understand you better now. As to the why, the for loop is block scoped, but has to honor method scoped variables.

My apologies if this is more than necessary ... i did this more for my benefit of working out the problem. The variable defined in the for loop will not hide/shadow because the for block does not begin until after the for statement, so the variable initialized cannot conflict with others in the block.

Here is an example I created....hopefully i commented it correctly

edit: By the way, I am really glad you posted this thread, it made me really think about scoping.

Line 8 is OK, it is a shadow, line 10 will fail, line 15 is ok because there is no other variable named 'free' in the block.

From the K&B book pg 191 there are 4 scope types:
* static, class level
* instance, object level
* local , method level
* block , block level

The question that jumps to my mind is ...why is it ok to declare ouch on line 18. I would say it is because it is method level scoped, and when the method is in scope on the stack arguments are passed by value. So even though the method is free to extend beyond itself to the reference static/instance variables it still has the flexibility to re declare those names since they are not in scope.

Wouldn't the answer be "unpredictable" since the output of either thread can not be guaranteed? Even though there is no contention, the thread pool scheduler will run/stop/run then in its own sweet time.

In the book example you provided, the compilation fails because ouch is already in scope prior to the for loop which attempts to declare a variable that has the same name.

In this example a variable i is declared in the for loop, and when it goes out of scope the variable name is available again.

This example fails for the same reason the book example failed, i is already in scope when the for loop attempts to create a variable of the same name.

I too am studying for the I hope I did not miss anything in this example.
Explicity add the jar to the classpath, not just the directory.

Or you can add the fully qualified jar to the classpath of the command line.
16 years ago

Just to make sure I undertand what you are trying to do.

1) Create an object
2) Pass the newly created object to doSomething so that its values are set

3) Do the logic

I hope I am on the right track so far.

1) Does doSomething need to know things about SomeObject to do its job?
2) Does doSomething return a value that ONLY SomeObject could care about?
3) Are the operations in the switch statement only valid for SomeObject?
16 years ago
I switched companies. The new place is a JBuilder shop...ugh. So hey refused to buy me anything other than JBuilder.

When I saw the anouncment I almost ripped my wallet appart getting the credit card out!
17 years ago

Originally posted by Tim Holloway:
you don't want to use Eclipse on a 200MHz machine with 100MB RAM!

It would run a lot better if you took that 36MB stick out

Originally posted by David Attard:
Its dumb to say you should still use textpad / vi.

I don't agree with this statement. If programmer becomes proficient using a good extendable editor, the editor becomes an extension of the person. A programmer can work by instinct when it counts. Instead of "...Oh I am in (insert IDE here). I need to click/press/type this to get what I want done to work."
[ September 29, 2003: Message edited by: Jim Toy ]
I am a Linux newbie who recently installed SuSE 8.2. I noticed that Blackdown Java was part of the default installation.
Intrigued I went to the project site, but I am confused as to the goals of the project or even a "why" to the project.
If Sun offers a Linux distro, then what is the purpose of Blackdown? Is it optomized for Linux? The site did not get into why I would choose Blackdown over the Sun distro.
I would appreciate the thoughts and comments of this community.
[ September 24, 2003: Message edited by: Jim Toy ]
18 years ago
Real programmers use punchcards.
There is a somewhat valid point to be made on the "Real Programmers use Textpad". The Pragmatic Programmers Andy Hunt and Dave Thomas tout the virtues of plain text. Simply...plain text endures. Furthermore if you can find an editor that is extendable, that editor can be used for a variety of languages.
That being said, a "Smart Programmer" will leverage stylized tools to increase productivy.
So a Devloper has to ask themselves, am I willing to train myself to productivly use single purpose tools? Or use a development environment that reduces the learning curve?

Originally posted by Richard Hawkes:
You'll only go blind if you forget to wipe the semen out of your eyes

Now THAT is funny
18 years ago
Of course THEY are saying that it will miss us! THEY want us all placid. THEY have silenced the scientiets. But I say power to the people, information is free.
18 years ago

Originally posted by Ashok Krishnan:

cd "Program Manager" will work only in CMD, not in ''.

To get "Program Manager" to work in you need to conform to 8.3 spec. So you need to use c:\progra~1
18 years ago
It has to do with the order of the objects in your first example it was A->B->C in your second it is A->C->B.
Therefore when you created C it did not have to "go through" B.
To get what I think you are looking for you would change your object instantiation code to
C c = new B();
19 years ago