2. What are coding conventions?
“coding conventions are a set of guidelines for a specific programming
language that recommend programming style, practices and methods for
each aspect of a piece program written in this language.” wikipedia
lunes 16 de septiembre de 2013
3. examples
• Naming conventions
• Code formatting
• Code licenses
• Code documentation
• Code refactoring
• Apply programming practices
• Architectural best practices
• More..
lunes 16 de septiembre de 2013
4. walkmod is a tool to...
• automatize the practice of code conventions in development teams (i.e
license usage).
• automatize the resolution of problems detected by code quality tools
(i.e PMD, sonar, findbugs).
• automatize the development and repetitive tasks i.e: creating basic CRUD
services for the entire model.
• automatize global code changes: i.e refactorings.
lunes 16 de septiembre de 2013
5. requirements
• walkmod is a Java tool, so you need the java virtual machine (jdk) 1.6 or
higher in order to proceed.
Please, make sure that JAVA_HOME is set to the location of your JDK and
that $JAVA_HOME/bin is in your $PATH environment variable.
lunes 16 de septiembre de 2013
6. installation
• download walkmod-{version}.zip from walkmod.com.
• unzip the folder.The created folder is called$walkmod_home.
• update your environment variable $PATH with your$walkmod_home/
bin directory.
• run walkmod --version to verify that it is correctly installed.
lunes 16 de septiembre de 2013
7. walkmod.xml
• Create a walkmod.xml file in the root directory of your java project.
• Edit the file and put the following content.
<!DOCTYPE walkmod PUBLIC "-//WALKMOD//DTD" "http://www.walkmod.com/dtd/walkmod-1.0.dtd">
<walkmod>
<chain name="example-chain">
<reader path="${source directory}" />
<transformation type="walkmod:commons:import-cleaner" />
<writer path="${target directory}"/>
</chain>
</walkmod>
lunes 16 de septiembre de 2013
8. configure a project
• Replace ${source directory} from where read your java packages. i.e
src/main/java.
• Replace${target directory} from where write the new code. i.e src/
main/java. if ${source directory} = ${target directory}, your code
will be automatically replaced.
• imports-cleaner will remove unused imports of your project.
• writer will rewrite your code with a default eclipse formatting.Yo can
configure it.
lunes 16 de septiembre de 2013
9. run
Open your prompt and go to your project directory.
> cd {project directory}
Then, type:
> walkmod apply
And voila! your code has applied all declared conventions
(transformations) into your source code according a configuration file
called walkmod.xml
lunes 16 de septiembre de 2013
10. ...
INFO [main] - >>com.mycompany.Foo
INFO [main] - >>com.mycompany.Bar
INFO [main] - >>com.mycompany.Services
------------------------------------------------------------
INFO [main] - TRANSFORMATION CHAIN SUCCESS
------------------------------------------------------------
INFO [main] - Total time : 3,262 seconds
INFO [main] - Finished at : Sun, 7 Apr 2013 18:13:39
INFO [main] - Final memory : 4 M/ 21 M
INFO [main] - Total modified files : 14
output
walkmod should print those files which contain unused imports. For
example:
lunes 16 de septiembre de 2013