M
mark.norgate
Not a problem really, just curious about other people's views...
I have written a control in ASP.NET 2.0 (derived from UserControl) for
a timesheet application that represents the entries for time charged to
a particular project for each day in the week. Now I must write two
very similar controls that represent potential projects and overheads.
There are only slight differences in appearance and function between
these two new controls I must write and the existing project control:
they use a different DataView, some of the drop downs have different
DataValueField values, and so on.
I'm wondering how best to accomplish this. Should I create a base
class, perhaps abstract, and support the various differences in
functionality using polymorphism? Or should I use generics (which I
like
) and instantiate the controls with a "service provider" class
as the type parameter that provides these services, which is tantamount
to the same thing since presumably the three service providers must be
derived from a common base class (or interface) so the controls can get
along with them.
I did read something about templated controls somewhere, but it wasn't
very well written so I abandoned the idea of trying to understand it.
Although perhaps that's what I need...
I imagine it's a case of six of one and half-a-dozen of the other,
although I'm more attracted to the latter alternative since it is
exploiting perhaps a more robust feature of the Framework and is
essentially a sort of Abstract Factory pattern implementation.
Any thoughts?
Mark
I have written a control in ASP.NET 2.0 (derived from UserControl) for
a timesheet application that represents the entries for time charged to
a particular project for each day in the week. Now I must write two
very similar controls that represent potential projects and overheads.
There are only slight differences in appearance and function between
these two new controls I must write and the existing project control:
they use a different DataView, some of the drop downs have different
DataValueField values, and so on.
I'm wondering how best to accomplish this. Should I create a base
class, perhaps abstract, and support the various differences in
functionality using polymorphism? Or should I use generics (which I
like

as the type parameter that provides these services, which is tantamount
to the same thing since presumably the three service providers must be
derived from a common base class (or interface) so the controls can get
along with them.
I did read something about templated controls somewhere, but it wasn't
very well written so I abandoned the idea of trying to understand it.
Although perhaps that's what I need...
I imagine it's a case of six of one and half-a-dozen of the other,
although I'm more attracted to the latter alternative since it is
exploiting perhaps a more robust feature of the Framework and is
essentially a sort of Abstract Factory pattern implementation.
Any thoughts?
Mark