Indentation styles

J

Jim Gibson

Lew said:
Here other programmers are "the customer", and we're here to help with source
code, or talk about other related matters where source code is part of the
discussion.

I wasn't talking about posting code to comp.lang.java.programmer. I was
discussing the use of programming standards in general. I haven't had
occasion yet to post any code here, but if I do, you can be assured it
will follow Java standards, just to avoid criticism from the
small-minded among you.
Even if the language, such as C, doesn't have an official standard but it
does have a de
facto standard, standards is standards.

"I believe in standards. Everyone should have one." - George Morrow
It's about clear communication *with other programmers*. You want to use a
sociopathic
style like Mr. Tilde's or Stefan's, you will run into communication
difficulties. Just use the
standard format, for Chrissake!

My format is better than the standard format. It is not, however,
"sociopathic". Just works for me.
 
R

Roedy Green

There are several different ways to format texts with braces
and parentheses. One of them is being described here.

This was the sort of thing that blew teams apart in the old days.
Today we have beautifiers so you can format it to you personal
preference, then put it back to corporate standard and commit to
Subversion.

Logically Java snippets in newsgroups should be logically separate
from the message body so that the viewer can automatically reformat
them.
 
A

Arved Sandstrom

square( x ) creates a two-dimensional square with x pixel side length,
right?

In the context of a graphing package I might expect that. In the context
of a math package I would not.

AHS
 
D

Daniele Futtorovic

In the context of a graphing package I might expect that. In the context
of a math package I would not.

Which package the method belongs to, or what a package is "about", is
hardly a generally readily discernible information. And you might have a
package that does both...

But generally speaking, you see what I mean, don't you? That condensed
form is ambiguous; the further condensed, the more ambiguous any form
will be. There is beauty and elegance in subtlety; there is a lot of
onanism in it, too. For our trade, I believe the Jav has it right in
recommending more paraphrasing and hence more determinism -- especially
readily apparent determinism.
 
A

Arved Sandstrom

Which package the method belongs to, or what a package is "about", is
hardly a generally readily discernible information. And you might have a
package that does both...

But generally speaking, you see what I mean, don't you? That condensed
form is ambiguous; the further condensed, the more ambiguous any form
will be. There is beauty and elegance in subtlety; there is a lot of
onanism in it, too. For our trade, I believe the Jav has it right in
recommending more paraphrasing and hence more determinism -- especially
readily apparent determinism.
Bad choice of words on my part, my headspace when I wrote that wasn't
Java, it was more general. Think "software package", not "Java package".

In general I agree with you. I would understand 'square' as a method
name to mean the mathematical operation, provided that the argument type
made sense. This actually follows Pike's guidelines: 'square' used as a
verb with a numerical (integer, real, complex, matrix etc) argument has
one well-known meaning. It's not actually ambiguous at all.

But if the method were to do something different other than squaring a
number, yes, it should have a better name.

AHS
 
A

Arne Vajhøj

Even if the language, such as C, doesn't have an official standard but it does have a de
facto standard,

Really?

What is it?

I mean GNU style says indent 2, K&R styles says indent 4 and Linux
kernel style says indent 8.

Which one is the de facto standard?
It's about clear communication *with other programmers*. You want to use a sociopathic
style like Mr. Tilde's or Stefan's, you will run into communication difficulties.

Playing psychiatrist again?
Just use the
standard format,

That one I agree with!

Arne
 
A

Arne Vajhøj

I wasn't talking about posting code to comp.lang.java.programmer. I was
discussing the use of programming standards in general. I haven't had
occasion yet to post any code here, but if I do, you can be assured it
will follow Java standards, just to avoid criticism from the
small-minded among you.

Right decision wrong reason. IMHO.

Arne
 
S

Stanimir Stamenkov

14 May 2013 01:16:41 GMT, /Stefan Ram/:
»By convention, method names should be a verb in
lowercase or a multi-word name that begins with a verb
in lowercase, followed by adjectives, nouns, etc.«

http://docs.oracle.com/javase/tutorial/java/javaOO/methods.html

The followers thus should write:

calculateSquareroot( calculateSquare( x )+ calculateSquare( y ))

JLS, Chapter 6. Names
<http://docs.oracle.com/javase/specs/jls/se7/html/jls-6.html>:

| We recommend these conventions for use in all programs written in
| the Java programming language. However, these conventions should
| not be followed slavishly if long-held conventional usage
| dictates otherwise. So, for example, the sin and cos methods of
| the class java.lang.Math have mathematically conventional names,
| even though these method names flout the convention suggested
| here because they are short and are not verbs.
 

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,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top