@walkmod#walkmodevoxx
walkmod an open source tool to apply coding conventions
Raquel Pau
@raquelpau
www.walkmod.com
@walkmod#walkmodevoxx
A bit of me
• 7 years working with Java
• Team leader in the research group DAMA-UPC
• Experience in...
@walkmod#walkmodevoxx
Developers principle
DRYdon’t repeat yourself
@walkmod#walkmodevoxx
Coding conventions
“Set of guidelines for a specific programming language that
recommend programming...
@walkmod#walkmodevoxx
... shall we dream again? yes!
walkmod
• Tool to apply coding conventions
• Extensible tool by plugi...
@YourTwitterHandle@walkmod#walkmodevoxx
Demo
@walkmod#walkmodevoxx
How walkmod works?
•Most code conventions can be automatically assured using
code transformations. T...
@walkmod#walkmodevoxx
public class HelloVisitor extends VoidVisitor<VisitorContext>{
...
@Overwrite
public void visit(Meth...
@walkmod#walkmodevoxx
import org.walkmod.javalang.ast.body.ModifierSet;
import java.lang.reflect.Modifier;
import org.walk...
@walkmod#walkmodevoxx
package ${query.resolve("root.package.name")};
import javax.persistence.Id;
import javax.persistence...
@walkmod#walkmodevoxx
How does walkmod respect your changes?
• Applies a semantic merge after each transformation.
• Each ...
@walkmod#walkmodevoxx
Can walkmod grow up?
• Creating new plugins and deploying them into maven
• The whole architecture i...
@YourTwitterHandle#DVXFR14{session hashtag} @walkmod#walkmodevoxx
Follow your
dreams!
@walkmod#walkmodevoxx
Thanks / Creative Commons
•Presentation Template — Guillaume LaForge
•The Queen — A prestigious heri...
Devoxx UK quickie talk about walkmod
Upcoming SlideShare
Loading in...5
×

Devoxx UK quickie talk about walkmod

675

Published on

Devoxx UK quickie talk about walkmod, an open source tool to apply and share coding conventions

Published in: Software, Technology
0 Comments
3 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
675
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
6
Comments
0
Likes
3
Embeds 0
No embeds

No notes for slide

Devoxx UK quickie talk about walkmod

  1. 1. @walkmod#walkmodevoxx walkmod an open source tool to apply coding conventions Raquel Pau @raquelpau www.walkmod.com
  2. 2. @walkmod#walkmodevoxx A bit of me • 7 years working with Java • Team leader in the research group DAMA-UPC • Experience in Social Network Analysis, Deduplication algorithms & recommendation engines • Research publications about software engineering • Currently involved in CoherentPaaS (EU project)
  3. 3. @walkmod#walkmodevoxx Developers principle DRYdon’t repeat yourself
  4. 4. @walkmod#walkmodevoxx Coding conventions “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 • Define rules to accomplish DRY and make code readable • Are partially supported by IDEs & Text editors
  5. 5. @walkmod#walkmodevoxx ... shall we dream again? yes! walkmod • Tool to apply coding conventions • Extensible tool by plugins (DIY) • Respects your code changes • Works with Java 8 code • Open source + free
  6. 6. @YourTwitterHandle@walkmod#walkmodevoxx Demo
  7. 7. @walkmod#walkmodevoxx How walkmod works? •Most code conventions can be automatically assured using code transformations. Types: •Visitors (Visitor pattern): an straight-way java transformation •Scripts: Polyglot inline transformations •Template: DYSWYG transformations
  8. 8. @walkmod#walkmodevoxx public class HelloVisitor extends VoidVisitor<VisitorContext>{ ... @Overwrite public void visit(MethodDeclaration md, VisitorContext ctx){ //TODO } @Overwrite public void visit(FieldDeclaration fd, VisitorContext ctx){ //TODO } ... } Visitor Example
  9. 9. @walkmod#walkmodevoxx import org.walkmod.javalang.ast.body.ModifierSet; import java.lang.reflect.Modifier; import org.walkmod.javalang.ast.body.FieldDeclaration; for(type in node.types){!   def fields = type.members.findAll({it instanceof FieldDeclaration});   for (field in fields){     int modifiers = ModifierSet.addModifier(field.modifiers, Modifier.PRIVATE);     modifiers = ModifierSet.removeModifier(modifiers, Modifier.PROTECTED);     modifiers = ModifierSet.removeModifier(modifiers, Modifier.PUBLIC);     field.setModifiers(modifiers);   } } Script Example (Groovy)
  10. 10. @walkmod#walkmodevoxx package ${query.resolve("root.package.name")}; import javax.persistence.Id; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; public class ${query.resolve("type.name")} { ! @Id ! @GeneratedValue(strategy = GenerationType.SEQUENCE) ! Integer id; ! @Override ! public boolean equals(Object o) { ! ! if (o instanceof ${query.resolve("type.name")}) { ! ! ! return id.equals(((${query.resolve("type.name")}) o).id); ! ! } ! ! return false; ! } } Template Example (Groovy)
  11. 11. @walkmod#walkmodevoxx How does walkmod respect your changes? • Applies a semantic merge after each transformation. • Each source code element (e.g. methods, fields, statements...) has an specific merge policy. • Liberates code transformations from change-management responsibility.
  12. 12. @walkmod#walkmodevoxx Can walkmod grow up? • Creating new plugins and deploying them into maven • The whole architecture is extensible and configurable. • Plugins are loaded in runtime before applying transformations.
  13. 13. @YourTwitterHandle#DVXFR14{session hashtag} @walkmod#walkmodevoxx Follow your dreams!
  14. 14. @walkmod#walkmodevoxx Thanks / Creative Commons •Presentation Template — Guillaume LaForge •The Queen — A prestigious heritage with some inspiration from The Sex Pistols and funny Devoxxians •Girl with a Balloon & Follow your dreams — Banksy •Tube — Michael Keen
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×