store whole InputStream in a String

P

Paul Lutus

ak said:
yup, go to doctor, may be he can help you

However most people use Windows, just because it is more comfortable.

And even more people avoid the disorienting experience of even sitting at a
computer. Among operating systems, Windows is closest to not having a
computer at all.
 
P

Paul Lutus

Jacob said:
This approach fails seriously on readability.

As I have already said, once you have seen this pattern ten thousand times,
it begins to seem familiar and readable. There is a reason one sees this
pattern so often.
The while(true) construct for reading streams is
the natural choice and it is so common I'd classify
it as a pattern.

No, it is a misuse of "while". It is an effort on the part of inexperienced
programmers to create an unconditional block in a language that doesn't
offer one.

Inexperienced programmers will often create something like this:

while(true) {
int c = source.read();
if(c < 0) {
break;
}
else {
// use the character
continue;
}
}

This sort of code is regularly created by those with prior experience with
languages that do not have any structure, or by those who simply are not
getting the structured prorgamming paradigm.
A "stream" is, conceptually speaking, endless!

Conceptually speaking, nonsense. All streams end, which is why a value is
reserved to signify their end, and why programmers must test for the end of
the stream.
Reading it using an endless loop is quite natural.

No, that is a sign of inexperience. It is a sign of ad hoc programming --
"What? This stream might end? Okay then, I'll just put a break right here,
that should repair my ill-conceived code."

Except it doesn't, and such devices are never seen in properly managed,
maintainable software projects.
If the stream for some reason stops, then break
the endless processing.

This same thing could be said of any structured programming method -- if you
don't understand why it's there, defeat it. Then, after some real-life
tests fail, apply a fix that is equally unsuitable to the task.
 
P

Paul Lutus

Tor said:
We canb call it the "Goto Pattern", then, because that's what
"while(true)... break" really is.

I had the same thought, but I didn't want to introduce that notion to this
audience. Wrong experience level. I thought it better to criticize
"while(true)" on its immediate deficiencies, e.g. what it isn't rather than
what it is.
 
A

ak

consider to provide "Reset menus" button
Already true! How long is this going to take, exactly? Please read the
documentation.

no, [GetRescueMacroSet] is not the same thing as "Reset menus" button.

Try following the instructions I provided. I posted a link to the correct
Web page, paragraph and section.

Here is the first paragraph of your link:

"I tried everything, and I still can't get Arachnophilia to run (or
Arachnophilia ran once, but won't any more).

Although most likely a resource issue (see below in this answer), this may
be caused by a bad installation of Arachnophilia's user directory. Take
these steps:

1. Delete the directory (user home directory)/.Arachnophilia
2. Try to run Arachnophilia again. If this fails, go to step 3.
3. Download the current Arachnophilia build from the Arachnophilia Home
Page www.arachnoid.com/arachnophilia.
4. Reinstall.
5. If this fails, look for an error log file at (user home
directory)/.Arachnophilia/ArachErrorLog.txt. If it exists, this file may
offer some clues. If you submit a bug report, be sure to include the
contents of this file.

Finally, chronic unsolved problems of this class are almost invariably
caused by not having enough system RAM and/or hard drive space. To solve
this problem, purchase more RAM and/or free up hard drive space."

Sorry, may be my english not good anough, but I don't see any solution
which could be realized from within arachophillia.
 
P

Paul Lutus

ak wrote:

/ ... snip full text of my FAQ on this issue
Sorry, may be my english not good anough, but I don't see any solution
which could be realized from within arachophillia.

You need to stop placing conditions on a situation that you do not
understand. Your post is like saying "I need to change a tire, but why
can't I do this while driving the car?"

The solution is listed in your post, just before your claim that it is not
there:

1. Delete the directory (user home directory)/.Arachnophilia
2. Try to run Arachnophilia again.

This *will* solve the problem you have created for yourself.
 
A

ak

However most people use Windows, just because it is more comfortable.
And even more people avoid the disorienting experience of even sitting at a
computer. Among operating systems, Windows is closest to not having a
computer at all.
I agree, most people have not anough money to buy a computer,
however some people have so much money, that they don't need
computer anymore.
 
A

ak

Sorry, may be my english not good anough, but I don't see any solution
You need to stop placing conditions on a situation that you do not
understand. Your post is like saying "I need to change a tire, but why
can't I do this while driving the car?"

The solution is listed in your post, just before your claim that it is not
there:

1. Delete the directory (user home directory)/.Arachnophilia
2. Try to run Arachnophilia again.

This *will* solve the problem you have created for yourself.

You speak about solution, I speak about _user_friendly_solution_.
It seems that you don't want to understand me.
So long than...
 
A

ak

This *will* solve the problem you have created for yourself.

tztztz, I didn't created this problem.
That was some buggy software.
However I used now the "only one" remedy that you recommended and it worked
very well.
 
A

ak

This is the biggest problem of free software - programmers does not
think
This is the funniest line I have ever read on this topic. Programmers of
free software do not think of anything else but the user. Were this not
true, they would charge for their programs.

Please read your own website.
It looks like fortress - your leading message is "DON'T CONTACT ME!!!"
Yes, and if "one simple click" is your goal, you should definitely avoid
sitting at a computer.

there much users which _must_ have computer - it is their job.
And yes "simple click" could make their life easier.
 
P

Paul Lutus

ak said:
tztztz, I didn't created this problem.

As a mater of fact, you created this problem.
That was some buggy software.

False. The program worked perfectly as it carried out your explicit
instructions. Garbabge in, garbage out.
However I used now the "only one" remedy that you recommended and it
worked very well.

There are several remedies, this was just one, and I practically had to
force-feed it to you.
 
P

Paul Lutus

ak said:
You speak about solution, I speak about _user_friendly_solution_.

You need to ask yourself how this free program has taken advantage of you.
Please, do it in public, so everyone can have a good laugh.
It seems that you don't want to understand me.

It seems that I don't need ot understand you. Instead, you need to
understand instructions.
 
P

Paul Lutus

ak said:
I agree, most people have not anough money to buy a computer,
however some people have so much money, that they don't need
computer anymore.

Among those people, some of them anyway, having a computer is an enjoyable
intellectual diversion.
 
P

Paul Lutus

ak said:
Please read your own website.
It looks like fortress - your leading message is "DON'T CONTACT ME!!!"

And? Too many people contact me instead of reading the instructions. Sound
familiar?
there much users which _must_ have computer - it is their job.
And yes "simple click" could make their life easier.

As would a toaster control ("lighter ... darker") instead of a mouse. It all
depends on what you are trying to accomplish.

Your thesis seems to be "I want to press one button and let the computer
figure out what I mean."
 
G

Gary Labowitz

ak said:
Please read your own website.
It looks like fortress - your leading message is "DON'T CONTACT ME!!!"


there much users which _must_ have computer - it is their job.
And yes "simple click" could make their life easier.

General answer to all:

You guys break me up. As I recall Arachnophilia is careware. Where is all
your caring? And it is free. That's means don't be so demanding -- you got
your money's worth. As to OP topic (remember the OP?), as a teacher I find
it easier to teach a while(true) [with break] to get students running with a
valid program (all those usages being valid) and then expand on better ways
to do any given thing. In this case it results in code Paul suggests.

Paul: what you say is true, but one can't always impose strict academics on
students who are struggling with a sea of ideas, programming constructs, and
new ways of thinking. We start them in the wading pool. Those who don't
drown there get to try the deep end later. I'm sure you wouldn't like my
classes, but I'm not sure my students would like yours. By like, BTW, I mean
enjoy the actual learning of programming enough to spend the time and
thought needed to actually understand it.
To you other guys: lighten up. So you did it baby-fashion. So it works.
Okay. But now learn from the master (or at least one of them here) and move
on. Stop defending and attacking on such a dumb question. There are going to
be better ways of doing just about anything you care to mention; otherwise
we CAN close the patent office.

As for me, I don't care how it damned thing is coded -- just that it work.
Optimization comes ... uhh ... last.
 
C

Chris Smith

Tor said:
We canb call it the "Goto Pattern", then, because that's what
"while(true)... break" really is.

There really is a serious difference between break/continue (including
labeled break/continue) and goto. It can be debated whether that
difference fixes the pitfalls of the goto statement, but it's useless to
deny that the difference exists.

That difference is that while break/continue can be used to exit a block
of code from an arbitrary point, it cannot be used to enter a block of
code at an arbitrary point. There is a very strong case to be made that
it's the latter -- arbitrary entry points to a block -- that is most
threatening to readable code. The former is a natural abstraction in
many programming scenarios, esp. when try/finally is used judiciously as
well.

For the record, though, in at least the specific case of reading from an
InputStream, the universal idiom of "while ((len in.read(buf)) != -1)"
is far easier to follow, simply because an average Java programmer will
already know what to expect.

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

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
 
A

ak

Please read your own website.
And? Too many people contact me instead of reading the instructions. Sound
familiar?

hundreds? thousands? millions?
lol
Your thesis seems to be "I want to press one button and let the computer
figure out what I mean."
this may be not so difficult as to let you understand what I mean.
 
A

ak

General answer to all:
You guys break me up. As I recall Arachnophilia is careware. Where is all
your caring? And it is free. That's means don't be so demanding -- you got
your money's worth. As to OP topic (remember the OP?), as a teacher I find
it easier to teach a while(true) [with break] to get students running with a
valid program (all those usages being valid) and then expand on better ways
to do any given thing. In this case it results in code Paul suggests.

the irony is that I agree that Paul's code is better,
but I don't agree with Paul's art to speak.
 
J

Jacob

Paul said:
As I have already said, once you have seen this pattern ten thousand times,
it begins to seem familiar and readable.

I prefer making code understandable for those that have
*not* read my code 10-thousand times. That's the majority
after all. It includes avoiding variable names like "len"
when meaning "length" and so on.
 
M

Mike Schilling

..
No, it is a hack, not an argument by assertion.

OK, I get it now. I thought you were being serious. I see now that you're
doing a sort of Mionty Python routine:

You're wrong.

That's not a logical argument, it's simply an assertion:

No it isn't an assertion.

Why not?

Because you're wrong.

Sorry it took me so long to catch on.
 
G

Gary Labowitz

Above is the message as I received it. Checking the source it also reads as
above. I have been seeing a number of posts, very random, that have words
concatenated as the "familiarandreadable" above. I am worried as to where it
is coming from (since I'm using OE :)).
My question is to > > (I think Jacob): did you actually write
"familiarandreadable" without spaces for a reason, or did you have spaces
and it came through without?
TIA
 

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,780
Messages
2,569,611
Members
45,280
Latest member
BGBBrock56

Latest Threads

Top