473,387 Members | 1,925 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Function Delegation

We have a project that we are developing in C# and one of our biggest requirements is that this be a single application but that many of the functions be customized depending on which cost center the user belongs to. In reality, what this typically means is that the user interfaces are the same everywhere but there are some business logic that is different from cost center to cost center. As much as possible we are building switches into the code from logic that we can anticipate, but we realize from experience (this is v3 of this product) that it just isn't possible to handle all business logic through switches and some custom code will be required. So, my question is what techniques have others found work in C# for accomplishing this goal? The "core" components cannot be modified, but it is acceptable to add new custom components to the application that might override some of the functionality of those "core" components.

I'm relatively new to C# (former VB6 programmer) and from what I've found so far, it appears that using delegates may be a promising technique. The one gotcha that I've run into so far is that I can't figure out how to get a reference to a component and function at runtime to use as the delegate. What I mean is that I would like my "core" function to lookup (in a database or session variable) the file name of an assembly which holds the delegate function and then call it in place of the compiled function code. So, pseudo-code might look like:

void CoreFunc()
{
// See if there is a cost center specific delegate
if( _costCenterAssemblyName != "" )
{
call GetDelegateFunc( _costCenterAssemblyName + ".CoreFunc()" );
return;
}
// Otherwise, do what you would normally do...
...
}

Any help with how to accomplish this or suggestions of a better method would be greatly appreciated.

Thanks!!!

Ian
Nov 15 '05 #1
4 2080
Ian,
I would recommend the PlugIn Pattern coupled with the Seperated Interface
Pattern.

http://www.martinfowler.com/eaaCatalog/plugin.html
http://www.martinfowler.com/eaaCatal...Interface.html

For some thoughts on implementing the Plug In Pattern in C# see:
http://www.yoda.arachsys.com/csharp/plugin.html

Hope this helps
Jay

"R. Ian Lee" <an*******@discussions.microsoft.com> wrote in message
news:AB**********************************@microsof t.com...
We have a project that we are developing in C# and one of our biggest requirements is that this be a single application but that many of the
functions be customized depending on which cost center the user belongs to.
In reality, what this typically means is that the user interfaces are the
same everywhere but there are some business logic that is different from
cost center to cost center. As much as possible we are building switches
into the code from logic that we can anticipate, but we realize from
experience (this is v3 of this product) that it just isn't possible to
handle all business logic through switches and some custom code will be
required. So, my question is what techniques have others found work in C#
for accomplishing this goal? The "core" components cannot be modified, but
it is acceptable to add new custom components to the application that might
override some of the functionality of those "core" components.
I'm relatively new to C# (former VB6 programmer) and from what I've found so far, it appears that using delegates may be a promising technique. The
one gotcha that I've run into so far is that I can't figure out how to get a
reference to a component and function at runtime to use as the delegate.
What I mean is that I would like my "core" function to lookup (in a database
or session variable) the file name of an assembly which holds the delegate
function and then call it in place of the compiled function code. So,
pseudo-code might look like:
void CoreFunc()
{
// See if there is a cost center specific delegate
if( _costCenterAssemblyName != "" )
{
call GetDelegateFunc( _costCenterAssemblyName + ".CoreFunc()" );
return;
}
// Otherwise, do what you would normally do...
...
}

Any help with how to accomplish this or suggestions of a better method would be greatly appreciated.
Thanks!!!

Ian

Nov 15 '05 #2
Hi,

I suggest you to look into the abstract factory pattern, using it you can
use a different set of components in an easy way. Usually the abstract
factory is implemented using the Singleton pattern so you may want to take a
look at it too.

See this link:
http://www.dofactory.com/Patterns/PatternAbstract.aspx

Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"R. Ian Lee" <an*******@discussions.microsoft.com> wrote in message
news:AB**********************************@microsof t.com...
We have a project that we are developing in C# and one of our biggest requirements is that this be a single application but that many of the
functions be customized depending on which cost center the user belongs to.
In reality, what this typically means is that the user interfaces are the
same everywhere but there are some business logic that is different from
cost center to cost center. As much as possible we are building switches
into the code from logic that we can anticipate, but we realize from
experience (this is v3 of this product) that it just isn't possible to
handle all business logic through switches and some custom code will be
required. So, my question is what techniques have others found work in C#
for accomplishing this goal? The "core" components cannot be modified, but
it is acceptable to add new custom components to the application that might
override some of the functionality of those "core" components.
I'm relatively new to C# (former VB6 programmer) and from what I've found so far, it appears that using delegates may be a promising technique. The
one gotcha that I've run into so far is that I can't figure out how to get a
reference to a component and function at runtime to use as the delegate.
What I mean is that I would like my "core" function to lookup (in a database
or session variable) the file name of an assembly which holds the delegate
function and then call it in place of the compiled function code. So,
pseudo-code might look like:
void CoreFunc()
{
// See if there is a cost center specific delegate
if( _costCenterAssemblyName != "" )
{
call GetDelegateFunc( _costCenterAssemblyName + ".CoreFunc()" );
return;
}
// Otherwise, do what you would normally do...
...
}

Any help with how to accomplish this or suggestions of a better method would be greatly appreciated.
Thanks!!!

Ian

Nov 15 '05 #3
Thanks! I think this will help me accomplish what I need to accomplish.

Ian
Nov 15 '05 #4
OK, so now that I understand how to make a plug-in work there's now the question of security. What is the best way that my program can ensure that "plugin" assemblies are properly signed? Is there a global way or do I have to do this with every Reflection call

Thanks

Ian
Nov 15 '05 #5

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

Similar topics

7
by: Rene Pijlman | last post by:
Section 6.5 "What is delegation?" of the FAQ says: "Python programmers can easily implement delegation. For example, the following class implements a class that behaves like a file but converts...
3
by: Jacob | last post by:
Hello All, I am trying to serve out some content via IIS that is hosted on a remote fileserver, and am unable to get the delegation working correctly. Our setup is as follows: Local LAN...
6
by: DPfan | last post by:
Is the following so-called "delegation"? If not how to make some changes so that the F class delegates its operation to an E instance. On the other hand the following code runs without any...
3
by: Tony Johansson | last post by:
Hello! What does it mean with delegation and can you give me one example. //Tony
2
by: | last post by:
Hi, I am working on a n-tier app using remoting. I am using the VS 2005 beta 2. My server needs to access a remote resources on behalf on the connected user. I have configured my server like :...
2
by: russell.lane | last post by:
I'm building out a pretty standard n-tier web application. The stack includes application/presentation, biz logic, and data access layers on top of an SQL server back end. We want to use...
4
by: JimLad | last post by:
In advance, sorry if this is the wrong group... SQL Server 2000 SP3 on Server 2003. SQL Account and Computer both Trusted for Delegation. Given SPN. IIS 5.0 on W2000. Kerberos enabled....
6
by: Marc Castrechini | last post by:
This is a classic double hop delegation issue, however its the first time we are setting this up so we are doing something incorrectly. If we run through the IDE or using a localhost path on the...
3
by: Patrick | last post by:
Hello I have the following scenario - SQL 2005 server (serversql) - Windows 2003 with IIS (serveriis) - Windows 2003 ADS (serverads) I want to connect to an intranet application using NTML...
5
by: =?Utf-8?B?TWF5ZXI=?= | last post by:
Hi, I'm using two form classes and I would like all methods of the second class (the child class) to be managed by the first class (the main class). Is delegation the best solution for me? If so,...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.