This post originated from an RSS feed registered with Agile Buzz
by Joe Walnes.
Original Post: OT2004 : Generic Mechanisms in Software Engingeering
Feed Title: Joe's New Jelly
Feed URL: http://joe.truemesh.com/blog/index.rdf
Feed Description: The musings of a ThoughtWorker obsessed with Agile, XP, maintainability, Java, .NET, Ruby and OpenSource. Mmm'kay?
This workshop, hosted by Simon Davies, and chums from Microsoft (with a bit of Bruce Anderson), was a thinking excercise about the pros and cons of some of the language features of C# (and conveniently also Java) including generic types, attributes and dynamic code generation.
We were given some sample scenarios to which we had to contrast the approaches of using these features in isolation and combined together, taking into account ease of development, runtime performance, flexibility, maintainability and simplicity:
* Creating a strongly typed list.
* Serializing objects to XML (a subject I'm familiar with).
* CRUD persistence of domain objects to a database.
This was quite thought provoking. While it was very easy to see the advantages of using generics to implement a strongly typed list, experimenting with all the different approaches was a fun exercise. Code generation may be less simple but offers better runtime performance.
It was fun brainstorming ideas with developers from different backgrounds and seeing which approaches appealed to them.
I was also shown the anonymous delegate feature in the next version of C#. Mmmm closures...
// usage
int totalAge = 0;
peopleFinder.All(delegate(Person person) {
totalAge += person.Age;
});
// implementation
class PersonFinder {
public delegate PersonDelegate(Person person);
public void All(PersonDelegate delegate) {
some magic iteration code {
Person person = ...;
delegate(person);
}
}
}
Now for a staticly typed language, that's a lot cleaner than I was expecting.
This is something I'm really excited about as it's the style of development I use all the time in Java, without all the syntactic cruft of anonymous inner classes. And I'm sure it'll appeal to all the Ruby/Smalltalkers out there.
Something else I learned is that (unlike Java 1.5), generic definitions are available at runtime.