Line: 1 to 1 | ||||||||
---|---|---|---|---|---|---|---|---|
Design Rules | ||||||||
Changed: | ||||||||
< < | This page is the start of a hopefully growing collection of design rules. By building this collection
of examples we will hopefully be able to form an idea of the kind/range of things that would be useful to
enforce as design rules as well as how we would like to express them in our domain specific language.
What are Design RulesNote: This is an attempt to provide a definition / vision on what we mean by "design rule". This is not the be all and end all. | |||||||
> > |
| |||||||
A Design Rule is a (relatively) easily verifiable rule that constrains how code is to be structured. By adhering to a design rule developers trade away some flexibility on how they write and structure code | ||||||||
Line: 21 to 15 | ||||||||
| ||||||||
Changed: | ||||||||
< < | For example, let's us considering the opening and closing of files. An interesting property we may wish to ensure ourselves of as developers is that | |||||||
> > | For example, let's consider the opening and closing of files. An interesting property we may wish to ensure ourselves of as developers is that: | |||||||
Changed: | ||||||||
< < |
| |||||||
> > |
| |||||||
Changed: | ||||||||
< < | This property is potentially very hard to verify. However, it becomes much easier to verify it if adopt the following design rule: | |||||||
> > | This property is potentially very hard to verify. However, it becomes easier to verify if the following design rule is followed: | |||||||
Changed: | ||||||||
< < |
| |||||||
> > |
| |||||||
By adopting this desing rule the developer agrees to always open and close file in manner similar to the following idiom: | ||||||||
Line: 42 to 36 | ||||||||
Note that this design rule may be overly restrictive for some situations. In such cases, the desing | ||||||||
Changed: | ||||||||
< < | rule may need to be extended to allow for certain exceptions. For these more complex cases may then chose to adopt a different design rule as an alternative.
Design Rule Catalog-- Main.kdvolder - 05 May 2005 | |||||||
> > | rule may need to be extended to allow for exceptions. For example, we could ammend the rule to allow open files to be stored in instance variables of certain objects. For these more complex cases we may then chose to adopt other, perhaps more application specific design rules to gain confidence that those files are also not left accidentally open. | |||||||