• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Question on proper case for classes and variables

 
Ranch Hand
Posts: 38
Oracle Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Junilu Lacar wrote:Kabayan Joseph,

First of all, no offense but the coding style (seemingly random capital letters in the names) in your sample code is atrocious. Please don't do that in real code. Secondly, what you show is not at all overloading. Overloading is when you use the same method name and return type but allow different parameters to be passed. A good example of overloading: see the many different types of parameters you can pass to String.valueOf()

Edit: See discussion regarding return type below



its ok atleast im commiting my errors now as a student
i just thought that what i was doing was camel back spacing haha and by the way its not random its 3rd letter of the variable that is capital anyway if its wrong then i shall remove it in my practice and thanks for all the comments
 
joseph dela cruz
Ranch Hand
Posts: 38
Oracle Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
by the way can i ask what is the difference between

Kano Kano; vs Kano Kano = new Kano();

and

char[] a = "asdf".toCharArray();

String.ValueOf(a) vs new String(a);

and i just want to ask is new String(a) is casting char array to string or no? is it similar to this (int)a[1] casting it into an integer

thanks for all your answers please do not hesitate to tell me if i have misconception on certain things and if im doing something wrong or in a very hard way
i am open minded and i want to learn
 
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I thought it was called camel-case. But that means the first letter of each word is Capitalised when the words are allRunTogether. (all run together)
 
Sheriff
Posts: 17644
300
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Joseph,

Java identifiers are case-sensitive so 'Kano' and 'kano' are considered as two different identifiers.

See http://java.about.com/od/javasyntax/a/nameconventions.htm for a good discussion of Java naming conventions. And it's called "CamelCase", not "Camel back."

String.valueOf() (note the case convention for method names) is preferable over new String(..). No, the latter is not the same as casting. Casting simply tells the compiler to use a particular type; no memory is allocated for a new object as is the case with new String(). See https://coderanch.com/t/524964/java/java/When-new-String-against-string for more.
 
Campbell Ritchie
Marshal
Posts: 79177
377
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nice article, but I am not sure about interfaces beginning with the letter I. That is, I think, however, the usual convention in C#. Also note how many interface names end in able or ible.
 
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Campbell Ritchie wrote:Nice article, but I am not sure about interfaces beginning with the letter I.


Ugh. Totally agree. Smacks of the old "type prefix" to me, which I never liked; even back when it was possibly worth something.

Winston
 
Junilu Lacar
Sheriff
Posts: 17644
300
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Add my vote against the "I" prefix to mark interfaces. The practice my teams uses is to give an implementation-agnostic name to the interface (go figure) then use qualifiers that help distinguish different implementations. This is most commonly used with our Repository services: CustomerDao would be the interface name, then JdbcCustomerDao or HibernateCustomerDao would be specific implementations.

Joseph, note that when using mixed or camel case, you would capitalize at the start of a word, not at some arbitrary position like "the third letter" as you were doing before. The intent is to make it easier read the code and remove ambiguity

 
reply
    Bookmark Topic Watch Topic
  • New Topic