This document describes a list of coding conventions that are required for code submissions to AndroMDA. By default, coding conventions for most Open Source Projects should follow the existing coding conventions in the file that you are working on. For example, if the bracket is on the line after the if statement, then you should write all your code to have that convention.
Below is a list of coding conventions that are specific to AndroMDA. Anything else not specifically mentioned here should follow the official Sun Java Coding Conventions.
The following applies to any code, whether it be templates, java files, XML files, etc.
Another requirement is to set the right margin to 120 characters, so lines break if they exceed this limit. A shorter limit is not acceptable since it will break lines sooner and will disrupt the look and feel of the code.
public class SomeClass
{
public void someMethod()
{
if (xxx)
{
}
}
}
if (this.isComposition())
{
}
ClassifierFacade classifier = (ClassifierFacade)element;
for (final Iterator stereotypeIterator = stereotypes.iterator(); stereotypeIterator.hasNext();)
{
final ModelElement stereotype = (ModelElement)stereotypeIterator.next();
stereoTypeNames.add(stereotype.getName());
}
@author FirstName LastName
public int getEntityCount()
{
// don't do this:
/*
if (condition)
{
return 6;
}
return 0;
*/
// but do this:
int entityCount = 0;
if (condition)
{
entityCount = 6;
}
return entityCount;
}
attribute, collIdents should be
identifiers (the type is Collection, don't specify that
in the name), the code should read as plain English.
public class SomeClass
{
private String someString;
...
public void someMethod()
{
logger.debug("Value = " + this.someString);
}
}
strClassName for a String).
When more than one parameter is present in the list we write each one of them on a new line
and indent. Where possible we make the parameter final. For example :
public void someMethod(
final String className,
final int count)
{
}
break keyword would be missing it should be
replaced by a comment indicating the fall-through. If the default action
is to not perform anything then please put this in a comment so people know it's on purpose.
switch(myValue)
{
case 1 :
doSomething();
break;
case 2 :
doSomething2();
break;
case 3 : // fall-through
case 4 :
doSomethingElse();
break;
default :
// do nothing
}
try
{
...
}
catch (Exception ex)
{
logger.error("Some error has occurred" + ex);
}
try
{
...
}
catch (Exception ex)
{
logger.error("Some error has occurred" + ex);
ExceptionRecorder.instance().record( ex );
}
This will create a .exc file with the stacktrace and additional debugging and environment information:
------- AndroMDA Exception Recording ------- Version ........: 3.0-RC2-20050420181638 Error ..........: Error performing ModelProcessor.process with model(s) --> 'jar:file:/home/martin/ews30andromda/workspace/andromda-all/cartridges/andromda-webservice/src/test/uml/WebServiceCartridgeTestModel.xml.zip!/WebServiceCartridgeTestModel.xml' Build ..........: 2005-04-20 18:16:38 Build System ...: Linux-2.6.11-suspend2 Build JDK ......: Sun Microsystems Inc.-1.4.2_07-b05 Build Builder ..: martin Run System .....: Linux2.6.11-suspend2 Run JDK ........: Sun Microsystems Inc.1.4.2_07-b05 Main Exception .: Error performing MDRepositoryFacade.readModel Root Exception .: java.lang.OutOfMemoryError java.lang.OutOfMemoryError
$variable.property instead of $variable.getProperty(),
the two calls are equivalent but the former better matches our metamodels
(and is less code to write).
/documentation/main/src/changes/changes.xml.
Take a look at previous changes for examples.
As always, use JIRA to submit feature requests and patches.
If you have modified your local version by adding a new feature and would like to see in the main distribution, then file a new issue in JIRA and attach the patch to it (please do not send it to the mailing list).
If you want to see your patch quickly applied by committers, you should be able to provide the following items:
If all of these requirements are met and you are respecting the coding conventions, then it is very likely your patch will be accepted soon.