Naming convention for JSF pages [closed] - java

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 years ago.
Improve this question
In Java, there's a naming convention for classes, interfaces, packages, methods, variables and constants. I'm just wondering if there is a naming convention for JSF XHTML pages.
Here are a few variants that came up to my mind:
MyPage.xhtml
myPage.xhtml
my-page.xhtml
mypage.xhtml

There's no need to think of xhtml pages as something different from plain html pages. In the end, if a user has to type it out, then it would help to have a simple page name (just like we would name any html page).
To give you an example, even a company like Apple who are so specific about using the correct case for their products, still maintain a URL such as http://www.apple.com/iphone! (iPhone is written as iphone)
To summarize I would say, don't use capital letters in URL, and try not to use special characters either.

Camel-case starting with a lowercase letter is good, I use hyphens to distinguish modules/ subpages/ subelements.
For example:
productList.xhtml
productEdit.xhtml
productEdit-buttons.xhtml
productReport.xhtml
customerAddress.xhtml
customerAddress-map.xhtml
Not a formal convention, but it works well. Being able to modularize or identify fragments or sub-functions is useful.

Related

Why java variables can only contain underscore and dollar sign [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 2 years ago.
Improve this question
I was wondering what is the reason behind this and why we cannot use any symbol than those two, I think I never use a variable with those symbols but it is worth to know the cause
The $ in variables is a historical convention that is commonly used in Linux systems (among other languages) to call variables. In a Linux system, if I set a variable, I call it with this key (i.e. x = 4, echo $x).
Underscores and Camel Case are 2 common ways to identify multi-word variables. If I want to declare the variable iLoveJava or I_Love_Java, both are easily readable.
Of course, all of this is a rationalization of stylistic choices made by Sun Microsystems when they made the language, but I think it's a fair interpretation ;). If you want more details on why the others aren't used in detail, the link posted by Sercan is excellent information as well.

JSON file proper Case and word spacing [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 5 years ago.
Improve this question
I am wondering what will be the best approach for word case and word delimiter in JSON
considering that later on the JSON file will be converted to a Java Pojo and i would like this Java Pojo to be in ProperCase
I am debating between:
"sectionSuspensionTiresSteering": [{
"SectionSuspensionTiresSteering": [{
"section_suspension_tires_steering": [{
"section Suspension Tires Steering": [{
I don't really think that JSON has a naming convention, so you can "choose" sort of speak. As I have a Java background, I prefer using camelCase (your first option). I would avoid using blank spaces in the JSON keys, it is allowed but causes problems because most of the existing framework aren't able to deal with it.
So you are free to use the style you want. Regarding the conversion back to Java Pojo, this is just a matter of annotations. When you use for example Jackson, it allows you to annotate your fields in order to convert the JSON file back to a Java Pojo.
Use always the first one:
"sectionSuspensionTiresSteering": [{
Examples of similar files in official guides:
https://spring.io/guides/gs/authenticating-ldap/
As you can see here, the gradle file uses this notation and XMLs files too.
I understand that JSON properties are written in camel case (sectionSuspensionTiresSteering) style.
But it has nothing to do with how the property will be written or coded in java.
For example if you use Gson() to do the conversions between java an JSON you can name the java property whatever you want and annotate the property with #SerializedName("jsonName") passing in the JSON property name.
What I mean is that the two names are not coupled.

Java split string naming conventions [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
If I split a String permIp, Is there a specific naming convention that is considered to be correct that I should follow for the String[] that I create, such as permIps, permIpSplit or splitPermIp? Or is this a matter of personal preference?
permIpSplit seems fine. The naming convention should be camel casing and ensuring that it conveys the correct meaning to the people reading it apart from you. So including split in the variable name should do.
That all depends on what code style you have decided to go with. There is no set rule for naming conventions. There are lots of examples of different code styles but they are all just guidelines. A good place to start might be googles though.
https://google-styleguide.googlecode.com/svn/trunk/javaguide.html#s5.2.7-local-variable-names
There is no naming convention for the spiltted String[] array. Use usual java naming convention for variable name which is suitable for array and also suitable for the original String which is being splitted.

Java naming convention for identifiers that begin with a number [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I have to deal with a domain object that's real name is 351K-Report. According to the Java naming convention its forbidden to use a number at the beginning of an identifier.
I don't want to fully spell out the number. And, I also think that it's a bad idea to place an underline in front of the number.
But what is the recommended alternative?
UPDATE
There are also other reports, like SpecReport, TopReport, LF10Report and so on. So I'm very doubtful that inverting parts of the noun changes the meaning of the whole project.
Maybe reverse it. For example:
report351K
That would be very bad..
Imagine this:
int 1d = 3;
double d = 1d * 2;
What would be d?
Alternatives:
Since variables that begins with _ usually indicates for class member, I would use report351K.
if you really want to do this then _351KReport but I don't think you should do this. try to make something meaningful of it and at the same time is convineient to Java

Design pattern fu for converting between subclasses [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
We are writing a hierarchy of classes that implement various ways to represent languages. There is a base LanguageCode class with several subclasses, including ISO1LanguageCode for ISO 639-1 codes (example: 'en'), ISO2LanguageCode for ISO 639-2 codes (example: 'eng'), and HumanReadableLanguageCode (example: 'English'). At any time, we need to be able to convert between any two of the subclasses. Is there some design pattern magic we could use here to help?
Note:
Our first idea was to standardize the base class and make each subclass write a conversion routine between itself and the standard on the base class. That way, to convert between ISO2LanguageCode and HumanReadableLanguageCode, use LanguageCode as a bridge.
There is only one set of languages. Each language has an -1 code, a useless -2 code, and a -3 code. And a human-readable name. So make one enum with accessors to return the different codes, and multiple lookup static methods.

Categories