[redland-dev] C# cleanup

Dave Beckett dave.beckett at bristol.ac.uk
Wed Jul 14 14:48:00 BST 2004


On Wed, 14 Jul 2004 13:37:11 +0100, Edd Dumbill <edd at usefulinc.com> wrote:

> This patch ensures underlying nodes and statements are copied when
> needed.  It also includes a lot of cleanup, and implements IDisposable
> for all Redland classes that wrap unmanaged resources.
> 
> I've not got any huge applications to test it on, so if Cesar you can
> test it on your use cases, that'd be great.


>  14 files changed, 561 insertions(+), 175 deletions(-)

Wow, thanks a lot Edd.  It's a lot of code.  I've tried it out and
all the examples and unittests work, even better than before.  The
Dispose code looks the best way.


I've committed it with just one minor mod in documentation, some
tidying of the headers plus some changelog editing so it matches the
existing form, I've been using changelog entries like:
   (function changed): message
or
   (method(signature args)): message
or for python where multiple classes are in one file
   (Class.method changed): message

---


C# stylistically you did

-			else if ((Object)uri == null)
+			if (uri == (Uri) null)

which I probably do both ways elsewhere.  The reason I cast both of
them to null was to prevent a Uri.Equals method being called with a
null object (raises an exception) or a null parameter.  It seemed
easier to cast to Object and let Object.Equals(null, null) deal with
it.  Maybe?


A general point that somebody made for the python API recently, just
putting here as I remember it, is that in languages where it's a
common metaphor, there should really be subclasses/factories for all
the implementation classes such as storages, parsers, serializers,
queries engines so you just do x = new FooStorage() or whatever, in
your favourite language.  Then you don't need to remember the string
values for the more general contructors.

The QueryResults method returns a hash of (name, values) - I wasn't
sure if Hashtable was the right type, but you've kept it, so I guess
it is good enough.  The enumeration code that is used with that seems
pretty clunky (I previously added it to csharp/test.cs) but looks
like how it is done in C#:

  IDictionaryEnumerator enumerator = result.GetEnumerator();
  while ( enumerator.MoveNext() )
      Console.WriteLine("  {0} = {1}", enumerator.Key, enumerator.Value);

  -- my code from csharp/test.cs

You've changed QueryResults to add an IEnumerable which looks like it
should make that code simpler?

Dave



More information about the redland-dev mailing list