Forums Register Login

A silly question about naming convention

+Pie Number of slices to send: Send
Hi friends, Im creating the following class:

I readed the Java naming conventions file, because its very important to me to follow this conventions. So, if I follow the correct convention the name of accessor method will be getOnCreateEvent() correct? Or it will be getonCreateEvent() ? (with the 'o' lower case) ?
Thanks in advance!

+Pie Number of slices to send: Send
It's Camel case (The humps .. Get it?)

Your method is called getOnCreateEvent(), however be warned that in some EL (Expression Languages)
and the "new" Ruby/Groovy/Roo patterns, your view code would refer to it as "onCreateEvent()".
The EL will put a "get" in front of it, and convert the "o" to "On".

Also if boolean types "get" can magically become "is" ;)

Welcome to the Fold!

Pat.
+Pie Number of slices to send: Send
Agree. Capital O. You should follow the indentation and spacing conventions, too. A get method takes 5 lines, one of which is blank. Not 1 line as you wrote.
+Pie Number of slices to send: Send
Thanks for the informations guys.
@Campbell Ritchie, can you give me an example about this five lines ? Thanks in advance!
+Pie Number of slices to send: Send
 

Campbell Ritchie wrote:Agree. Capital O. You should follow the indentation and spacing conventions, too. A get method takes 5 lines, one of which is blank. Not 1 line as you wrote.


I include a leading blank line where the house style forces me to place the opening brace at the end of a line. My own preference is to place the opening brace by itself on the next line following the method signature. With this formatting I find that a leading blank line is too much white space. I never like to see trailing blank lines before the closing brace.
+Pie Number of slices to send: Send
The blank line comes after the closing brace (or before the method header). 1 method header, 1 {, 1 return ..., 1 } and 1 blank makes 5.
1
+Pie Number of slices to send: Send
Also, always use spaces, not tabs, for indenting.
+Pie Number of slices to send: Send
Campbell's tips are good, but there are really no "official" naming conventions or coding standards for Java. Almost all Java software seems to use the same naming conventions for classes, variable names, method names etc., following the style of the standard Java library. The placement of braces differs at different places.

The closest to standard code conventions is this old (but still relevant) document: Code Conventions for the Java Programming Language.

At the company I'm currently working at, we put opening braces on the same line. Like this:
+Pie Number of slices to send: Send
 

Jesper de Jong wrote: . . . At the company I'm currently working at, we put opening braces on the same line. . . .

Most code conventions tell you the same thing, except for one common difference: whether { goes at the end of the line or on a line by itself.
+Pie Number of slices to send: Send
 

Jesper de Jong wrote:At the company I'm currently working at, we put opening braces on the same line.


Where I work we do whatever we want , but I've always much preferred that style as well. Both have sensible justifications, in my mind. As long as you don't mix and match!
+Pie Number of slices to send: Send
They are right to tell Jesper to use a particular convention. You get code awkward to read if you allow people to mix {} conventions.
2
+Pie Number of slices to send: Send
Yeah, well, where I work it's a big enough job to get people to use the same technologies, never mind the same style.
+Pie Number of slices to send: Send
Thanks a lot guys. And @Campbell Ritchie, I will use your style because its really a lot clean for me.
+Pie Number of slices to send: Send
You’re welcome
a fool thinks himself to be wise, but a wise man knows himself to be a fool - shakespeare. foolish tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 940 times.
Similar Threads
Naming method which returns boolean
Question about JavaBean naming for a method that returns boolean
having problem in verifying a character
static char in the files given from Sun
Public interfaces ...
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 16, 2024 09:41:30.