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 / General / August 2007

Tip: Looking for answers? Try searching our database.

OT - Tips for width constrained text

Thread view: 
Andrew Thompson - 06 Aug 2007 02:19 GMT
There has been some discussion on a thread about these
parts, as to the difficulty of posting code that is constrained
by width (as the SSCCE document, ..as well as common
sense, might suggest when posting code to usenet).

One suggestion was raised to simply upload the code to
a web site and provide an URL - this is a good solution, in
that it completely removes the need to worry about line-wrap.
Lines do not wrap in code that is downloaded.

GeoCities was suggested as one free place to upload code,
but another poster pointed out that GG users also had the
option to upload 'documents' to their GMail accounts and
link directly to that.

The one reservation I have with linked code though, is that
some people who either "read off-line", or "just don't click
links - ever"*, do not have access to it, and the responses
might be fewer and further between.  Also, asking people
to post to the group really puts the pressure on to keep
the code *short*.  Code at the end of links often has 40
buttons (etc.) not needed to display the problem.

* And I suspect that is a lot of people.

So.. for those wanting to post code to groups, who have
trouble figuring how wide it is, I suggest this scale.

/*
12345678901234567890123456789012345678901234567890123456789012345
        1         2         3         4         5         6      
*/

Paste that comment into Java source code shown in
a fixed width font, and it is easy to judge when later
code will exceed the 'limit'.  

What is the limit?  I have heard it suggested at 72 chars,
but to be safe, I suggest limiting code lines to no more
than 65 chars.

HTH

Signature

Andrew Thompson
http://www.athompson.info/andrew/

Stefan Ram - 06 Aug 2007 13:22 GMT
>the difficulty of posting code that is constrained by width

 I do not get your point.

 I write this here text.
 Its width is restricted
 to 40 characters at most.
 I can also post it.

 What is difficult about it?
 What is the question or
 problem you write about?

 (Actually text is not
 constrained by a width,
 it /has/ a width. A text
 generating /process/ might
 be constrained by a width.)
Lew - 06 Aug 2007 14:40 GMT
>   Its width is restricted

Thank you for spelling "Its" correctly.  That is one of my bugbears, and it's
always a pleasure to see it used correctly.

Your point about being able to restrict your text to 40 characters is well
taken, but I sing hosannas to Andrew for providing a helpful scale for those
who might benefit.  He's provided a tool to help a Usenet poster visually
confirm that they're staying within the margin.

Hosanna, heysanna!

Signature

Lew

Andrew Thompson - 07 Aug 2007 00:10 GMT
>>the difficulty of posting code that is constrained by width
>
>  I do not get your point.
...

That comment resulted as my way of bowing out of this thread..
<http://www.javakb.com/Uwe/Forum.aspx/java-programmer/37325/TextArea-resistant-to
-change


(I hope that thread is 'explanation enough'..)

Signature

Andrew Thompson
http://www.athompson.info/andrew/

Stefan Ram - 07 Aug 2007 23:03 GMT
>>I do not get your point.
>That comment resulted as my way of bowing out of this thread..

 Roedy Green is a very experienced programmer and Usenet
 author, a regular poster in this group. I see, that even he,
 in his recent »refactoring« posting, was not able to avoid
 ugly line breaks while he was not posting via Google.

 So how can one expect to educate Google posters, who might
 only post to this group once for a single question, about this?
Lew - 07 Aug 2007 23:27 GMT
>   Roedy Green is a very experienced programmer and Usenet
>   author, a regular poster in this group. I see, that even he,
>   in his recent »refactoring« posting, was not able to avoid
>   ugly line breaks while he was not posting via Google.

I hear agreement on the principle that it's good to help people post
effectively, disagreement on whether advice about line formatting achieves
that goal.

I propose that we acknowledge arbitrary line breaks as an obfuscatory issue,
and occasionally perhaps mention it helpfully to folks that seem to be
struggling with it more than others.  Andrew's offer of a column-count
template is a helpful one; I've used the same technique any number of times to
lay out screen text.

Everyone is a champion of the benighted Google Groups users, and no one blames
the victims.  Gentleness with the these hapless folks upon whom are such
foibles foisted is the only correct attitude.

>   So how can one expect to educate Google posters, who might
>   only post to this group once for a single question, about this?

These newsgroups educate best the regulars; what benefit accrues to those who
never return is a general question.

Signature

Lew

Joe Attardi - 06 Aug 2007 15:02 GMT
> So.. for those wanting to post code to groups, who have
> trouble figuring how wide it is, I suggest this scale.
[quoted text clipped - 3 lines]
>          1         2         3         4         5         6      
> */

This is a good idea, definitely.

As for websites, a lot of IRC channels I frequent use "pastebins". For
an example of a well known pastebin in the ##java channel on
irc.freenode.org, you can check out http://eugeneciurana.com/pastebin/.

If there was enough interest in using this approach somebody could
always set up a semi-"official" comp.lang.java.programmer pastebin.

Just adding my thoughts..

Signature

Joe Attardi
jattardi@gmail.com

Andrew Thompson - 07 Aug 2007 01:15 GMT
...
>As for websites, a lot of IRC channels I frequent use "pastebins". For
>an example of a well known pastebin in the ##java channel on
>irc.freenode.org, you can check out http://eugeneciurana.com/pastebin/.

This was also touched on, in the thread linked 'up-thread'..

>If there was enough interest in using this approach somebody could
>always set up a semi-"official" comp.lang.java.programmer pastebin.

Aaah.. yes.  I had considered such a thing, long ago.

There are the challenges of
- Controlling access (not only having to identify people who
upload material, but storing, and keeping safe, their log-ins)
- Controlling upload size (OK pretty easy - make it a 'GET')
- Ensuring you are not supporting ..spammers (a code that
repeats "Shop at Ass-Hopper" a million times), pornographers
& paedophiles (code that draws ASCII art pictures of some
famous hated figure having sex with babies..) or general
malcontents who simply post malicious code.

One might argue that none of the last point is relevant
to the person who controls the server, but if some court in
..Wherever* decides that a person is offended by something
from a particular server, it can cause hassles for whoever
controls it - probably whichever country the server is coming
from.  Server hosts are all too willing to remove a site based
on a single complaint, and the owner getting in contact with
them to argue it being restored.

* I was about to name a particular (randomly chosen) city
in the US, given Americans seem to be one of the most
litigious(?) groups of citizens on the planet at this time, but
it really does not matter.  A court anywhere might put
pressure on the hosts of a web site.

As an aside..

For a short, heady time, I actually had an on-line
compiler available to attach to on-line codes, and
compile them directly from a web page (with no
JRE/JDK on local PC).  As it happens, my use of
the (never intended to be publicly exposed on-line)
javac utility on the net opened my server to DOS
attacks.  Although the immediate fix was pretty simple
(constrain compiles by time), it made me realise
that there was a lot more to the security side of
on-line compiling than I had first realised.

Signature

Andrew Thompson
http://www.athompson.info/andrew/

Joe Attardi - 07 Aug 2007 03:07 GMT
> For a short, heady time, I actually had an on-line
> compiler available to attach to on-line codes, and
> compile them directly from a web page (with no
> JRE/JDK on local PC).

How did that work, did you just give it the URL of some Java source code
stored online and it would fetch the text and compile it as if it were a
.java file?

Signature

Joe Attardi
jattardi@gmail.com

Andrew Thompson - 07 Aug 2007 03:50 GMT
>> For a short, heady time, I actually had an on-line
>> compiler available to attach to on-line codes, and
[quoted text clipped - 4 lines]
>stored online and it would fetch the text and compile it as if it were a
>.java file?

Paste it* into an HTML form, select some (javac) options,
as well as versioning options (it could compile against
1.1 -> 1.4 rt.jars) click the 'Submit/Compile' button.  

* The code needed to be an SSCCE** - no references
to other non J2SE classes.

The results page showed the formatted Java source
and either compilation errors, or an applet with a
button to launch it (sandboxed) or a link to the .jar
(for download, or standard app. run).

If I were to do it again, I might do it as a JWS app.,
with the various rt.jar's supplied lazily, but.. I am not
sure of my right to actually distribute the rt.jar's, and
the latest runtimes have become a significant wallop
to download, in any case.

Of course, the JWS option would require the end-user
to have a JRE installed, which the 'on-line' compiler did
not.  ( But then, I always did wonder what the point of
developing Java, using a box that does not run it, could
be ;).

** I did consider something more like what what you
indicated, to get around the 'single source file' limitation.
Offer the user to upload a Zip/Jar archive containing
source, and do the compilation on all the source in the
archive.  But with my paranoia about getting 100's of
kilobytes (or megabytes) of code dumped to the server,
I never bothered proceeding with it.

Signature

Andrew Thompson
http://www.athompson.info/andrew/



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



©2009 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.