473,473 Members | 1,709 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Flexible class architecture question

I need some architecture help. Our app is similar between clients, but
every client has specific needs that can require us to change anything.
I'll concentrate on one class below, but potentially any number of
methods, fields, additional classes, or anything could need to be
changed for a client.

With two clients, one way to implement this would be:

default/Biz.dll
public class CustomerBase // with default implementation

client1/Biz.dll
public class Customer : CustomerBase // with modifications

client2/Biz.dll
public class Customer : CustomerBase // with modifications

The two client dll's would reference the default dll and we would
instantiate the client's version via a factory.

Various issues come up with this implementation:

1. The client dll's have to include Customer implentations (even if
empty). Lots of repetition between clients. Also, if I add a new
class in CustomerBase I have to modify every client dll.
2. What happens when two clients share the same, but different from the
Base, logic. Here it would be a copy and paste and will exist in two
places. Not good.

There's other issues and I would imagine maintainability would spiral
out of control as new clients are added.

A possible improvement I've thought about (kind of a dynamic class
loading factory):

Have Customer defined in all dll's (no CustomerBase). Configure a
hierarchy of dll's for each client (i.e. look in client1 first, then
look in default). Dynamically make the class at run-time based on the
config. Problem 1 above is solved since if no implementation is there
it will just move to the next dll on the list. Problem 2 could be
solved by adding more levels to the hierarchy. Of course,
implementation and going against OOP could be problematic.

To implement it I was thinking:
- Make the class using reflection and the Builder classes (TypeBuilder,
etc.) based on the contents of the dll's in the config.
- Wrap a dynamic proxy (something like
http://www.castleproject.org/index.php/DynamicProxy) around the methods
in the default implementation and override it's implementation
according to the config when called.
- Similar to above, but use full AOP to implement (AspectSharp, etc.).
- Some kind of partical classes implementation over multiple dll's (not
sure if it's possible, and we might have to use .NET v1.1 anyway).

Anybody have thoughts on how best to design this? In short, we want to
flexibly override, add, and refactor anything from the default
implementation; and be able to deploy any dll independently.

Are there any good sample apps that shine in this regard?

Thanks for any help,
feech

Nov 17 '05 #1
4 1469
feech,

See inline:
1. The client dll's have to include Customer implentations (even if
empty). Lots of repetition between clients. Also, if I add a new
class in CustomerBase I have to modify every client dll.
This isn't necessarily true. Why not just have a Customer class as a
base with virtual methods that can be overriden? This way, you can provide
a base implementation, and yet, you can specialize what is needed for each
client's implementation.
2. What happens when two clients share the same, but different from the
Base, logic. Here it would be a copy and paste and will exist in two
places. Not good.
Again, you can bake this into the base class. However, if you mean that
you have logic that is shared between two custom implementations, then I
would implement that logic in another external assembly, and create
instances of those classes in each of the custom implementations.

Honestly, don't even bother with the AOP approach. I can't imagine that
what you are doing is so complex that it warrants such an approach. Using
simple polymorphism will work just fine here.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

There's other issues and I would imagine maintainability would spiral
out of control as new clients are added.

A possible improvement I've thought about (kind of a dynamic class
loading factory):

Have Customer defined in all dll's (no CustomerBase). Configure a
hierarchy of dll's for each client (i.e. look in client1 first, then
look in default). Dynamically make the class at run-time based on the
config. Problem 1 above is solved since if no implementation is there
it will just move to the next dll on the list. Problem 2 could be
solved by adding more levels to the hierarchy. Of course,
implementation and going against OOP could be problematic.

To implement it I was thinking:
- Make the class using reflection and the Builder classes (TypeBuilder,
etc.) based on the contents of the dll's in the config.
- Wrap a dynamic proxy (something like
http://www.castleproject.org/index.php/DynamicProxy) around the methods
in the default implementation and override it's implementation
according to the config when called.
- Similar to above, but use full AOP to implement (AspectSharp, etc.).
- Some kind of partical classes implementation over multiple dll's (not
sure if it's possible, and we might have to use .NET v1.1 anyway).

Anybody have thoughts on how best to design this? In short, we want to
flexibly override, add, and refactor anything from the default
implementation; and be able to deploy any dll independently.

Are there any good sample apps that shine in this regard?

Thanks for any help,
feech

Nov 17 '05 #2
See inline:

Nicholas Paldino [.NET/C# MVP] wrote:
1. The client dll's have to include Customer implentations (even if
empty). Lots of repetition between clients. Also, if I add a new
class in CustomerBase I have to modify every client dll.
This isn't necessarily true. Why not just have a Customer class as a
base with virtual methods that can be overriden? This way, you can provide
a base implementation, and yet, you can specialize what is needed for each
client's implementation.


Not sure I'm getting this. The client assembly will have to have a
blank implementation even if all the base methods are virtual (i.e.
public class Customer : CustomerBase {} ). So, when I add an Order
class I'll need to modify the client assembly to add the stub even if
it uses the default implementation, right?
2. What happens when two clients share the same, but different from the
Base, logic. Here it would be a copy and paste and will exist in two
places. Not good.


Again, you can bake this into the base class. However, if you mean that
you have logic that is shared between two custom implementations, then I
would implement that logic in another external assembly, and create
instances of those classes in each of the custom implementations.


Ok. I like that approach. Cool.
Honestly, don't even bother with the AOP approach. I can't imagine that
what you are doing is so complex that it warrants such an approach. Using
simple polymorphism will work just fine here.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com


Nov 17 '05 #3
Ok, I see what you are saying. However, if you are concerned with
copying:

public class Customer : CustomerBase {}

Between different implementations, then I would say you have a bigger
problem on your hands =)

Of course, I don't see why you have to do this at all. Like you stated
in your last email, just have your class factory return an instance of
CustomerBase and use that. You aren't required to make CustomerBase
abstract.

Personally, I prefer the overhead of the declaration so I can just new
up my class, and get a type-specific instance as well, but that's just me.

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

<d0*******@sneakemail.com> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
See inline:

Nicholas Paldino [.NET/C# MVP] wrote:
> 1. The client dll's have to include Customer implentations (even if
> empty). Lots of repetition between clients. Also, if I add a new
> class in CustomerBase I have to modify every client dll.


This isn't necessarily true. Why not just have a Customer class as a
base with virtual methods that can be overriden? This way, you can
provide
a base implementation, and yet, you can specialize what is needed for
each
client's implementation.


Not sure I'm getting this. The client assembly will have to have a
blank implementation even if all the base methods are virtual (i.e.
public class Customer : CustomerBase {} ). So, when I add an Order
class I'll need to modify the client assembly to add the stub even if
it uses the default implementation, right?
> 2. What happens when two clients share the same, but different from the
> Base, logic. Here it would be a copy and paste and will exist in two
> places. Not good.


Again, you can bake this into the base class. However, if you mean
that
you have logic that is shared between two custom implementations, then I
would implement that logic in another external assembly, and create
instances of those classes in each of the custom implementations.


Ok. I like that approach. Cool.
Honestly, don't even bother with the AOP approach. I can't imagine
that
what you are doing is so complex that it warrants such an approach.
Using
simple polymorphism will work just fine here.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

Nov 17 '05 #4
Thanks very much for your help.

The client I'm working with has this crazy app with lots of intricate
biz logic and everything is configurable between clients. They hired
us to straighten things out and I just want to make sure we don't end
up where they already were. They started with something like we're
talking about here and have now copy & pasted themselves into
unmaintainability. I think it's more of a training issue with some of
them. We'll get it right one way or another.

Nov 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Todd Johnson | last post by:
Ok, say I have a class MyClass and an __init__(self, a, b) Say that a and b are required to be integers for example. So my init looks like: __init__(self, a, b): try: self.one = int(a)...
6
by: Sebastian Kemi | last post by:
How should a write a class to a file? Would this example work: object *myobject = 0; tfile.write(reinterpret_cast<char *>(myobject), sizeof(*object)); / sebek
10
by: Adam Warner | last post by:
Hi all, With this structure that records the length of an array of pointers as its first member: struct array { ptrdiff_t length; void *ptr; };
2
by: Chua Wen Ching | last post by:
Hi there, I had some doubts on creatings plugins. As most example on the internet shows how to write plugins onto a plugin host which is normally a windows form program. 1) Can i replace...
6
by: rodchar | last post by:
Hey all, I'm trying to understand Master/Detail concepts in VB.NET. If I do a data adapter fill for both customer and orders from Northwind where should that dataset live? What client is...
2
by: Chris Puncher | last post by:
Hi. I have a RCW class that was generated by the VS.NET2003 IDE when I added a COM dll reference to my project. This all works fine when I call methods on it. My initial problem is that in...
13
by: rrs.matrix | last post by:
hi i have to detect the type of CPU. whether it is 32-bit or 64-bit.. how can this be done.. can anyone please help me.. thanks.
5
by: Joseph Geretz | last post by:
Of course, I can store a C# class instance to the Server Cache (this.Context.Cache). I've tried it. My question is, will this destroy the scalability of my application? My background is VB6....
55
by: tonytech08 | last post by:
How valuable is it that class objects behave like built-in types? I appears that the whole "constructor doesn't return a value because they are called by the compiler" thing is to enable...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.