Lecture 7 - September 17th
, 2007
- I returned the graded binary search
programs that you all did for assignment #2 and we discussed them in great
detail.
- jGrasp is an editor not a compiler - we are
using the gcc or gnat compiler
- we discussed the importance of the
heading which must be on all submitted work.
- we discussed the need for descriptions
of purpose, input and output on our test programs and spec bodies.
- we discussed the need for purpose,
preconditions and post conditions on all specifications
- we discussed NOT using a tab when
typing in comments
- we discussed the constraint_error
and what causes it.
i.
we saw
that if a constraint_error occurs, that even if it is
handled the loop executes the specified number of times printing out the error
message produced by the exception handler each time the loop is executed
- we saw the use of an exit statement
to exit a loop after an error is handled
- we discussed writing additional
output statement when we are not sure what is causing an error
- we discussed what happens when a data_error occurs.
i.
when
using a for loop, the erroneous data does not go into the specified array
location
- we wrote a put_list
procedure to see what was in the array location after the data_error was handled
- we learned that no memory location is ever
empty and that if the value stored in the location referred to can be
interpreted as a value of the required type, whatever is there is
printed.
- we remembered that Ada is not
case sensitive.
- We then wrote the spec and the spec
body for a sequential search using the bin_search.ads
and bin_search.adb as a model
- we discussed the importance of
referring to code examples for guidance in writing new procedures
- we changed the pre-condition to
reflect that when doing a sequential search the data does not have to be
sorted in ascending order
- we discussed writing comments when we
are not sure what a statement does and modifying to indicate what the
statement does once we determine that
- we discussed where to find out how to
write a while loop
i.
look
on salmon sheet
ii.
look
on previous programs
iii.
look
in text
iv.
look
in online Ada 95 Language reference manual