Ok, Test Driven iPhone Development. First off, I am not doing it, yet. Do I want to? Yes. But how?
What is Test Driven Development (TDD)? Well you can go wiki it, but in general it comes down to "write tests first, write code second, when tests pass, code is done, rinse and repeat" until project is complete.
Do I have experience with TDD? Yes, I have used utlPLSQL to perform TDD during the development of a Data Warehouse PL/SQL back-end API for a php written front-end to said Data Warehouse. I've also used CppUnit after the fact on an existing code-base.
As well, I am currently working on putting CppUnit into place for a new project at work. The good, this will be for a system we will be refactoring from Ada into C++. The bad, I'll admit it, I was a bad programmer and I extended CppUnit so that I could pass a void * into the TestFixture::setUp routine (that run's before each test case) so that I could run the tests inside a client that has a lot of setup which includes the ability to override the execution loop. That execution loop is where I put the test cases, but I had to get the pointers created during setup of the app into the test code so I could use their callbacks.
Needless to say, I feel embrassed I had to extend the code with what amounts to a blank check for programmers using the "extended" CppUnit to pass whatever they want into the test code. Why is this bad? Well, Unit Testing in the vein of CppUnit is about testing individual classes. What I am doing is bastardizing CppUnit so I can perform unit testing of two seperate processes implementing a Proxy/Service pattern.
The great thing is that I can run both of these in the same executible and inject messages into the Service which then passes them to the Proxy which passes them up to a Client which uses the Proxy. By making the changes I have to CppUnit, I can now run a Client, Proxy, and Service in one process and run tests against the three of them at the same time. This makes coding the test cases easier than having to implement TCL (or my favorite, Perl Expect) scripts to try and run the Client (with Proxy) and Service in different processes and then build something on top of that which is easy for other devs to use.
So, all that to say, I love TDD, I want to use it all the time, but getting into it I find takes understanding the arena you are working in. Being a newbie to Objective-C, Cocoa, XCode, and the iPhone OS I am finding it hard to figure out how to get TDD working for my projects yet. That said, I can see how it would work for some simple classes, but for the Model View Controller (MVC) pattern, I am still thinking about that.
Prehaps I will login to Stack Overflow and ask that question. It would be a good one.
--Update (10 minutes later):
Ask and you shall receive. Stack Overflow led me to:
No comments:
Post a Comment