Exercise 1.3: Defining an architectural control rule

This exercise assumes you have completed Exercise 1.1: Importing the required resources. In Exercise 1.3 you read a user scenario first. Then you assume the role of the software architect described in the user scenario and use the project you imported in Exercise 1.1 to complete the exercise.



User scenario

To prevent extraneous dependencies, the architect wants to put a safeguard in place to ensure that none are introduced into the application. To do this, he creates a rule from a supplied wizard. The rule is to alert him if the utility package becomes dependent on the application package.

After creating the rule, the architect runs a code review by applying it to a code base. The findings will show any extraneous dependencies in the application.



Exercise

In this exercise you perform the following tasks:

  1. Define a rule based on a supplied wizard.
  2. Verify that your user-defined rule is added to the Structural Analysis code review.
  3. Run the Structural Analysis code review.
  4. View the code review findings that do not adhere to the criteria of your rule.


Defining a rule

To define an architectural control rule based on a supplied wizard:

  1. On the toolbar in the Code Review view click the Manage Rules icon, .
  2. Code Review view

  3. In the Preferences window click New rule. The New Code Review Rule wizard opens.
  4. The New Code Review Rule wizard, as shown in the next screen capture, takes you through a few steps to define your own rule. In this exercise, you will design an architectural control rule to alert you if a dependency between two components is introduced.

  5. In the Architectural Control list of rules, click Component [dependency] introduced. Notice that when you select this choice, the text below the list tells you to use this template to disallow a dependency between two components. Click Next.
  6. Wizard, select rule template

  7. Under Basic properties, accept the defaults that put the rule in the structural analysis category, with a problem severity level.
  8. Wizard, specify properties to complete rule

  9. Under Specific properties, specify the independent and dependent components for the rule:
  10. Click Finish.


Seeing your rule added to a code review

  1. After you define a rule, the Preferences window appears. In the Select Code Review list, click Complete Code Review if it is not already the selected code review. This shows all code review categories.
  2. Expand the Structural Analysis folder to see the rule you just created.
  3. Click the rule to see the properties you set for it, as shown in the following screen capture:
  4. Preferences window with new rule



Selecting a code review that applies your rule only

To run a code review for your rule only, clear all folders in the list except for the Structural Analysis folder, as shown in the previous screen capture. Click OK.



Selecting a code base to review

To select the workspace as the code base to review:



Running the code review

Once you select the code base to review, the code review runs. You can track its status by checking the progress bar in the lower-right corner of the view.



Viewing the code review findings

When the code review is finished, the findings are shown in the Code Review view, as shown in the following screen capture. Below the tab the statistics line summarizes the review.

Code Review findings, 1 collapsed folder

  1. Expand the Structural Analysis folder to see the findings in it.
  2. Code Review view, showing source code for selected finding

  3. Double-click the third finding to see the source code for it in the editor, as shown in the following screen capture:
  4. Code Review view, showing source code for selected finding



You have completed Exercise 1.3: Defining an architectural control rule.



Leveraging the power of user-defined rules

By creating your own rules, you put custom safeguards in place to monitor the implementation of your design. You can take the following measures:



Wrapping up Exercise 1.3

You have completed Exercise 2: Defining an architectural control rule. In it you performed the following tasks:

  1. Defined a rule based on a supplied wizard.
  2. Verified that your user-defined rule was added to the Structural Analysis code review.
  3. Ran the Structural Analysis code review.
  4. Viewed the code review findings that do not adhere to the criteria of your rule.

Now you are ready to begin Exercise 1.4: Resolving a structural problem.



Feedback
(C) Copyright IBM Corporation 2004, 2005. All Rights Reserved.