Underscore in package name in Java - is it bad? [duplicate]
Asked Answered
M

1

12

Sorry for my English

I think that sometimes it is necessary.

In my opinion search_result_list, location_provider are easier to read than searchresultlist, locationprovider.

What does the documentation say?

Mogerly answered 3/3, 2014 at 11:28 Comment(8)
"I'm interested in your opinion" => SO isn't for opinions.Brilliancy
These look more like a class names, not the package names... Packages name should be hierarchical and roughly group classes by some feature (like functionality or structural similarity).Nonstandard
We usually use camelCase for packages and PascalCase for classes/interfaces; in your case it'll be "SearchResultList" and "LocationProvider"Inconspicuous
@DmitryBychenko You're free to do that but that's not the official convention.Brilliancy
@Nonstandard but sometimes a class could use many helper-classes so I need to separate this class with its helpers from others by moving them to a new package named as this class.Mogerly
@LeonidSemyonov Do other classes use these helpers? Or just one? Maybe you could actually put all of their methods into a class, that actually use it. Or you can use "main" class name as prefix in helper class names, i.e. MyClass, MyClassResultList, MyClassHelper, MyClassWhateverProvider, etc.Nonstandard
@Nonstandard Just one class uses these helpers. But often class names already are too long so I cannot use "main" class name as prefix in helper class names. And these helpers are created in order to simplify big "main" class by separating the logic from the helper methods.Mogerly
Class or packages naming, and I don't mean conventions, sometimes is really cumbersome. On one hand names should be short, on the other hand they should be descriptive. It's not easy task to accomplish both. However maybe you should consider, if you really need to have this long search_result_list instead of just result. Try to pick just most important noun. You actually know, what are these classes for.Nonstandard
T
9

Code Conventions could be found here!

I think code conventions are nothing to vary, so stick to such conventions if there exist any...

Tabethatabib answered 3/3, 2014 at 11:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.