feedback3.html

来自「Data Structure Ebook」· HTML 代码 · 共 139 行

HTML
139
字号
<HTML><HEAD>
<TITLE>Data Structures and Algorithms - Assignment 3</TITLE>
</HEAD>
<BODY BGCOLOR="#ffffff">
<H1>Data Structures and Algorithms</H1>
<HR>

<CENTER><H3><FONT COLOR=red>
Feedback from assignment 3
</FONT></H3></CENTER>

<OL>
<LI><H4>Separating the classes</H4>
Many of you failed to place each class in a separate file!
<P>
This allows:
<P><OL>
<LI> separate development - once the specification is decided, you
can individually work on separate parts of the whole problem,
<P>
<LI> separate verification - each class can be verified
independently of the others.
<P>
Of course, sometimes one class depends on another, 
so complete independence can't be achieved.
However the testing strategy becomes crystal clear,
test all the classes which don't depend on any others first,
then test classes that only depend on this first group,
and so on.
</OL>
<P>
<LI><H4>Equivalence Classes</H4>
Very few of you had any decent approach to proving
individual methods of classes correct.
<P>
Some were trivial .. simply put some data in an object and
verify that you could get it back!
Such tests can be performed entirely automatically: 
the program sets the object's attributes and compares
the values returned by 'projector' functions.
By using a program for this,
you make use of the machine's ability to mechanically
compare large amounts of data <B>accurately</B>
(once the test program is correct, of course!).
<P>
Generally, there will be large number of equivalence
classes - and therefore test cases.
These can be handled in three ways:
<OL>
<P>
<LI> Use program code to generate the test data sets.
For instance you want to test 0,1,2,...,n,n+1 items
where the items are random numbers. Write a function to
generate the appropriately sized arrays of random numbers.
<P>
<LI> Use data structures to hold the tests.
For example, node labels - make an array of strings:
<PRE>
char *labels[] = { "a", "aa", "aaa", "b", "" };
#define N_LABELS	(sizeof(labels)/sizeof(char *)) 
</PRE>
Note how C allows you to put an arbitrary number of items 
in an array, using <TT>[]</TT>, and <TT>#define</TT> a
symbol which gives the number of items.
This means that as you discover a need for more tests,
they are trivially added to <TT>labels</TT> and no other
part of the program needs changing!
<P>
<LI> Put the test data in files - prepared with a text editor,
or another program. This would be a good approach for testing
the MST itself
<UL>
<LI>determine what cases need testing,
<LI>produce a number of files with the appropriate data in them,
<LI>run the program reading from each file in turn 
(give the files names like "graph1", "graph2", <I>etc</I>,
so that a program can automatically read them all!)
<I>or</I>
<LI>write a Unix shell script to run the program with
each file as input and capture the test output.
</UL>
</OL>
<P>
<LI><H4>Presenting Verification Results</H4>
The best way to do this is with a table:
<P><TABLE BORDER=1>
<TH>Class<P>
Brief description<BR>
of equivalence class</TH>
<TH ALIGN=left>Representative<BR>
<UL><LI>Value of data,
<LI>Name of test file,
<LI>Name of data set,
<LI>etc
</UL></TH>
<TH ALIGN=left>Test<BR>
<UL>
<LI>Location,
<LI>Name of proram
<LI>Name of function
</UL></TH>
<TH>Expected<BR>Result</TH>
<TH>Result</TH>
<TR>
<TD>No data</TD><TD> - </TD><TD>no_data.c</TD><TD>Assertion<BR>raised</TD>
<TD>Assertion<BR>raised</TD></TR>
<TR>
<TD>Empty data<BR>set</TD><TD> - </TD><TD>null_data.c</TD><TD>NULL<BR>return</TD>
<TD>NULL</TD></TR>
<TR>
<TD>n > max</TD><TD> 10<SUP>6</SUP> </TD><TD>large_n.c</TD><TD>Assertion<BR>raised</TD>
<TD>Assertion<BR>raised</TD></TR>
<TD>Single datum</TD><TD>data_1</TD><TD>testx.c</TD><TD>Same data<BR>returned</TD>
<TD>OK</TD></TR>
<TR><TD>2 points<BR>out of order</TD>
<TD>data_2_out</TD><TD>testx.c</TD><TD>Order<BR>reversed</TD>
<TD>OK</TD></TR>
<TD>2 points<BR>in order</TD>
<TD>data_2_in</TD><TD>testx.c</TD><TD>Order<BR>unchanged</TD>
<TD>OK</TD></TR>
</TABLE>
<P>
Some examples of the sorts of entries that could be made in
each column are shown.
<P>
You can obviously vary the columns (particularly the
second and third) to suit the style of test that you are
making.

<P>
<HR>
<A HREF="ds_ToC.html" tppabs="http://www.ee.uwa.edu.au/~plsd210/ds/ds_ToC.html">Table of Contents</A>
<HR>
<SMALL>
&copy; <A HREF=mailto:morris@ee.uwa.edu.au>John Morris</A>, 1996
</SMALL>
</BODY>
</HTML>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?