Extensibility Thoughts

Topics: Building and extending application blocks, Validation Application Block
Sep 13, 2007 at 12:19 PM
Just my 2 cents on extensibility and what is made available to us, developers.

It seems like I keep fighting against internal and protected stuff where I can find plenty of scenarios where those things were needed when creating extensions to the blocks.

Last thing I tried was creating a PathValidator for the EntLibContrib project. This validator would allow an object available through navigation of a complex path to be validated.

public class A { public B B; }
public class B { public D C() { return d; } }
public class D { public DateTime E { get { return e; } } }

Hence, specifying a PathValidator with the path "B.C().E" and passing an instance of A, it would effectively be E that would end up being validated.

So first thing I figure out, I need to use Reflection based Value Access. Bummer, FieldValueAccess, PropertyValueAccess, MethodValueAccess, ReflectionMemberValueAccessBuilder and ValidationReflectionHelper are all internal sealed class.

Let's say I copy/paste source code, then my PathValidator delegates the job of validating the endpoint of the path to a pre-configured validator. However, it must call DoValidate(...), overriding the key being validated so it can specify the whole path, not just the last part of the path. The same way ValueAccessValidator calls DoValidate when it delegates the job after getting the value to validate. However, DoValidate is protected internal.

So my question is, were those classes/methods restricted visibility a deliberate choice? What pushes this kind of decision? Could it be changed?

Framework designing is a difficult task. I hope to see a 3.x release with more visibility.
Sep 13, 2007 at 10:59 PM
Edited Sep 13, 2007 at 11:00 PM
Salut François,

I had the same issue a few weeks ago.

I think internal is overused in EntLib for non-critical classes and methods.

A class library is, after all, a class library. It should be meant to be used and extended.

Sep 14, 2007 at 2:18 AM
Yeah, I was actually thinking of this post as well when I wrote the post. Should've referenced it.
Sep 26, 2007 at 4:00 PM

Well, still no feedback on this :-(