Skip to content

Commit dd2392d

Browse files
eirizarrypdavidc
authored andcommitted
Update WorldWind Java documentation (NASAWorldWind#128)
- Added ISSUE_TEMPLATE.md, which gives the guidelines for submitting an issue - Added PULL_REQUEST_TEMPLATE.md, which gives the guidelines for submitting a pull request - Added CONTRIBUTING.md, which gives the overall expectations for contributing to WorldWind Java, the coding and design guidelines, and resources for the WorldWind community - Removed "Design and Coding Guidelines.html"; this file's content was ported into CONTRIBUTING.md
1 parent 0835e20 commit dd2392d

File tree

4 files changed

+308
-290
lines changed

4 files changed

+308
-290
lines changed

CONTRIBUTING.md

Lines changed: 262 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,262 @@
1+
# Contributing to WorldWind Java
2+
3+
#### Table of Contents
4+
5+
[Asking Questions](#asking-questions)
6+
7+
[Design and Coding Guidelines](#design-and-coding-guidelines)
8+
9+
[Contributing](#contributing)
10+
- [Reporting Bugs](#reporting-bugs)
11+
- [Suggesting New Features](#suggesting-new-features)
12+
- [Pull Requests](#pull-requests)
13+
14+
[Resources](#resources)
15+
16+
## Asking Questions
17+
18+
**Please do not file an issue to ask a question.** You will get faster results by using the following resources:
19+
20+
- Check out the [WorldWind Forum](https://forum.worldwindcentral.com/)
21+
- Email the [Administrative Contact](mailto:patrick.hogan@nasa.gov)
22+
23+
## Design and Coding Guidelines
24+
25+
These design and coding guidelines are for **WorldWind Java** and do not necessarily reflect the expectations for other
26+
WorldWind projects.
27+
28+
### General
29+
30+
* The project's development IDE is IntelliJ IDEA. The IDEA configuration files for this project are checked in to
31+
the code repository. They define within them global and local library links, formatting rules, etc.
32+
* Our required target platforms are OS X, Windows XP and Vista, and the most popular versions of Linux. All code
33+
and all products must run on all those systems.
34+
* Read the WorldWind API's Overview section for a description of WorldWind architecture, design and usage. Read
35+
the overview pages of each WorldWind package for descriptions of those. These descriptions contain critical
36+
information that is not repeated elsewhere. To avoid making mistakes, everyone working on WorldWind must read
37+
them before using or modifying the code.
38+
* Most major classes need a no-argument constructor so that the declarative instantiation mechanism can work. WW
39+
objects should avoid constructors with arguments so that they can be created generically by name. This means
40+
they should self-configure if at all possible, drawing their parameterized info from Configuration. They should
41+
also contain an interface to set the configuration details programmatically.
42+
* Make field and variable names clear and easy to read. Don't label them with "my" or "m_" or some other goofy
43+
notation. Within a class refer to all member fields with "this", e.g., this.tileCount.
44+
* The buffers one must use to pass arrays of info to JOGL must have their byte order set to that of the machine
45+
they're used on. Call nativeByteOrder() on NIO buffers when you deal with them, use the methods in
46+
com.jogamp.common.nio.Buffers.
47+
* Favor immutability (all fields final) in classes representing some small entity like a Point or Vector.
48+
Immutable classes are fully thread safe and generally less error prone.
49+
* Don't worry too much about frequent memory allocations. Java is now so optimized for this that allocating an
50+
object on the heap has similar performance to allocating it on the stack, and this includes the cost of garbage
51+
collection. There is still a cost to executing any code, however, so be smart about allocation frequency.
52+
* Configuration items typically have two values and thus two attribute names: a DEFAULT value that is used if not
53+
overridden, and a non-default value that can be set programmatically (in Configuration) to a current value
54+
without losing the ability to recover the default value.
55+
* Classes such as BasicDataFileStore and the logger are effectively singletons but they are not defined in their
56+
class definition as such. Their singleton nature comes from their 1:1 association with the truly singleton
57+
WorldWind class, which provides access to instances of these "singleton" classes.
58+
* Do not use classes that are not available in the standard 1.6 JRE. Don't incur additional or external
59+
dependencies. The only 3rd-party library we rely on is JOGL.
60+
* Constants are defined as String and namespace qualified. This enables easy and non-conflicting extension.
61+
* Do not use GUI builders to generate interfaces for examples or applications. They prevent others from being able
62+
to maintain the code.
63+
* Protect OpenGL state within a rendering unit, such as a layer, by bracketing state changes within try/finally
64+
clauses. The util.OpenGLStackHandler utility class makes this easy. It manages both attribute state and matrix
65+
and when it fails.
66+
* WorldWind never crashes. Always catch exceptions at least at the highest entry point from the runtime, e.g., UI
67+
listeners, thread run() methods.
68+
* Within a rendering pass WorldWind does not touch the disk or the network. Always fork off a thread to do that.
69+
Use the TaskManager and Retriever systems to start threads during rendering. These are set up to govern thread
70+
usage to avoid swamping the local machine and the server.
71+
* Too much micromanagement of state makes the code brittle. Try to design so that the right thing just happens
72+
once things are set up, and the effect of something going wrong is benign. For example, Layers fork off
73+
Retriever objects to retrieve data from the network. But they don't try to keep track of these. If the retriever
74+
succeeds then the data will be available the next time the layer looks for it. The fact that it's not there
75+
because of a timeout or something tells the layer to ask for it again if it needs it.* DOMs are expensive in memory and time. Use an event for any documents that might be large. Use the parser in
76+
gov.nasa.worldwind.util.xml when appropriate.
77+
78+
### Exceptions
79+
80+
* WW objects running in the Main thread pass exceptions through to the application unless there's good
81+
reactive/corrective behavior that can be applied within WW.## Contributing
82+
* Log any exceptions prior to throwing them. Use the same message for the log as for the exception.
83+
* Ensure all exception messages are generated using the i18n method details below.
84+
* Public methods validate their arguments and throw the appropriate exception, typically InvalidArgumentException,
85+
and identify the exception message the parameter name and the problem -- null, out of range, etc. See the
86+
message resource file, util.MessageStrings.properties, for common messages and their identifiers.
87+
* In Retriever threads, do not catch Throwable. Catch and react to Exception if there's a good reactive/corrective
88+
behavior to apply, otherwise allow them to pass up the stack. Retriever threads should have an uncaught
89+
Exception handler specified for the thread. The method should log the Exception or Throwable and then return.
90+
* Private and protected methods whose calling client can't be trusted validate their arguments and throw an
91+
appropriate exception.* The audience for exceptions is not primarily the user of the client program, but the application or WorldWind
92+
developer. Throw exceptions that would let them know immediately that they're using faulty logic or data.
93+
94+
### Logging
95+
96+
* Logging using java.util.logging has the nice feature of capturing the class and method name at the site of the
97+
logging call. That's why there is the common idiom of create message, log message, throw exception. Wrapping
98+
these three actions in some utility method would lose the class and method-name feature, so don't do that. Don't
99+
use any logging system other than that in the JRE.
100+
* Log all exceptional conditions before rethrowing or throwing a new exception.
101+
* Ensure all logging uses i18n messages as detailed below.
102+
* Use level SEVERE for things that prevent the intended action,e.g., file can't be written. Use level WARN for
103+
things that don't stop the action but seem exceptional, e.g., a file was retrieved or written redundantly. Use
104+
level FINE for simple notifications. Use FINER for method traces. Using the "FINE"series prevents screen display
105+
of these when the default JAVA logging settings are used. Since we're a component, we don't communicate such
106+
things directly to the application's user; the application does.
107+
108+
### Concurrency
109+
110+
* Use collection classes from the java.util.concurrent package if there's any chance at all that the collection
111+
may be accessed from multiple threads.
112+
* Except for simple atomic variables (but not long or double) the safest way to manage multi-thread access is
113+
through the blocking queue classes of java.util.concurrent.
114+
* Making a class' fields final avoids concurrency problems, but it makes the class much less extensible. If using
115+
private, make sure there are overridable set/get accessors.
116+
117+
### Offline Mode
118+
119+
* WorldWind's use of the network can be disabled by calling {@link gov.nasa.WorldWind.setOfflineMode}. Prior to
120+
attempting retrieval of a network resource -- anything addressed by a URL -- WorldWind checks the offline-mode
121+
setting and does not attempt retrieval if the value is true. To honor this contract, all code must check network
122+
status prior to attempting retrieval of a resource on the network.
123+
124+
### Documentation
125+
126+
* Use the appropriate Ant target to generate worldwind.jar and javadoc API documentation. Do not use the IDEA
127+
Tools command because it's not configured appropriately, only the Ant targets are.
128+
* All public and protected classes, methods and fields should be commented for javadoc documentation generation.
129+
* Descriptions of classes, methods, etc. should start with a capital letter. Parameter descriptions and
130+
return-value description should start with a lower-case letter. All descriptions end with a period.
131+
* If a class overrides methods from {@link Object} such as <code>toString()</code> and <code>equals()</code>,
132+
their behavior for the specific class should be described. For <code>equals()</code> that would be the fields
133+
compared. For <code>toString()</code> that would be the representation returned.
134+
* Use links liberally, e.g., {@link WorldWind}. They help the reader get to information fast.
135+
136+
### Code Formatting
137+
138+
* Use the code formatting and style that's in the IDEA project file. It makes it possible to review previous code
139+
modifications.
140+
* Use the code formatting rules specified in WorldWindJ.ipr. They are in the project file under (Settings Project
141+
Settings Project Code Style). To apply them, simply use Code Auto-indent Lines. You can also just check the box
142+
at Subversion check-in time and the formatting will be applied before check-in. Be sure the formatting rules are
143+
not overridden in your IDEA workspace.
144+
* We generally use the traditional Sun coding conventions. Constants are in all upper case with words separated by
145+
underscores. Everything else is in camel case. Class names start with an upper case character, variables start
146+
in lower case.
147+
* White space is preferred over packing code into a small space. Please use white space liberally.
148+
* Set up IDEA to automatically place the standard project header in newly created files by putting the following
149+
as the File Header in the Includes tab of IDEA in the File Templates dialog: <br> <code> <br>/* Copyright (C)
150+
2001, 2011 United States Government as represented by <br>the Administrator of the National Aeronautics and
151+
Space Administration. <br>All Rights Reserved. <br>*/ <br>package ${PACKAGE_NAME}; <br> <br>/** <br> * @author
152+
${USER} <br> * @version $Id: Design and Coding Guidelines.html 1171 2013-02-11 21:45:02Z dcollins $ <br> */
153+
</code><br><br> Then remove the package name property from first line of the Class and Interface items of the Templates tab
154+
in the File Templates dialog. (The package name is in the "include" now, so it gets inserted after the
155+
copyright.) Test it out by creating a dummy class. Unfortunately this set-up is a personal configuration in
156+
IDEA, not project specific.
157+
* When creating a new file, the Id subversion keyword has to be explicitly set via Version Control --> Set
158+
Property --> Property name: svn:keywords, and the term Id included in the text box. If the property is not
159+
included in this list then Subversion doesn't replace the property string when updating the file.
160+
* Resolve all IDEA warnings before checking in a file. If the warning refers to an intentional case, add an
161+
exception statement.
162+
163+
### Internationalization (i18n)
164+
165+
* String "constants" are stored in separate resource files (e.g. MessageStrings.properties). These files must end
166+
in ".properties" and must be stored in the src directory. Strings are stored with the format:&nbsp;
167+
packageOfClass.className.nameOfString=value of the string
168+
* Access the string constants by using the following pattern:&nbsp; (e.g. Logging.getMessage("myPackage.myClass.targetStringName");).
169+
170+
### Books
171+
172+
The books we go back to again and again are the following:
173+
* *Core Java*, Horstmann & Cornell, Volumes 1 and 2, Prentice Hall. Be sure to get the editions covering at
174+
least J2SE 5. Get the newest edition (currently 8).
175+
* *The Java Programming Language*, Arnold & Gosling, Addison Wesley. Be sure to get the most recent edition
176+
covering at least Java 6.
177+
* *Concurrent Programming in Java*, Lea, Addison Wesley
178+
* *Java Threads*, Oaks & Wong, O'Reilly
179+
* *Java Cookbook*, Darwin, O'Reilly
180+
* *OpenGL Programming Guide*, Shreiner & Woo & et al, Addison Wesley. Be sure to get the version covering
181+
OpenGL 2.0, which is currently the Fifth Edition.
182+
* *Mathematics for 3D Game Programming & Computer Graphics*, Lengyel, Charles River Media. Be sure to get the
183+
Second (or later if there is one) edition.
184+
185+
## Contributing
186+
187+
### Reporting Bugs
188+
189+
This section guides you through submitting a bug report to WorldWind Java. Following these guidelines helps both the
190+
WorldWind team and community understand your report, reproduce the behavior, and find related reports.
191+
192+
#### Before Submitting a Bug Report
193+
194+
* Check the [**WorldWind Forum**](https://forum.worldwindcentral.com/forum/world-wind-java-forums).
195+
* Check this repository's [**issues**](https://github.com/NASAWorldWind/WorldWindJava/issues) to see if the problem has
196+
already been reported. If it has and the issue is **still open**, add a comment to the existing issue instead of opening
197+
a new one.
198+
199+
> **Note:** If you find a **Closed** issue that seems like it is similar to what you are experiencing, open a new issue
200+
and include a link to the original issue in the body of your new one.
201+
202+
#### Submitting a Good Bug Report
203+
204+
Bugs are tracked as [GitHub issues](https://guides.github.com/features/issues/). After you've complete the prerequisites
205+
for submitting a bug, create an issue in the appropriate repository and providing the following information by filling out
206+
the [template](ISSUE_TEMPLATE.md).
207+
208+
Explain the problem and include additional details to help the WorldWind team reproduce the problem:
209+
210+
* **Use a clear, descriptive title.**
211+
* **Describe the exact steps which reproduce the problem.** Please be as detailed as possible. When listing steps, don't
212+
just say what you did, but explain how you did it.
213+
* **Provide specific examples.** Include the appropriate files, links, or code snippets which will help the WorldWind
214+
team and community better understand the issue.
215+
* **Describe the behavior.** Detail what behavior you observed and point out what is wrong with that behavior. Explain
216+
which behavior you expected to see and why.
217+
218+
Provide more context by answering these questions:
219+
220+
* **Did the problem start happening recently?**
221+
* **Can you reliably reproduce the issue?** If not, provide details about how often the problem happens and under which
222+
conditions it normally happens.
223+
* **Does the problem happen for all files, or only some?**
224+
* **What is the name and version of the OS you're running?**
225+
226+
### Suggesting New Features
227+
228+
This section guides you through submitting and enhancement for WorldWind Java, including completely new features and minor
229+
improvements to existing functionalities. Following these guidelines helps the WorldWind team and community understand
230+
your suggestion and find related suggestions.
231+
232+
Before creating new feature suggestions, check this repository's [issues](https://github.com/NASAWorldWind/WorldWindJava/issues)
233+
as you may find out that you don't need to create one. When you are creating an enhancement suggestion, please provide as many details as possible. Fill in the [template](ISSUE_TEMPLATE.md), including the steps that you imagine you would take if the feature you're requesting existed.
234+
235+
#### Submitting a Good New Feature Suggestion
236+
237+
New feature suggestions are tracked as [GitHub Issues](https://guides.github.com/features/issues/). After you've checked for existing issues that might relate to your suggestion, create an issue
238+
in the appropriate repository and provide the following information:
239+
240+
* **Use a clear and descriptive title.**
241+
* **Provide a step-by-step description of the suggested enhancement** in as many details as possible.
242+
* **Provide specific examples to demonstrate the steps.**
243+
* **Explain why this enhancement would be beneficial** to most WorldWind users.
244+
* **Specify the name and version of the OS you're using.**
245+
246+
### Pull Requests
247+
248+
* Fill in the [PULL_REQUEST template](PULL_REQUEST_TEMPLATE.md).
249+
* Do not include issue numbers in the PR title.
250+
* Provide a description of the change.
251+
* Explain why this code should be in the core.
252+
* Describe possible benefits and drawbacks from merging this pull request.
253+
* Specify some issues to which this pull request is applicable.
254+
255+
## Resources
256+
257+
For WorldWind Java tutorials and examples, please check out our website: https://worldwind.arc.nasa.gov/.
258+
259+
For community support and FAQs, check out the WorldWind Forum: https://forum.worldwindcentral.com/.
260+
261+
To reach our Administrative Contact, please email: [patrick.hogan@nasa.gov](mailto:patrick.hogan@nasa.gov).
262+

0 commit comments

Comments
 (0)