Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 345553
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T11:05:41+00:00 2026-05-12T11:05:41+00:00

I am wondering what’s the best way to insert customization hooks into my application.

  • 0

I am wondering what’s the best way to insert customization hooks into my application. Basically, my application is split into two assemblies: A Core assembly containing all the business logic and a UserInterface assembly containing the GUI, controller classes (I am using a deviant MVC pattern callse “Passive View”) and some helper classes. The core assembly is used by some other applications as well.

My application is used by our company to handle orders from other companies. The general process is the same for all companies, but there are small deviations here and there that are customer-specific. As of now those deviations are implemented straight into the core assembly, which smells. I want to separate those specifics, best encapsualte them into a single object per customer so I have a central object containing all customer specific details which I can put into the UserInterface assembly.

I thought about using events to achieve this. By adding some events in my core classes, my controller classes would be able to subsribe or unsubscribe methods implementing those deviations for certain customers.

I can think of two ways of doing this: Adding those bindings manually or let them being added automatically, if the deviant methods exist. I’m thinking about something like this for the latter:

foreach (Order order in form.SelectedOrders) {
    CustomerExtension customer = customerExtensions[order.Customer];

    if(Exists(customer.StatusChanging(...)) // Pseudo Code!
            OrderManager.StatusChanging += new StatusChangingEventHandler(customer.StatusChanging(...));

    order.SetStatus(newStatus);

    if(Exists(customer.StatusChanging(...)) // Pseudo Code!
            OrderManager.StatusChanging -= new StatusChangingEventHandler(customer.StatusChanging(...));
}

I guess I have to use Reflection to achieve this, but is this viable for operations that need to be done many times?

Or are there better ways to add customization hooks while leting me centralize the deviations on a customers-basis?

[EDIT] Completely revised the question.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T11:05:41+00:00Added an answer on May 12, 2026 at 11:05 am

    I think you could even do it without events (are they the structure you want?). I tried to put together something: try having a look at the code (without caring too much about the details) and let me know if you’d like me to elaborate… 🙂

    // Begin personalization assembly (one of many)-----------------------
    
    /// <summary>
    /// Here you could use an attribute to allow clean reflection
    /// </summary>
    // [CustomerSpecific("Acme")]
    public class AcmeCustomization : BaseCustomization
    {
        public override void OnStatusChanged()
        {
            base.OnStatusChanged();
            // do what you need to customize
        }
    }
    // End personalization assembly (one of them)-------------------------
    
    // Begin core assembly -----------------------------------------------
    public interface ICustomization
    {
        void OnStatusChanged();
    }
    
    /// <summary>
    /// This class is optional of course, but can be useful
    /// </summary>
    public class BaseCustomization : ICustomization
    {
        public virtual void OnStatusChanged()
        {
            // intentionally empty
        }
    }
    
    class CustomizationFactory
    {
        public ICustomization GetCustomization(string order)
        {
            // Here you could
            // - hardcode (as you did in your solution)
            // - use reflection (various ways)
            // - use an external mapping file
            // - use MEF (!)
            // and then
            // - do instance caching
            // - whatever...
    
            // I'm lazy ;-)
            return null;
        }
    }
    
    class OrderManager
    {
        private ICustomization _customization = null;
    
        public void SetStatus(string order, int status)
        {
            // Do some work
            this.OnStatusChanged();
            // Do some other work
        }
    
        protected void OnStatusChanged()
        {
            if (_customization != null)
            {
                _customization.OnStatusChanged();
            }
        }
    
        public void SetCustomization(ICustomization customization)
        {
            _customization = customization;
        }
    
        public void ClearCustomization()
        {
            _customization = null;
        }
    }
    // End core assembly -------------------------------------------------
    
    class Program
    {
        static void Main(string[] args)
        {
            CustomizationFactory factory = new CustomizationFactory();
            OrderManager manager = new OrderManager();
    
            // here I'm just pretending to have "orders"
            var orders = new string[] { 
                "abc",
                "def"
            };
    
            const int newStatus = 42;
    
            foreach (var order in orders)
            {
                manager.SetCustomization(factory.GetCustomization(order));
                manager.SetStatus(order, newStatus);
                manager.ClearCustomization();
            }
        }
    }
    

    HTH

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Wondering if there’s a plugin or best way of setting up an ActiveRecord class
Wondering what the best way to make this more efficient, perhaps with jQuery. I
Wondering why it doesn't load on one click, but on two.................................................................? <input id=btnPaymentAdd type=button
Wondering if there is any way to get the lambda expressions that result from
Wondering what is the best or most popular database client tool. Similar to Microsoft's
Wondering whether there is an efficient way to add an item to Java's ArrayList
Wondering how does an application like Process Explorer or Combo Fix detect hidden process
Wondering what would be the most efficient way to do the following. Game play.
Wondering if there is any way to build and fire an event (e.g. on
wondering what is the major difference between these two: onClick and mouseClick..

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.