Welcome to CrankyGoblin.Com Sign in | Join | Help

Public Class GeoffAppleby

Inherits Microsoft.VisualBasic.MVP : Implements IBrainFart
Time is not on my side

I was redesigning some of my collection classes today. As always happens with iterative development, the vision we had of what was required when we started this project is slightly different to the end result. An outcome of this is that while all our business classes work, and quite well, there's some internal implementation issues that could be refined.

An example of this is our List object. In the first iteration, it was a class that inherited from IDictionary, making a nice, speedy, strongly typed hashtable. Many of our web methods return objects of this type. Then in the interests of making things a bit better, I stopped deriving from IDictionary, but instead used an internal hashtable as a private member. The difference was subtle, but better.

It ends up now that we don't actually need any hashtable specific accessors, so indexed lookups are not important. An array is all we need. Sometimes the simplest things are the best, after all. :)

This object does need to be serialized through the web service however, so I want to keep the classes as neat an friendly as possible, with regards to serialization. For storing all the items inside this class I see two main options: using an array from the outset, or some sort of dynamically growing thing like ArrayList.

ArrayList is nice in that I just keep adding things to the list, and it internally (and I presume in some sort of optimised manner) grows it's internal array as required. But it implements all manner of interfaces, including IList, ICollection, and a few others. From now on I really want to try to avoid serializing collections or dictionaries, so I'd like to avoid it. An plain old array is cleaner and lighter, and all i need for the sake of serialization, but I'll have to maintain growth of the array myself, in possibly not as optimised a manner as the ArrayList or other provided BCL objects are.

On top of this, I've got a reuse problem. Over the course of this application, I need to use about 5 different versions for storing different data types in its internal array/list. If write a base class that wraps all the list type stuff, I will have to declare everything as Object. If write a custom class for each type so that it can be strongly typed, then I have a maintenance issue. Yes, I could write a strong typed wrapper around a object-based list, but I still having boxing issues when its used.

I haven't decided what I'm actually going to do yet - I think I'll use a base class plus strongly typed wrapper approach for now, but we all know what I really need, right?

Generics.

Which leads me to my point (finally, I know!). I've noticed something in myself as far as new features are concerned in VS2005. When I first heard about some of the features of Whidbey, it was at Teched in 2003. I was impressed, and looking forward to it, but I knew it was a long way off. It didn't effect me right now. I was more impressed by the sneak preview they gave of Yukon.

Over the last 6 months or more, however, the phrase 'well, we can do that in whidbey' comes out of my mouth more and more often. Which led me to write a formula:


Where t is the time until Whidbey is released, and I is my impatience level.

Yes, my maths knowledge is astounding. Basically, as Whidbey gets closer, I'm getting more and more impatient.

God dammit guys, hurry up already! I need it now! :)

Listening to: brush away - alice in chains - (3:22)
Posted: Tuesday, January 18, 2005 9:17 AM by Geoff Appleby

Comments

Eric Wise said:

I'm a huge fan of collectionbase, IDictionary ended up causing problems for me just like it did for you because sorting was an issue. Walking an idictionary collection to load an arraylist just to sort is so expensive.
# January 18, 2005 7:07 PM

MattyT said:

I hear you mate! I'm hanging to be able to use C++/CLI in production code...

Although at least I can use templates in Managed C++ right now to get strongly typed containers. But realistically the syntax is just too kludgey to use and maintain, especially for a 'dead end' language.

Hurry up and bring on STL.NET and C++/CLI I say!
# January 19, 2005 12:57 AM

Geoff Appleby said:

Eric: CollectionBase is definately a pretty good option. But to send a collection through a serializer has it's own issues too. Having a hard coded requirement in the framework demaning that I implement it in a particular way makes me shy away a little.

Matty: You make me cry sometimes dude. I know I'm biased (just as many people are against VB) but STL is so damn confusing to follow as a developer that I really wonder what .net can add to it without making still just as obfuscated. :)

That said, generics do look to me like STL. It's for that reason i will only be using them minimally - in scenarios like i described above it certainly has it's use, but i'm sure many people will use them just because they can, which leads to confusion, in my mind :)
# January 19, 2005 1:50 AM

MattyT said:

The STL may be initially confusing, but when you get your head around it you realise that it's just a beautiful design.

Using other similar toolkits are just frustrating. I was horrified to see that, in .NET 1.1, we're stuck with the same crappy kind of collections that has plagued Java for years. I mean you have to cast objects to get things out of a collection! And you can, with no compile-time issue at all, stick whatever the hell you like into them! Alternatively you can reinvent the wheel and extend a collection to support your own particular type. Crap.

At least with Generics that will change somewhat. Though if you're comfortable with C++ templates you'll see them as a poor second cousin.

Anyways, I don't use STL just because I can - I use it because it's the best solution for the job. I'm willing to admit that it takes a long time to get your head around it but - IMHO - it's well worth it.

STL.NET is a real technology by the way, check out Stan Lippman's article:

http://tinyurl.com/3t3ub

# January 19, 2005 4:34 AM

An attempt at structured thought. said:

The Problem with Conforming to Standards
# January 18, 2005 10:21 PM

An attempt at structured thought. said:

She loves me, she loves me not.
# January 19, 2005 8:27 PM
Leave a Comment

(required) 

(required) 

(optional)

(required) 

To submit your comment, click on these pictures:
  • Searching Geoff
  • Geoff's foot
  • Geoff's pretty blue eyes
Gaptcha Image - No Peeking! Gaptcha Image - No Peeking! Gaptcha Image - No Peeking!
Gaptcha Image - No Peeking! Gaptcha Image - No Peeking! Gaptcha Image - No Peeking!
Gaptcha Image - No Peeking! Gaptcha Image - No Peeking! Gaptcha Image - No Peeking!
Can't recognise the people in these pictures? Look here for a quick introduction.
There's a time limit for you to get your comment submitted before this set of pictures expires. If you think it's been longer than 10 minutes, get some new pictures first (you won't lose what you've typed so far).
Get some new pictures 

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS