The following are simple steps to detect such violations using ConQAT:
- Add a new Architecture Analysis. Go to Project>New>Other
- Select ConQat>Architecture Specification:
- A new architecture specification file is opened. Start adding components and assign classes, packages or namespaces to it:
- Following the steps in the next screen shot to (1) Add component (2) Click on the component to open the properties window (3) Press the ‘New inclusion button’ (4) Write a pattern indicating the class or package name:
- Now, we should run the architecture analyzer to verify the dependencies and catch any violations. To do that, we will create a Run configuration. Open “Project>New> Run Config":
- Open “blocklib” you will find a long list of analysis blocks. Select the following:
- For .Net code: “ILArchitectureAnalysisChain”
- For java code: “JavaArchitectureAnalysis”
- Add the required parameters as in the next screen shot:
- exclude-dependency: to exclude the specified namespace or class pattern from analysis
- exclude-file: to exclude the specified file names from analysis
- Press the ‘Launch ConQAT analysis’ link
- Go to the architecture specification file and press the ‘Switch Editor Mode’ button as in the screenshot below:
- Browse for the ‘architecture-assessment.xml’ file under the output directory and select it. The result of the architecture analysis is displayed as in the following screenshot:
Some Tips and Tricks
- The ‘orphans view’ lists all classes which are not assigned to any component. Review this list and make sure that it does not include any classes which may impact your analysis
- You may use the ‘orphans view’ to incrementally build you architecture, as such:
- Create all you components and keep them empty
- Run the architecture analysis, you will find that all classes are orphans.
- Drag and drop classes or complete packages on to the component
- If the package is not part of your code and need to be excluded, right click on the package and ‘Copy pattern’:
- Then, you may exclude this pattern using the exclude-dependency property
- You may right click the violations and take a decision to allow them, if appropriate: