|
Follow these simple rules while hacking away for JCast-X.
Keep your code as simple as possible:
- Classes < 25 Methods
- Methods < 1 Screen full of code
- Lines shorter than 80 chars
Try and use comments to explain the inner workings of your code. Be descriptive! For example
always explain inside the conditional case what you expect and not the state of variables:
Wrong:
if ( count < 0 ) {
// Count is below 0
...
code
...
}
Right:
if ( count < 0 ) {
// So far we didnt count any newlines
...
code
...
}
The difference is simple, in the latter case anyone reading the comment inside the condition
will understand what the author tried to achieve. If for any reasons a problem related to the
condition occurs, it is easier for any reader to see the problem.
Make your code readable by using "space" in your code plus fully qualified comments.
Wrong:
if (m_readBytes <= 0) { break; }
Right:
if ( m_readBytes <= 0 ) {
// I guess we are at the end of file...
// This breaks file read, iteration through playlist continues...
break;
}
Also Right:
if ( m_readBytes <= 0 )
{
// I guess we are at the end of file...
// This breaks file read, iteration through playlist continues...
break;
}
Use the collections framework provided by Java, in general look at java.util.* and make use of the tools available.
Create unit-tests for all classes in order to keep up code quality by reducing likelyness of
change-bugs. Ask other developers/friends to take a look at your code and give your feedback.
(Given enough eyeballs, all bugs are shallow). Further please read the JCast-X
development process document.
|