Object Oriented Programming using C#

(backadmin) #1

Object Oriented Programming using C#
Case Study


We must now add these methods o our program and revise them until these tests pass.


The IncreaseCredit() method is given below...


public void IncreaseCredit(int extraCredit)
{
credit = credit + extraCredit;
}

And the DeleteClient() method is given below...


public void DeleteClient(int clientID)
{
if(clients.Remove(clientID)==false)
{
throw new
UnknownClientException(“ClientBook.DeleteClient():
unknown client ID:” + clientID);
}
}

Finally we must amend the system GUI to invoke these methods as required.


Theory suggests that TDD leads to simple code.


In this case by focusing our minds on what the IncreaseCredit() and DeleteClient() methods needs to achieve we reduce
the risk of over complicating the code. Of course we may need a range of test cases to make sure the method has all of
the essential functionality it needs.


Even if not developing our system using TDD we should define a wide ranging set of test cases for all of the classes within
the system. This will ensure that we can undertake regression testing every time we enhance or adapt the system to meet
the future and ever changing needs of the client.

Free download pdf