none
I need help with application arhitecture? RRS feed

  • Question

  • Hi!

    I'm working on my first "big" C# and net framework application. I need some help with deciding how to plan the apllication, that it will use elegant C# code in make most out of net framework. Let me first describe the application. The application will consist of  4 important parts:

    1.) Data acquisition driver part

    This part wil receives input data and store it in a buffer, when the buffer is full, the driver will notify the second part and continue with its work. This probably wil be a seperate windows driver.

    2.) Data processing part

    This part will do some data processing on the input data. It will have many calculation intensive functions, which will execute based on the settings in part 3 and 4.  When a function returns it should notify the part 3 and 4.

    3.) GUI part

    This part will display the processed data in different ways, manage setting for all other three parts.

    4.) Logger part

    This part will log data from any function in part 2.

     

    I would like to to make application in such way that all part are as independend as possible, but they should have no problem to communicate with each other. I would like that any function in part 2 would only work if part 3 or 4 is subscribed to it.  For example if in part 3 I display the graph of raw input data the there is no need for part 2 to run function that calculates some statistics, but if the logger needs some statistics then it should run that to.

    The way i currently imagine the apllication is that each part is a separated thread and they communicate through events and shared data structures.  I imagine that part 1 generates an event when it has data ready for part 2 , part two checks for every function if there is somebody subscribed to it and if it is, it then runs that function and fires an event after the function is done. Part 3 and 4 get the events from part 2 and do their job.

    I'm very grateful for any help, advice or comment  you can offer.

     

    best regards to all

    Tuesday, September 12, 2006 1:10 PM

Answers

  • This seems to be an interesting place .
    I think using a Factory with predefined interfaces is a nice way to do it. It should suffice.
    Just to add a little more to it, you can have a singleton class manage the interaction between different components. Each component will regsiter itself with the singleton class. The components will notify the singleton about the event. It is then the singleton's responsibility to call the appropriate class. Typically, you can define delegates to handle the calls from the singleton to the components.
    Sunday, September 24, 2006 5:38 AM

All replies

  • One generic suggestion is to use Interfaces between each of the individual components, just doing that answers a lot of what you seek. It will keep the code sharing to a minimum and if you have to change for future needs the itnerface can just be added to...also consumer is not bound to any one design and it can be swapped out if needed.

    Another suggestion is to use a factory in between the business layer and any GUI layer. That way you can reuse the business logic in other areas without being tied to that one app.

    Note these suggestions will add more upfront work ...but it pays off in the future. Some developers may criticise, but writing code that works vs buggy is always preferable for me and I will take that criticisim.

    Check out this discussion about the desing of the Data Access Layer DAL.


    Examples are some of the best way to learn. Check out some of the VB/C# examples for the basic operations or some more robust examples as found in the Starter Kits whihc is directed towards SQL development which can help you wit designs.

    Also there are 101 Samples for Visual Studio 2005 which is a robust, initial development tasks to more involved tasks for winforms, web development etc.


    Tuesday, September 12, 2006 3:02 PM
  • This seems to be an interesting place .
    I think using a Factory with predefined interfaces is a nice way to do it. It should suffice.
    Just to add a little more to it, you can have a singleton class manage the interaction between different components. Each component will regsiter itself with the singleton class. The components will notify the singleton about the event. It is then the singleton's responsibility to call the appropriate class. Typically, you can define delegates to handle the calls from the singleton to the components.
    Sunday, September 24, 2006 5:38 AM