![]() Welcome! and rules Joel on Software |
User-Defined Class Loaders? I've just been reading about user-defined class loaders in Java. Does .Net have this facility?
John Topley
No. When asked why Microsoft sites security concerns.
Fred Flintstone
I've written Java class loaders, and I've had to deal w/ the effects of class loaders and how they're used in various Java-based app servers. When they're used well, they are nice. But more often that not, they get in the way of what would otherwise be normal app-development expectations.
Donnie Hale
Thanks. Java class loaders can also be used for dynamic extension, does .NET allow anything similar?
John Topley
.NET can load new types at runtime using methods of the Assembly object. I don't know enough about java to know whether that's an equivalent to dynamic loading or not. What does java dynamic loading do?
Mike Gunderloy
From http://www.artima.com/designtechniques/dynaext.html
John Topley
.Net can do the same. You use the Assembly.Load or Assembly.LoadFrom method to load a type. You can examine the type to see what properties/ methods/ interfaces, etc. that it supports, then use those members.
Fred Flintstone
One place I've used this in .NET is with a pluggable archictecture - a program that allowed many different "sensors" to be plugged in to an overall framework. An XML configuration file specifies the sensors to load, then the code uses Assembly.LoadFrom to get the types into the AppDomain. Works fine.
Mike Gunderloy
Replying to "Mr. Flintstone" above (cute) - there are two ways to go w/ dynamic loading. You can load types dynamically which implement already-known interfaces. You can then invoke instances of those types via those known interfaces. So there's some compile-time safety in that situation, and you risk getting cast exceptions at runtime if the dynamically loaded type doesn't support the expected interface.
Donnie Hale
I have dynamically loaded types (in order to implement an 'add-ins' object model), but these types all inherited from one known interface or another.
Fred Flintstone
Expanding on "generic object-relational mapping layers"... By way of background, I'll state that I have a strong penchant for certain design patterns in distributed apps. Martin Fowler had an excellent site up on enterprise patterns, but it's down now since the book is out. Also, I strongly believe that apps should take as much advantage of the features of relational DBs as possible. Many O-O advocates focus so much on modelling the objects that the data layer is neglected. Correspondingly, most of the O-R mapping libraries I've come across want to base the DB schema on the object model and, in fact, generate schema creation code from the object model. I'd much rather fully define the data model, including constraints and everything, i.e. full DRI, as much of that can't be inferred/generated from the object model.
Donnie Hale
|