Conventions
Navigate Project Page topic: | )
These conventions are aimed to increase the readability and the comprehension of the Java Programming Wikibook. It completes the Wikibooks Manual of Style. However exceptions can be made if needed. If you find it too complex to follow, add the content rawly. It will be formatted by someone.
Page formatting
editMost of the time a page from the Java Programming Wikibook has a structure that looks like this:
You write | You get | |
<noinclude>{{Displaytitle|title=The title of the page}} {{Nav}} {{Java Programming/LanguageFundamentalsTopic/Nav}} __NOTOC__</noinclude> This is the introduction. ==First section== This is a section. <noinclude> {{Nav}} {{Status|50%}}</noinclude> |
First sectioneditThis is a section. |
Samples
editJava file
editSometimes we wish to convey an entire java file, this can be done as follows:
You write | You get | ||
{{XCode|1='''Code listing 1.1: The <code>MyClass</code> class''' <syntaxhighlight lang="java"> class MyClass{} </syntaxhighlight>}} |
|
"1.1" means that it is the first code of the first chapter. Using <syntaxhighlight/>
is better than using a template as ||
is a part of the Java syntax.
Snippets
editWhen just a small section of code is shown, the code template may be used as follows:
You write | You get | ||
{{XExample|1='''Code section 1.1: The <code>MyClass</code> class''' <syntaxhighlight lang="java"> for (int i=0; i<10; i++) { System.out.println("Hello!"); } </syntaxhighlight>}} |
|
Screen print
editTo represent what is shown on the screen, use the following syntax:
You write | You get | ||
{{XConsole|1='''Output for the application''' <pre style="background-color:#000; color:#fff;"> Hello World! </pre>}} |
|
Notes
editNotes grant readers additional information about a certain topic. You can enter additional or side notes by using the following template:
You write | You get | ||
{{XNote|This is an additional note.}} |
|
Use notes only when it is necessary. A note is less readable than paragraphs.
Warning
editTo warn the user of things like common pitfalls, the XWarning
template should be used as demonstrated:
You write | You get | ||
{{XWarning|This is a warning.}} |
|
To-do items
editIf there are sections of the book that require attention at a later time, you can add a to-do note by including the following template:
You write | You get |
{{TODO|To-do items for pages should be kept in their respective comment boxes.|Java Programming}} |
|
Hidden section
editIf a section is optional, it can be hidden like this:
You write | You get |
{{Java/Hidden begin|title=Hidden section}} This section is not mandatory. {{Hidden end}} |
Hidden section This section is not mandatory. |
Illustrations and diagrams
editThis book uses various illustrations and diagrams to convey its message, e.g., flow-chart or UML diagrams, etc. Due to the nature of diagrams, they need to be designed in a scalable vector format. It is highly recommended that you use the SVG format for your diagrams. Please, do not use JPG or PNG for diagrams that could otherwise be done in SVG. Ask a regular contributor for his/her help in this matter.
A regular feature for diagrams used in this book is the overall color scheme. The most notable color used for illustrations in this book is #2a7fff
(as is shown for the diagrams below, for instance). In order to include illustrations into your content, you need to use the {{Java/Illustration}}
template. Given below is an example of how this template ought to be used.
You write | You get | ||
{{Java/Illustration |number=1 |caption=A sample illustration from the book |image=[[File:Java Compilation Basics.svg|center]] }} |
|
Text formatting
edit- Use italic when you use a term for the first time.
- Use the
<code/>
markup when you refer to a class, a field or a method.
Preferred English
editThis book uses United States English, purely for the sake of consistency. Most programming languages have words represented in the United States English, e.g., color
, etc. You should use the US English wherever possible.
Code conventions
editThe book follows the official Java code conventions. Here is an example:
Code section 0.1: The official Java code conventions
if (foo == bar) {
// do stuff
} else {
// do other stuff
}
|