Login

Username

Password





Register   Reset password

This is a read-only archive of the forum.

# swilliam 2/28/2007 3:47 AM
Dear All

Would it be a good idea to create, say, IModuleControl and IModule? That way you wouldn't have to subclass BaseModuleControl and Module Base to create modules. You would be able to reuse existing code that doesn't extend these classes. Creating a ModuleControl otherwise requires creating a dummy ModuleControl and ASCX and dynamically loading the actual class by filename (LoadControl(fileName)) because otherwise you get a cast exception from Cuyahoga.

Many thanks

Simon
# martijnb 2/28/2007 2:30 PM
It's not bad at all to have interfaces for this (just good practice, I think), but can I'm not sure I can follow your reasoning. Could you please explain it with a llittle use case or something?
# swilliam 2/28/2007 6:36 PM
Martijn

Let's presume you have some exising code you can't change that would make a good module. You can't change the base class, but you *can* extend it, implement an interface and then it would become useable. If you're starting from scratch, it doesn't make a difference, but if you have a DLL or are not allowed to modify the source code, you will have problems. The key point is you can implement *many* interfaces, but just one class. If your base class isn't BaseModuleControl or ModuleBase, there is no way you can extend these classes.

Many thanks

Simon
# martijnb 3/2/2007 6:34 AM
Thanks for explaining. I see your point. It's all about extensibility and flexibility and interfaces instead of (abstract) base classes add a lot to that.
Lately, I've also seen myself extracting interfaces from base classes where in the past, I never thought that this made sense :).
# swilliam 3/2/2007 7:25 AM
To quote Design Patterns (GOF):

Program to an interface, not an implementation

and

Favour object composition over class inheritance

Not quite so easy in practice, but using Windsor should make programming services as interfaces much easier.

Cheers

Simon