Hi,
I think you raise too many questions for me to easily answer all of them in a single post. I recommend dropping in on a lab next week, and discussing them with the teaching staff then.
Briefly, however: the documented behaviour of a method or class is the best starting point for
coming up with partitions.
But there is nothing wrong with making use of other knowledge, such as
- Are there any special cases which might be particularly prone to programmer error?
- Based on reasonable inferences about how a class is likely implemented, could the
state it ends up in (or starts in) be considered a special case?
If you make use of that knowledge, you might end up with slightly more
partitions. Does that seem like a bad thing, to you? Unless the number of
partitions is truly excessive, I can't see the harm, myself.
For many data structures – arrays, trees, stacks, heaps, etc. – if your code
works for a structure of at least size 2, then it'll work for all sizes above
that as well. But often, data structures of size 1 and 0 are special cases, and
if programmers do make mistakes, it's likely to be for one of those sizes.
If in this instance you think 1 isn't likely to be a special case, that's fine.
Cheers
Arran
ANONYMOUS wrote:
Hi Arran,
I'm unable to attend the labs this week so posting here. I wanted to ask about the stack class in lab 3.
"Some possible characteristics:
Does the array have zero elements in it, or one, or more?
(This partitions the domain into 3.)"
I'm a little uncertain about partitioning this as 0, 1 or more elements. Isn't having 1 element or more kinda the same partition as it doesn't change how the function would behave? Both would take remove the top element and return it.
The difference is only in the output where 1 element would result in an empty array afterwards, while having more elements results in the object state having at least 1 element left.
The input partition here feels a little grey to me as the partition isn't testing any different functionality here. I wanted to ask in such cases where the partition is a little grey, how do we go about deciding if something is a partition or not, such as in this case.
Is it appropriate to base the partition on if the output object state results in a special case (empty array or still having at least 1 element), or should it be more based on the functionality of the method itself and if it would react differently (0 elements or >= 1 element resulting in 2 partitions).
Thanks