Win a copy of React Cookbook: Recipes for Mastering the React Framework this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Rob Spoor
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Tim Holloway
  • Piet Souris
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Frits Walraven
  • Himai Minh

Documentation & Coding Styles

 
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The original looks exactly as intended in Mozilla, Firefox, and Opera. Those of you using MSIE are on your own.
 
blacksmith
Posts: 1332
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Jeroen Wenting:
In a few years you'll agree with most of us that underscores do nothing to make code more readable, all they do is make names longer than they need be.
Maybe Stefan will. I used camelCase for several years at jobs where it was the de facto standard, and for me underscores still improve legibility by functioning almost like spaces between the words. They also permit an additional style of capitalization.
 
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Jim Yingst:
The original looks exactly as intended in Mozilla, Firefox, and Opera. Those of you using MSIE are on your own.


That's the problem with the Mozilla engine and Opera, they don't obey the HTML specification of stripping whitespace properly...
 
Jim Yingst
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ummmm, no, check the source. The text you enter gets HTML inserted into it by the UBB program. If it didn't, most whitespace would be stripped as you say. For some reason UBB uses a <br /> at the end of every line that's not completely blank, but it uses a <p> in place of a completely blank line, replacing two consecutive <br /> tags. IE displays <p> and <br /> the same way, while the other browsers insert an extra line for <p> since the <p> represents the start of a new paragraph. I'm not aware of a clear spec on how paragraphs are to be displayed, so I'd say it's UBB's fault for generating inconsistent HTML.

I've just hacked the UBB code to try to get it to display things a bit more consistently, using <br /> at the end of each line. So hopefully this will work better in the future. So in the future, blank lines in code should display as blank lines, even if you're using IE. Or maybe not; there's probably some other side effect I haven't noticed yet. (Crossing fingers...)
[ May 13, 2004: Message edited by: Jim Yingst ]
 
Ranch Hand
Posts: 1272
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Jim:

About your post:

[MG]: My point was that your example is not OK according to the strange rule I quoted.

[JY]: Ah, but it is. The only identifier in that line was "intArray", and it's surrounded by whitespace. Whitespace around literals, keywords, operators, and other punctuation like commas is optional.


It's clear from both the examples and the wierd rationale shown in Chicken Coop style section 2.2 that literals as well as identifiers are to be surrounded by spaces.

However, let me propose a new example:
Do you think the spaces before the commas improve the code compared to: Have you even seen the first style in wide use outside the Cattle Drive?

[ May 13, 2004: Message edited by: Mike Gershman ]
[ May 13, 2004: Message edited by: Jim Yingst ]
 
Jim Yingst
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
[MG]: It's clear from both the examples and the wierd rationale shown in Chicken Coop style section 2.2 that literals as well as identifiers are to be surrounded by spaces.

No, the text refers only to identifiers, and there are numerous examples showing literals (integer and String) which are not surrounded by whitespace. As for the rationale - um, no comment.

[MG]: Do you think the spaces before the commas improve the code

Not particularly. I prefer to use commas the way we've grown used to seeing them everywhere else. Also I think that excessive whitespace diminishes its usefulness when you actually want to set something apart by giving it extra space.

[MG]: Have you even seen the first style in wide use outside the Cattle Drive?

No. Only at my current job, and that's a special case, since I got the job through the Coop style guide author.
[ May 13, 2004: Message edited by: Jim Yingst ]
 
Ranch Hand
Posts: 1923
Scala Postgres Database Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The revision-control system could strip all unused spaces, when comparing sources, but store them as they come.

This would support additional whitespaces like mentioned from Jim, where I agree, and exceptions from rules like this:



As (intended ) sideeffect, this example shows, why a tab is a tab and not 8 blanks (or 4, or 2). After RED we got 7 blanks, while behind YELLOW there are only 4.
 
Jim Yingst
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And here is what the above code looks like when viewed with tabs set to 4 spaces:

If the tabs had been saved as spaces, you would not see this problem.
 
Ranch Hand
Posts: 2937
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've just hacked the UBB code to try to get it to display things a bit more consistently, using <br /> at the end of each line. So hopefully this will work better in the future. So in the future, blank lines in code should display as blank lines, even if you're using IE. Or maybe not; there's probably some other side effect I haven't noticed yet.

Thanks for that fix Jim, much appreciated. I tested it, and it works. I look at my own code and I cry, touched by the elegance of those empty lines. I was considering putting an end to my JR membership because of that nasty bug, but now I am bound forever.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic