Monday, April 18, 2011

Planning the End of the Cycle

At this time, this program has the functionality I set out to create for it. DropStickRecurse hasn't been tested yet, so that's part of the TODO list.

These are the things I want to do to consider the current version of this project done:

  • Revise tests for all the public constructors and methods, including DropStickRecurse and the value passed to the Board constructor that limits the number of sticks that can be added to a board.
  • Evaluate whether all the public methods are necessary, including test_ methods.
  • Create a different test script for each method and constructor.
  • Create a toString method that returns a human-readable display of the grid (like the display function).
  • Use preprocessor directives to compile without testing code.
  • Write a test_ method to wrap each private method for testing. Previously, I've used the test_ methods on an ad hoc basis.

So, to get started, I'm going to create a speadsheet with an entry for each public constructor or method. I can get all these by using get-member for each class:

blog> $board = new Board(60)


blog> $node = new Node(6, $board)


blog> $stick = new Stick(3)


blog> $board | get-member



TypeName: Board


Name MemberType Definition

---- ---------- ----------

addStick Method bool addStick(int location)

dropStickRecurse Method bool dropStickRecurse(int location)

Equals Method bool Equals(System.Object obj)

GetHashCode Method int GetHashCode()

getPositionValue Method bool getPositionValue(int location)

getStick Method Stick getStick(int location)

GetType Method type GetType()

moveStick Method bool moveStick(int origin, int destination)

removeStick Method bool removeStick(int location)

test_dropStick Method bool test_dropStick(int location)

test_getNode Method Node test_getNode(int loc)

test_getStick Method Stick test_getStick(int loc)

ToString Method string ToString()

Value Property System.Int32 Value {get;}




blog> $node | get-member



TypeName: Node


Name MemberType Definition

---- ---------- ----------

currentNode Method bool currentNode(int location)

doMove Method bool doMove(int origin, int destination)

Equals Method bool Equals(System.Object obj)

fall Method bool fall(System.Int32&, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 loca...

GetHashCode Method int GetHashCode()

getLocation Method int getLocation(int temp)

getNull Method Node getNull()

GetType Method type GetType()

ToString Method string ToString()





blog> $stick | get-member



TypeName: Stick


Name MemberType Definition

---- ---------- ----------

Equals Method bool Equals(System.Object obj)

GetHashCode Method int GetHashCode()

GetType Method type GetType()

ToString Method string ToString()

Location Property System.Int32 Location {get;set;}

Value Property System.Boolean Value {get;}


I'm adding a column “Wraps” for test methods that wrap private methods. There are only 4 private methods. I thought there were more, but maybe I made some of them public. While I'm making tests, I'll look for opportunites to make some things private again.

After those columns, I added three more:

  • Acceptable: Vanilla values, checked to verify that the member is working.
  • Edge Values: Values that should be acceptable, but are at the edge of the range, such as 1 and 60, in this design or 4, 5, and 11, all of which are expected to act differently, sometimes, within the grid.
  • Unacceptable: Outside the range of valid values for the member. Expected to fail.

For today, I've gone ahead and added preprocessor directives wrapping the testing code. Tomorrow, I'm going to open the test script and start down the list, placing each existing test in its own script and verifying that it satisfies the three requirements.

No comments:

Post a Comment