Two types of Documentation
INDICATIVE Documentation
Documentation that is not part of the code should always be stamped or water marked as ‘INDICATIVE’.
INDICATIVE documentation can be useful but be aware that it is then either ‘suspect bad’ or ‘useless’. This applies to photographs, retained yellow stickies and any other media that may be used.
RELIABLE Documentation
Code written to identify the user and business rules used in the system is ‘RELIABLE’ documentation.
To get ‘RELIABLE’ documentation, it must be either
- part of the code (human friendly names etc, NOT annotation) or
- Part of the automatic testing, run when a new build is made.
Use of Fitness for Regular Automatic Testing
Using a wiki based test tool likeFitNesse,
allows wide distribution and support for the documentation, development and testing of the system.
Tests that pass are coloured green, whilst test that fail are coloured red, thus not just making the results of test easily seen, but also what tests passed or failed.
Concordian is another similar system, but I have not tried it.
This is similar, with the distinct advantage, that tests can be written in advance of the code. When run, these tests are just highlighted in yellow implying that this has not yet been coded.
For both systems, classes are coded with a supporting test class, known as a ‘fixture’ that will allow the class to be tested automatically. The test data and results modify previously written wiki pages.
The wiki pages are normally built in an agreed hierarchical structure, allowing separation of the levels of testing in functional groupings, such as use cases. They generally contain
- general text descriptions outlining the test and
- tables of values that contain test data used by the automatic testing, including the expected results.
The text is INDICATIVE, but the tables are treated as part of the code and are RELIABLE.
When a new version of the system is built, the fixtures read the tables and compare the calculated result with the expected result. If they agree, the results cell in the table is coloured green. If they disagree, it is turned red. In Concordian, cells that have no fixtures are coloured yellow, where as in FitNesse they are failed with red.
The fixtures are very ‘techie’, and are the responsibility of the developers, but the nature of the tests are very human readable, and understandable by everyone from the business staff to the coders. Hence, anyone can modify the wiki text or tables. Business staff could start a new page, write some text describing some feature that they think should be tested. They could also produce tables showing the test data that they think should be used. This can then be refined by analysts, tester and coders as they see more detail on what is needed. Alternatively, a coder should create the page, and business staff, or testers, or analysts should modify the wiki bits. The project can switch between test first or code first approaches; developers will often spot tests that are needed but have been missed by the analysts. They just add them, in the spirit of agile, perhaps mentioning them at the next stand-up meeting. When the system has passed, the analysts will see the details of these extra tests in the wiki.
The whole world can see what has failed and why. Test may be spelled out at all levels; the unit tests, system tests, user acceptance tests. Test switches may allow these tests to be run a few at a time. When the system is complete, all the tests should have been run, some as regression testing and some as new tests on new features.
The Proper Use of UML
Where I differ, from several other authors, is in analysing the requirements using UML. UML lets us clearly distinguish different types of tests. This extra level of analysis, not only helps everyone to visualise the system better, but it forces the tests into well defined categories that need different types of testing. This division also identifies the level of these tests and when they are tested. It introduces very little INDICATIVE documentation, but the control on the planned tests pays easily for that.
UML, used properly, allows the analysis of the requirements into distinctive types, which have distinctive patterns for testing. I emphasise the two words above, because I also disagree strongly with the recent trend, started by Alister Cockburn, whereby use cases become INDICATIVE mini specs and class diagrams are not part of the output. To overcome the huge size of these use cases, (I have seen some over 30 pages long, instead of the optimal 3 pages.), the actual requirements are listed in yet another INDICATIVE document called the Requirements Register.
UML breaks the analysis into two parts:
1. Use Cases -
These are of primary interest to the user community. Use cases should describe WHAT interfaces to the system exist and what their protocol is. It does NOT explain how the system processes them in any way.
To judge this, 90% of the steps in the scenario should be of the form of
- One statement ‘User does’
- One response ‘System does’
A few exceptions exist:
- These two are split by another pair
- System communicates with a secondary actor
- The secondary actor responds
- The system switches to an alternative path, which itself must not be more than 4 or 5 pairs of user/system interaction. If it is larger, then it should be made a secondary use case.
- The system response is to report a failure and head towards closure of the use case.
- An ‘exception’ close the use case immediately.
A typical use case has around 9 pairs of statements in a scenario; it can have more, but you should think carefully about it as you may be describing UI rules or business rules
Use Cases come in several flavours:
1.1. Primary use cases -
They are triggered by the user when they want to do
‘One Thing, at One Time, by One Person (Actor) in one Place’
OTOT-OPOP.
1.2. Secondary Use Cases – support primary use cases
1.2a. <included> use cases. The goal of these is INCLUDED in the goal of the primary use case. They are distinguished for convenience, either to provide clarity to the user or for sharing code.
1.2b. <extended> use cases. The goal of these EXTENDS the goal of the primary use case.
Either of these can be shared and either can be optional. Confusion over what they are, arises because the greater majority of shared code is implemented as <included> use cases and the greater majortity of optional code is implemented as <extended> use cases. Using the definitions that gave them their name gives the correct definition.
Note: all user stories can be expressed as one of these types of use cases. “As an <actor> I wish to ‘do One Thing’ so that I create (or expand) some use case functionality.
Ok, after that use case is complete, it may be decided to make the secondary use case becomes part of the primary use case. That is what agile is about. Agile also applies to the analysis, and NOT just the code.
With this level of simplicity, the whole of the use case can be added to Fitnesse.
- Is the actor appropriate?
- Are the pre-conditions met?
- Are the correct triggers available?
- Do the steps follow in the correct order?
- Was the Goal, expressed as the post conditions, attained as expected.
So only the introductory use case diagrams are INDICATIVE. The whole use case has been encapsulated in a RELIABLE automatic test suite. Yet this significant test is very easily understood from the very visual wiki pages. Each of the above will be displayed as onr or may be two tables, which ‘blush’ appropriately.
The business rules have already been rigorously tested, and so only one or two of them are tested, just to confirm that such things still work in the use case.
2. Business Rules.
These are usually dictated by the business at large and are applied to the Business objects.
Check digits in validation codes,
what algorithm is used for spelling tolerant searches,
how many items can be on loan to one person at one time etc.
They are centered on one or more business objects and the user (actor) does not necessarily have knowledge of them.
Also, Use cases and Business Rules have a many-to-many relationship. Using the ‘Mini-spec approach then forces a significant test of all the business rules on every use case where they are used. Testing the Business Rules formally on their own, reduces this duplication significantly.
Again, they can be subdivided:
2.1. Class and Attribute constraints. These are mostly validation rules.
The application controller should call the class whose data is being validated. This business object may then involve other business objects as needed.
Any validation in the UI is optimisation. If should normally be checked in the business class as well, just in case there are several UIs or other access paths to the software and one of them fails to check.
2.2. Procedurre requirements. This consists of 3 parts:
2.2a Pre-condition (Includes inputs)
2.2b Process (Algorithm)
2.2c Post conditions. (Includes Output)
Where have we seen these before? Any active process has them. That includes both use cases and program procedures.
The use cases are of interest to the users, who care about what they do. These are checked in the User Acceptance Checks.
The procedures are of interest to developers and business staff who care about HOW things are done. These arte checked during the publicly interesting unit tests.
2.3. Constraints on class interactions.
Links between classes represent those that are important to this system.
Links between Business Objects represent the subset of these that are important relationships within the business perspective.
These tests can become very complex, and often need the domain (business class) diagram to understand. Without a diagram and when split up in saya Requirements Catalogue, you often just have to give up, and just ‘tick the boxes’ for each test, without understanding how they work together.
Conclusion
So now wehave two sets of requirements that are of specific interest to two groups of business staff.
1. the user requirements in the use cases. These are of interest to the user community; the bank tellers say.
2. the business requirements associated with the business objects in the domain diagram. These are of interest to the account database staff, reconciliation staff etc.
All but a few diagrams and some supporting wiki text form RELIABLE documentation that is included in the automatic testing used with every build. That is RELIABLE because the ‘fixtures’ (tests) as well as the production code are tested with every build.
The INDICATIVE documentation is nearly all supportive diagrams and secondary text. It is needed, but any errors are not critical. Text that describes a test, where the test has been altered, is often still good enough to tell you what it is about.
The RELIABLE documentation is also part of the system tests. They are the same. In normal systems, this work is done twice over. Do we need Testers? Yes, just to confirm that the wiki tables perform all the tests necessary; they normally have good experience at this aspect.
Of course the level of testing is itself dependant on the project and the risks they are prepared to take. But even for reduced testing, it pays to identfy the different types of tests. For testing military weapons, the catagorisation of the tests provides the precision that is required.
Which comes first, the test or the code? It does not really matter. If the analyst has not yet written a test, then the developer can write one. If tests produced by any method are spotted as being inadequate by a business staff member or a developer, then they can upgrade them, forcing a possible revision of the code.
The wiki allows all interested parties to see how well the system is working almost at a glance.
Apart from the addition of a strong reliance on UML, this method is very similar to the ‘Specification by Example’ approach described in his book by A Gojko (I have yet to read this) and in an article with the same name by Mark Crowther, who quotes Gojko.
http://www.cyreath.co.uk/papers/Cyreath_Specification_by_Example.pdf
Mark used Concordian to replace Fitnesse. It seems to need to have the results copied to a wiki, but has the distinct advantage that that tests that have been written for code not yet produced, are coloured yellow. In Fitnesse these test fail and so are coloured red; you can switch off the page that they are on.