Cook Computing

Sunday Morning

February 2, 2003 Written by Charles Cook

I'm finishing off some changes to the documentation generator in XML-RPC.NET. These include some fixes and also code to handle optional members. The final step before releasing 0.8.0 is to update the FAQ.

Writing test code containing C# struct definitions I keep slipping back into C++ mode, forgetting that C# struct members are not public by default. This is irritating because the serialization code in XML-RPC.NET requires struct members to be public (this allows the code to work in Internet zone security type scenarios, e.g. for a smart client).

I can't think of anything else where I make mistakes in C#: it a very easy language to write code in. After writing a lot of C#, returning to C++ make me realize how unproductive C++ is. I wonder how many people are doing greenfield development in C++ these days?

Testing the documentation generator in XML-RPC.NET again emphasises how important it is to design for testability. I've modified the code slightly to expose the generator so that I can write a test harness which generates a html file containing the documentation for as many interfaces/classes as I want to define. The problem is that I can only inspect this manually to check the output. I should have designed the code so that much of the functionality could have been tested in NUnit. A manual inspection would still be necessary to check the presentation of the data but not to check the data itself.

I guess I need to do some refactoring. There is also duplicated code in several places which could do with some reorganization and the structure of the code in some places reflects the piecemeal development over a long period. I'm a bit wary of doing this until I've made the unit tests much more comprehensive. I've not used any of the available refactoring tools, for example C# Refractory. This provides several common refactorings such as:

  • Extract Method
  • Extract Superclass
  • Extract Interface
  • Copy Class
  • Push Up Members
  • Rename Type
  • Rename Member
  • Rename Parameter
  • Rename Local Variable

I need to do some research as to whether tools like this make a difference compared to editing the code by hand.