How tushartushar/designitejava works
Project Type and Purpose
• DesigniteJava is a standalone tool (a command-line application) for analyzing Java source code to compute object-oriented metrics and detect a variety of design and implementation smells.
• The tool uses Maven as its build system and relies on the Eclipse IDE for development.
• Its main purpose is static analysis of Java code by processing inputs (source code directories) and producing an output (report files or CSV exports).
Main Components
a. Application Entry Point:
• Main class (Designite.java) as the central controller.
b. Argument Parsing:
• A module consisting of the ArgumentParser package which includes classes like CLIArgumentParser.java, InputArgs.java, and RegularArgumentParser.java that are responsible for parsing command-line inputs.
c. Source Code Model:
• The SourceModel package which builds the internal representation of the Java source code. This includes various classes (e.g., SM_Project, SM_Package, SM_Type, SM_Method, SM_Field) representing different Java constructs.
d. Metrics Extraction:
• A dedicated module within the metrics package (e.g., MethodMetricsExtractor, TypeMetricsExtractor, and related classes) that computes metrics such as LOC, CC, NOM, WMC, etc.
e. Smell Detection:
• Comprises two submodules:
• Design Smells – Handled by classes in the smells/designSmells package (e.g., AbstractionSmellDetector, EncapsulationSmellDetector, etc.) with a DesignSmellFacade to orchestrate detection.
• Implementation Smells – Handled by the smells/implementationSmells package, for detecting issues like “Complex Method” or “Magic Number”.
• The support classes in smells/models hold representations (like CodeSmell, DesignCodeSmell) of detected smells.
f. Visitors:
• The visitors package contains classes (such as MethodControlFlowVisitor, InstanceOfVisitor, and others) used to traverse and analyze the Java source model to extract information.
g. Utilities:
• Utility classes under utils (for logging, file management, CSV exports) that support data processing and output generation.
h. Testing Infrastructure:
• Although not part of the core design, include a testing component which reflects unit/integration tests provided under the tests directory to validate analysis and detection logic.
Relationships and Data Flow
• A starting point at the “Main Application” (Designite.java), which receives command-line arguments.
• The source model is then processed by several “Visitors” which extract information required by both the “Metrics Extraction” and “Smell Detection” modules.
• Data from the SourceModel is fed into the Metrics Extractors, whose output (metrics values) may be used as input cues for smell detectors.
• The Design and Implementation Smell Detection modules work on the model (or enriched information from visitors) and yield results that are often encapsulated using the smells/models classes.
• Finally, “CSVUtils” and “FileManager” in the utilities module handle exporting and managing outputs (reports).
Architectural Patterns & Design Principles
• There’s a separation of concerns: Each main aspect of analysis (parsing, modeling, metric extraction, smell detection) resides in its own package/module.
• The use of visitors for traversing the source model highlights use of the Visitor design pattern.
• The modular approach also allows for easy extension in the future (for new smells or metrics).