I'm sorry if the title is a little hard to get.

I've never built an entire big software my self, just some small apps in my free time, i was more familiar with the do-what-my-boss-told-me things. And our approach is a little amateur, obsolete also (Foxpro 8.0 and MS SQL 2000).

Now i've started to work at another company and been assigned to build a software in C#.Net, but the problem is i'm not sure with the program's architecture

My problem is, we're building a software. But we have variety of clients, and for example, we have a CalculateCostOfProduct funtion, and it might be different for each client.

Says for party A, the function is :

function CalculateCostOfProduct()
return 5; 

for party B :

function CalculateCostOfProduct()
return 10; 


And there should be extra modules for specific needs also ! So there will be customized versions from the original standard. How should i manage this ?

But we can't build different exe for different client!

So please give me some ideas, or solutions that might solve this problem.

  • 2
    Asking here is fair, but I find it hard trying to have an answer to this question. I think you might try to clarify further. From what is given now, the most obvious answer people would give is that you have something like a database (or config file or SQLLite) in your architect. Your compiled exe file should retrieve values from the database when making calculation, and your clients specify these values in another method or module. – InformedA Jul 19 '14 at 7:01
  • 2
    Can you elaborate what kind of product the software is a part of and what kind of differences there are between the versions for each client (is it just numbers that could be looked up, or do they require completely different calculations)? – Bart van Ingen Schenau Jul 19 '14 at 7:32
  • 2
    For the specific configuration issue you mention, the relevant technical term is rules engine. Google it and see how you can use one. – Kilian Foth Jul 19 '14 at 7:48
  • 2
    @hoangnnm I would recommend you check out the plugin architecture of things like Eclipse. You then need to develop separate modules for each industry. When you build the software, you need a separate build process which releases the software into different packaged end products. This is a good thing since you don't want to ship code that belongs to one industry in a solution for another industry. Basically, look at Eclipse, they have different packaging to download for developing Java, C, Web, etc.. Also, this way you can avoid having your developers work on too many different things. – InformedA Jul 19 '14 at 7:51
  • 1
    @Kilian Foth also has good suggestion. I personally would like to know more specific requirements to say whether his suggestion or mine is better. – InformedA Jul 19 '14 at 7:58

For solving these types of problems is why polymorphism and dependency injection exist.

Following your example, you can have a CostCalculator interface or abstract class and two implementations: ClientACostCalculator and ClientBCostCalculator. With this half of the problem is solved, now we need to use dependency injection to solve the other half.

Suppose you use these classes from a process in your system, call the process "MyCalculationProcess", then you need to inject the correct CostCalculatorn depending on your client. You can use a dependency injection framework (there are a lot for .net) and inject the clientA o clientB implementation depending in some configuration or environment variable. Or you can implement this very easily yourself, for example:

class MyCalculationProcessFactory {

   public MyCalculationProcess createProcess(Config config) {

        if (config.isClient("A")) 
            return new MyCalculationProcess(new ClientACostCalculator()); 

        if (config.isClient("B")) 
            return new MyCalculationProcess(new ClientBCostCalculator()); 



Its not the best way to implement this and its more java than c# but i hope that you can get the idea behind.

Also, if you have not only this CostCalculator, you have more things like that depending on a client better than the previous "simple factory" you can use a AbstractFactory pattern.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.