Journal Articles
Browse in : |
All
> Journals
> CVu
> 124
(22)
All > Journal Columns > Professionalism (40) Any of these categories - All of these categories |
Note: when you create a new publication type, the articles module will automatically use the templates user-display-[publicationtype].xt and user-summary-[publicationtype].xt. If those templates do not exist when you try to preview or display a new article, you'll get this warning :-) Please place your own templates in themes/yourtheme/modules/articles . The templates will get the extension .xt there.
Title: Professionalism in programming Part 3
Author: Administrator
Date: 06 July 2000 13:15:38 +01:00 or Thu, 06 July 2000 13:15:38 +01:00
Summary:
Body:
Software needs documentation. Just how much documentation is a moot point. The user of a Windows office suite certainly thinks there should be more than the supplier does. As software producers by not writing documentation, we forego the chance to shout RTFM to the thick users who ask banal questions about our product. I don't think that anyone will argue with the usefulness (or necessity) of this sort of documentation.
But just as the final software product needs documentation, so do the intermediate steps in the process. This is the sort of documentation that the user will (usually) never see. These are the definitions of how the program will be designed and built. These are the software specifications.
Writing and working to specifications is a big part of Doing Things Properly. In this article we're going to investigate what sorts of specification we need, what should be in them, and why reality differs so greatly from the ideal.
Specifications are system and process documentation. There are many different types of specification that are related to the software construction process. Their scope ranges from the conception of the project to the final deliverable. They include specifications detailing exactly what the user requires (or exactly what they are going to get, if the two differ - they usually do), specifications detailing the architecture of the software solution, the interface a particular module of code has to conform to, of the design decisions relating to a particular piece of code, and more.
Specifications are formal documents that are visible to all relevant parties.
So what do specifications give us that means that we need to write them? Hopefully this is obvious, but that does not mean it is not worth cataloguing.
Specifications are a form of inter- and intra-team communication. We said in the last column that projects really do die of a lack of communication. Therefore we should use specifications as a communications medium as much as we can - but only where appropriate. Projects can just as easily die because too much time is spent writing documents, and not enough time is spent actually delivering product.
Specifications are often the intermediate 'gates' of a software development process. They form a kind of contract between two stages of the process. For example, a specification for the interface of a particular software component is written by the group of people who are scoping the functionality and environment the component should exist in - this is the analysis/design phase. In the implementation phrase the implementor of the component need only see this specification; it should be complete enough for them to write the component. In this sense the specification is a contract detailing what the systems integrator expects from the component and what the implementor needs to create. If either party deviates from the specification then they are in error.
Since errors such as these are measurable against the specification, it makes the software development process less hard, safer, accessible, and more repeatable.
- Less hard
-
You can be assured a component or product has a specification, and you know where you can find it. Tedium, legwork and confusion are reduced.
- Safer
-
If all decisions and interfaces are documented, then when people leave the company it will suffer less - the amount of information loss will be minimised, and there will be a solid base for the team's replacement member to get up to speed from. There is less information dangerously stored away in people's heads.
Specification users should make no assumptions - if something isn't documented in the specification then it should be altered to clarify the problem. Then there is no risk of two people making different assumptions - the classic reason why two separately created modules do not work together when first integrated.
- Accessible
-
New people come to the project and can understand what parts of the product do or how they work thanks to the documentation. They don't have to search for the information in a hundred different people's heads before they can get into the swing of their work.
- Repeatable
-
It has been seen time and time again that well specified projects succeed and badly specified projects fail. Companies with well defined processes that include specification are more successful. The increased communication oils the development process and makes it more reliable, reducing the risks and therefore increasing team performance.
I would (perhaps contentiously) argue that specifications become increasingly important as the size of a project increases. This is not because specifications are not important in smaller projects, but because in the larger projects there is more to loose - there is a greater number of people whose lack of co-ordination will have a greater impact of the outcome of the software development process.
As a student I remember being annoyed at being set an exercise which was practically impossible because the question was vague and could be interpreted in one of two ways, The specification for the piece of work I was set was not suitable. Very recently (as a professional) I've been annoyed because the specification of part of an embedded operating system[Bradner] was too vague, and I was not sure how to use it.
Good specifications and documentation are generally taken for granted, whereas poor specifications and documentation rapidly become loathed.
But is a poor spec better than no spec? If it's factually incorrect it definitely is not. If it's ambiguous then it's a borderline case, depending on whether the engineers are experienced enough recognise so. But a specification should really stand on its own and not be defined by its readership. If its too verbose and hides information then it may be better (in the long run) to rewrite.
There are in reality many different types of specifications. Below I list the most common ones. Naturally since we live in the real world, no one calls them by the same name. For example, a 'requirements specification' is variously called 'user requirements specification' and 'functional constraints specification' by different companies.
-
Requirements specification
The requirements are never clear. Customers can never tell you exactly what they want. There needs to be a single document that describes exactly what the item being built (be it a consumer product, a software library, or a smaller software component of a larger product) has to do.
This is the job the requirements specification. It should list in great (or at least 'appropriate', which will usually be 'great') detail exactly what the item will do and how it is expected to behave.
These requirements are usually written as a series of numbered sentences each containing a single factual piece of information. For example,
1.3.5 The user interface shall consist of a black rectangle containing the words 'Don't Panic' in a red san-serif typeface at 13pt.
Uniquely numbering each requirement allows easy referencing in subsequent documents and aids tracing a particular decision back to a single requirement.
The process by which this document is created will differ from company to company (and often from product to product).
Usually either the customer, or a representative of the customer is involved in the creation of this document. It will form part of the actual contract between the supplier and the customer (this time in the literal sense of the word). The supplier agrees to ship a product whose functionality meets that described in this specification.
This is really very necessary, otherwise when the product is shipped who will be to say whether it's of an acceptable quality? Without an agreed specification to work with the customer can just refuse to accept the product and the supplier will have spent a lot of effort to no avail[1].
-
Systems architecture specification
This often bandied about term describes the shape of the software. It encompasses things such as physical computer layout (is it distributed client/server software or a single user desktop application), software componentisation (how is it split up, which parts do we need to write, which can we buy in), concurrency issues (how many threads run at the same time), data storage (database design), and other aspects of the system's architecture.
It is important to get this right and specify it in detail before too much other work goes on, since the architecture will affect the later stages of development, both in design and implementation.
-
Functional specification
Perhaps the most relevant specification to us (as 'professional programmers'), the functional specification describes the exact functionality of a particular item. For a software component this includes an exact and unambiguous description of the public interface of the component. For us this will equate to a list of every public C, C++ or Java interface, method or function in the module's API, together with a description of how to use them.
It contains details of all external data structures and formats, and all dependencies that the component has on other components, work packages, or specifications.
This is more than a user guide to an item or piece of software. The detail implicitly describes how you can build the item. Two separate teams could read the document and go away to implement it. Although the internal implementations may differ the products they would each supply should behave identically.
This is actually exploited in practice. For example some NASA space craft employ five computers to do the job of one; four computers implement the specification for a particular calculation, running independently developed implementations. The fifth computer is used to average the results of the four calculations (or to decide whether or not one computer wildly disagrees with the others).
-
Design specification
A design specification documents the internal design of a component. It describes how a functional specification is to be implemented. The user of a component need never read this, however, the implementor will write it and a maintainer will require it. The document should be written prior to implementation (and reviewed to prevent too much possibly incorrect coding being performed). However, in practice this document is often written alongside coding.
Whenever the design specification is written, it should be kept up to date with the code.
The document contains descriptions of all internal APIs, data structures and formats.
-
Test specification
This kind of specification describes the test strategy for a particular piece of work (software component, consumer product, or whatever). It will contain a list of every test that must be performed together with their acceptance criteria and how the test will be run.
The test specification is usually derived from the item's functional specification and can be used by a test implementor to create any test code that may need writing.
Obviously each of these different types of specification contain different material. However, there are characteristics applicable to all types of specification.
-
Correct
This might seem an obvious characteristic, but it is also the most important. An incorrect specification can cause man-days (or more) of wasted effort. The number of factual inaccuracies in the specifications in your company will probably frighten you!
In order to ensure correctness, specifications should undergo a defined review process prior to release.
This also implies that the document should be kept up to date (see modifiable).
-
Unambiguous
If a part of a specification can be interpreted in more than one way then the 'specification' isn't (i.e. it is not being specific so it is not a specification!). This will cause the problem described above when two readers make different interpretations of the ambiguous information.
-
Complete
A specification should be self contained and complete, describing both itself and the item that it specifies. Note that this does not necessarily mean that it should itself contain all the information, it is perfectly acceptable to reference other relevant documents, as long as the reference is specific and will allow the reader to easily locate the document.
-
Verifiable
A specification for a software component, for example, will lead to the production of two things: (i) the software implementation (ii) the test harness that will be used to test the software. Therefore the specification must be verifiable. In practice, this largely equates to being correct, unambiguous and complete.
-
Consistent
Similar to unambiguous, the specification should not contradict itself. Again, this sounds obvious, but when a specification gets to a certain size it becomes difficult to ensure consistency holds. This becomes a particular problem when a maintainer (different from the original author) comes back to the specification to perform certain modifications - it can be very easy to alter information in one place, and not change any subsequent sections that allude to the same information.
-
Modifiable
If the specification needs updating due to factual error this should be possible. Having specification set in stone certainly prevents the problem of goalposts changing underneath you as you are programming. However, its of no use if the specification is factually incorrect.
-
Traceable
A company should have a document control procedure (akin to a source management system) in which all documents (including specifications) reside. Each revision of the specification should be logged in the repository and should be accessible (so you can discover which version of the spec you were working to a year ago, since a customer is asking you a question about a software installation a year old).
Each document should contain control information that allows you to find it in the document repository so you can check that you have the most up to date copy.
-
Useable during maintenance phrase of a project
The specification does not only stand as the contract that the implementor must honour, but also acts as documentation for the item - a maintainer should be able to read the specification for a particular piece of software, for example, and be able to immediately understand how it works or how it is used.
This also implies that the document should be kept up to date.
-
Standards compliant
A specification should be carefully written to comply with all relevant standards (for example, language definitions and company coding standards). As the document is reviewed it should be checked against this criterion.
A specification should contain at least: an introduction, a scope and purpose section, any relevant definitions and a set of references. This ensures that the document is self describing and that a reader will be able to access the information contained within easily (e.g. they will know what knowledge is prerequisite to reading).
Where appropriate a specification includes any constraints, assumptions and dependencies that are relevant to ensure that there is no ambiguity.
When writing a specification the use of language should be carefully made. Specifications are formal documents, and so must not be chatty or verbose (this tends to hide the important facts behind a wall of words). Formal documents are written in the third person, in present tense (i.e. you write must/should not will) [Bradner].
Ultimately, the specification should follow the document standards/conventions of the company. If the company does not have a standard (or some form of skeleton document) then you should worry!
Technical writing skills do not always come for free with an engineer. Some engineers are better at it than others. However, if a software engineer is not capable of documenting work that they have produced then they are a liability. Practice (followed by review) makes perfect.
The best specifications are written from the perspective of the reader, not the writer. The information is organised in such a way as to make it more comprehensible to someone new to the item, rather than in a convenient form for the writer. Writing specifications in this manner does require more work and take more time, but it's worth it if the result is simpler to understand. Blaise Pascal once wrote "I have made this letter a rather long one, only because I didn't have the leisure to make it shorter."
In the real world, decent specifications often get overlooked. Why is this?
Engineers do not write specifications for two reasons:
-
They do not know they should (or forget)
-
They consciously decide not to
If an engineer forgets to write a specification or does not know that they should be writing one then they are quite likely inexperienced. They need to be told to do so by their manager.
Programmers like to program, not write. Many programmers do not have good writing skills. Kent Beck will argue that it is not their job and the documentation is in the code and its set of tests [Beck]. Many programmers try to avoid writing specs since their technical writing skills are not that good, or they just do not like doing it.
The main reason an engineer chooses not to write a specification, though, is that they do not appreciate the value of the specification. Too often it's seen as a time wasting activity that is really not necessary. Or they think 'I'll code first, then come back to the documentation later'. Bitter experience has told us time and time again that this does not happen.
Experience has also told us that code written without any forethought (the kind of forethought writing a specification makes you perform) is worse code. It is code that is badly designed. It is code that is hard to understand. It is code that doesn't fit into the overall system properly. It is code that is hard to maintain. It is code that costs more to create and maintain than if it had been properly specified in the first place.
Having said that I can cite a recent occasion that I did not start by writing a specification for a particularly important piece of code, an interrupt service routine. I started to write the routine on Monday, the code was due to ship on Thursday. You would like to think that this kind of thing does not happen in the real world but it does. Why did this situation occur in the first place? An inadequate specification elsewhere![2]
We have seen what specifications are, some of the different sorts of specifications that exist in the programming world, why we write them, why we do not write them, and why our wrist should be slapped because of this.
If any readers would like to describe why projects they have been on have got stuck for lack of decent specification work then it would be a valuable cautionary tale to the rest of the C Vu readership.
[Bradner] S Bradner. Key words for use in RFCs to Indicate Requirement Levels. RFC 2119. From: ftp://ftp.isi.edu/in-notes/rfc2119.txt.
[1] Yes, I have seen this happen. It is a good example of the reason you do not want a specification to be ambiguous. In this kind of situation every term (for example 'alpha' and 'beta' release) need careful definition.
[2] In fairness, since I didn't have time to write a decent specification I spent a lot of time and effort designing a public API file with a great deal of documentation in the comments. When I came back to write the specification most of the work had been done already in the code documentation. This is not an ideal way to approach the problem, but it helped.
Notes:
More fields may be available via dynamicdata ..