# Install these first Use the Cog VM version 2519 (or higher) Install graphViz version 2.26 (or higher) Install PharoV10.sources in the Applications folder (extract from 1-click image?) # To set updemo fonts (if necessary) ImageSetup new girbaLargeDemoDejaVuFonts --- # Moose demos # 1. Moose Navigation Finding still-used deprecated classes in ArgoUML 0.32 - (Already done) We use InFAMIX extractor for Java, C & C++ to parse code and save model - Open Moose Panel (World>Moose>Moose Panel) - (already done) Import the model: MSE > ArgoUML - click on model -- see basic groups - select all model classes - we want to see all deprecated methods - we detect all the classes which are annotated with @Deprecated (to apply on all class group) each isAnnotatedWith: 'Deprecated' - gives 110 classes - We consider just the classes which are still used by other classes - filter ones still used: each invokingClasses size > 0 - gives 93 classes! - where do we start refactoring? Focus on model, not UI - we give priority to the classes belong to the core (4 Classes) ('*:ui:*' match: each mooseName) not - gives 4 classes - NB: ArguUML source code not in demo, so cannot browse --- To explore meta-model: - open the Meta Browser - shows us all Moose and FAMIX entities that have Moose annotations - click on an entity in the class hierarchy, and it shows all relationships - We can explore FAMIX.ClassGroup (underneath Moose.Entity>AbstractGroup ...) - Right-click (two-finger tap) or ALT-b to browse implementation --- # 2. Class name cohesion (Demo3) Usually classes with similar names belong to same subsystem. We check if classes with similar names belong to same package. We visually cluster the classes based on the similarity of their names, and then we color each class with a unique color based on the identity of the parent namespace. - Start from All model classes '*:uml:*' match: each mooseName - 1189 classes -- remove UI ('*:ui:*' match: each mooseName) not - 279 classes -- remove anonymous classes (listeners etc) each name startsWithDigit not - 260 classes -- From group select triangle: Browse > In Mondrian Easel - we open the resulting group in Mondrian and we look at the classes as nodes view nodes: classGroup - we relate the size of the node to the class name length. view shape rectangle size: #nameLength. view nodes: classGroup. - we draw edges between classes with a similar name and we cluster them visually. view shape rectangle size: #nameLength. view nodes: classGroup. view edgesToAll: [ :class | classGroup select: [ :eachTarget | (eachTarget name pairsDistanceFrom: class name) > 0.5]]. view graphvizLayout neato. - Aside: note that the metric is defined backward, since similar names should yield a distance of 0, not 1. - We finally color them accordingly with their namespace name view shape rectangle size: #nameLength; identityFillColorOf: #namespaceScope. view nodes: classGroup. view edgesToAll: [ :class | classGroup select: [ :eachTarget | (eachTarget name pairsDistanceFrom: class name) > 0.5]]. view graphvizLayout neato. - We can see that the system is reasonably cohesive, but there are some strange outliers (like the yellow class in between the grey and black ones) * Keep Easel for next demo (minimize) # 3. Glamour (Demo4) - select ArgoUML model (first tab) in MoosePanel - Browse > In Glamour Editor - Want browser with packages on left and visualization at right - we define the columns and we show the namespaces. composer tabulator with: [:t | t column: #namespaces; column: #classes. t transmit to: #namespaces; andShow: [:a | a tree display: [:mooseModel | mooseModel allNamespaces] ]]. composer startOn: model - we refine the namespaces to show just the roots composer tabulator with: [:t | t column: #namespaces; column: #classes. t transmit to: #namespaces; andShow: [:a | a tree display: [:mooseModel | mooseModel allNamespaces select: #isRoot] ]]. composer startOn: model - We want to show also the child packages composer tabulator with: [:t | t column: #namespaces; column: #classes. t transmit to: #namespaces; andShow: [:a | a tree display: [:mooseModel | mooseModel allNamespaces select: #isRoot]; format: #name; children: #childScopes ]]. composer startOn: model - open a glamour browser on top of the model - we want to integrate the Mondrian visualization into the browser. - Copy Mondrian Easel script into Glamour script at right point! - Change classGroup to namespace classes composer tabulator with: [:t | t column: #namespaces; column: #classes. t transmit to: #namespaces; andShow: [:a | a tree display: [:mooseModel | mooseModel allNamespaces select: #isRoot ]; format: #name; children: #childScopes ]. t transmit from: #namespaces; to: #classes; andShow: [:a | a mondrian painting: [:view :namespace | view shape rectangle size: #nameLength. view nodes: namespace classes. view edgesToAll: [ :class | namespace classes select: [ :eachTarget | (eachTarget name pairsDistanceFrom: class name) > 0.5]]. view graphvizLayout neato ]] ]. composer startOn: model # 4. MooseJEECloneAnalysis Show that Moose is also a pure data analysis tool We want to use Moose as instrument for data analysis so we want to merge information about the source code with information about code clones. Want to merge data from various sources. Want to integrate code clone reports into the model. Case study: Adempiere open source CMS on SourceForge NB: We have a FAMIX model of the files and their contents, not of the OO design! - First Workspace shows a random class - Second WS shows XML report from code clone detector - go to MoosePanel - Already done: Import Adempiere - Already done: Import clones * NB: this must be done once when the image is moved to a new location! - delete the Adempiere model: Utilities>Delete - import it: Import file model from file system> (navigate to Adempiere) - import the clones: JEA Importers>Import clones from XML Report (navigate to ...clones...xml) - Moose Panel shows source model and clone reports together - Want to create an EyeSee graph to show what percentage of a class is cloned - We create a graph to compare the dimension of the clones against the dimension of the class. - Select an arbitrary clone class - In *next* tab: Browse>In EyeSee Editor - Copy/Paste script that shows size of clone in a class as bar graph | diag1 diag2 | diag1 := ESVerticalBarDiagram new identifier: [ :source | source codeClass isNil ifFalse: [ source codeClass name removeSuffix: '.java']. source codeFile isNil ifFalse: [ source codeFile name removeSuffix: '.java' ] ]; rotatedLabels: true; y: [ :source | | text | source codeClass isNil ifFalse: [text := source codeClass sourceAnchor completeText. ]. source codeFile isNil ifFalse: [text := source codeFile sourceText. ]. (text isNil not and: [text contents lineCount > 0]) ifTrue: [text contents lineCount] ifFalse: [source codeClass numberOfLinesOfCode]]; regularAxis; models: mJCCPClass sources; yAxisLabel: 'LoC'; yourself. diag2 := ESVerticalBarDiagram new y: [ :source | source endLine - source startLine ]; valueAxisLine; gapFraction: 2 / 3; preferredAxisMaxY: diag1 values max; rightYAxis; defaultColor: Color green; axisColor: Color green; yAxisLabel: 'Clone Size'; models: mJCCPClass sources; yourself. (chart compositeDiagram) add: diag1; add: diag2; yPadding: 30; height: 400; width: 500. chart interaction popupText: #yourself. - Want a Glamour browser to show where the clone is - Since we want to have the same view on all clones we integrate the graph into the model and we build browser around that graph CloneClassesBrowser openOn: MooseModel root first - IMPORTANT: the highlight it computes is based on the information in the clone report. Since the code is reformatted by the code clones tool the lines indicated in the report could be quite different from the original file lines. Anyway it is a good indicator to see in which part of the file the clone is. * Can filter: each numberOfLines > 40 (clone lines)