Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
.NET Complaints
Message
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Titre:
.NET Complaints
Divers
Thread ID:
00692485
Message ID:
00692485
Vues:
56
This is just me venting, rather than asking any real question (unless someone has any easier way to do any of this)....

Why on earth are a lot of the .NET base classes marked as "sealed"? There is a bunch of annoying behavior in these classes that I'd like to fix, but there isn't any easy way to do it. They've got inheritance but they won't let me use it. Instead, I'd have to create an entire wrapper for the dang class. Whose stupid idea was that?

For example, the OleDbDataReader class. Every method requires the ordinal value instead of the field name. Yeah, it's a real smart move to force us to be bound to the field order. Instead, you can write code like:
// Assume dbReader is of type: System.Data.OleDb.OleDbDataReader

int numSomething = dbReader.GetInt32(dbReader.GetOrdinal("iNumSomething"));
string myField = dbReader.GetString(dbReader.GetOrdinal("cMyField"));

// It could be written as the following, which is a little better, but not by
// much since it forces me to deal with strings differently than other data types.

string myField = dbReader["cMyField"].ToString();
Now, if I could inherit from the OleDbDataReader I could create overloaded methods that accepted a string instead of an int and get the behavior I'd like by wrapping the call to GetOrdinal so my code could look like:

int numSomething = dbReader.GetInt32("iNumSomething");

(or even just enhance GetValue() instead)

They've also got an method called Values(). I could almost use this as a replacement in places where I'd have used SCATTER in VFP. Except, it requires me to create an array ahead of time (and know the size of it), and again, requires me to know the original field order to do anything useful with it. So it'd be nice to add a new method to this class that returns a name/value collection instead, BUT I CAN'T INHERIT FROM THIS CLASS. Arg....There's a bunch of other things just in this one class, but I'll spare you the details.

Again, I understand that I can work around all this, wrap the objects, create a library that does some of this, etc., but a lot of this behavior should be integral to the object, and I think it belongs there, but they've made it very difficult to do that; this stuff is a lot more difficult that it should (or could) be.

OK, enough for now. I (think) I feel a little better. ;-)
-Paul

RCS Solutions, Inc.
Blog
Twitter
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform