Click here to Skip to main content
15,893,381 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am very new to architecting the project. I am not sure what is the best way to start the project with following requirements:

Requirements are:
a. GUI which sends commands and expects the result. Next command will be sent only after we get the result(pass or fail) from the previous operation.

b. These commands are sent to devices. we need to support sending commands to one or more devices simultaneously.

c. The data received from the device need to be updated in the GUI and also saved to the DB.

Looking for the layered architecture. Any help would be appreciated.

My suggestions are:

a. GUI would be one layer.(different tabs for different devices)
b. Device Layer would be one.(single instance or multiple instance will support multiple device simultaneously)
c. DB layer would be one.

Here are my questions for which I need suggestions:
a. how to communicate between GUI and Device Layer?(here GUI is one, but device layer can be many each serving different devices of same kind)

b. Where to instanstiate the DB interface?...
Posted
Updated 23-Jun-15 5:41am
v2

1 solution

Your suggestions basically look reasonable.

The question also contains one of the most reasonable suggestions for communications between UI and device layer: that could be WCF. In this case, the most adequate WCF hosting would be self-hosting in the device-layer application, which could be Windows Service, which is well suitable for WCF hosting. Alternatively, you could use "classical" remoting, or lower level, such as TCP sockets (TcpListener on service side, TcpClient on client part) or named pipes. Note that such kinds of transport can become WCF channels, which can be replaceable/configurable, for better flexibility. This choice would be the in some more detailed level of your architecture. The most important point here is: devices should be services, not clients. You can hide device implementation detail behind the common interface. By the way, if you have different types of devices and need several different interface, each such device of group of similar or related devices could be implemented as a separate service.

For threading issues of the services, see also my past answers:
an amateur question in socket programming[^],
Multple clients from same port Number[^],
How Do I Get To Know If A A Tcp Connection Is Over[^].

Such approach to devices creates other benefits. Not only you isolate them from UI, data layer and other aspects, you can put them in a different tier (not to be mixed up with layers!) You can debug the device services using one client application, but your product client applications could be different. You can place your device layer on different platforms. In case of WCF, you may think that it could defeat the benefit of the service contract, which are very convenient but are specific to .NET, but then you should remember that CLI and WCF are also available on non-Microsoft platform, for example, via Mono and/or other 3rd-party platforms (say, CosmOS). Even if you think that you don't need other platforms now, the extra flexibility you put in the architecture will open the multiplatform opportunities to the future versions of your product.

The second question, "where to instantiate DB interface" is not clear. I cannot understand what do you mean. You already suggested a separate data layer, which is very reasonable. You can find a lot of reading on the architecture of data layers and their place in the application architecture.

The most important part to abstract out from other aspects is UI. This is in part due to some historical/cultural reasons. The UI computing is the least stabilized part, the UI designs use different frameworks and are the most "fragile". I suggest you learn and analyze applicability of the following architectural patterns (http://en.wikipedia.org/wiki/Architectural_pattern_(computer_science)[^]):

MVVM — Model View View Model,
http://en.wikipedia.org/wiki/Model_View_ViewModel[^],

MVC — Model-View-Controller,
http://en.wikipedia.org/wiki/Model-view-controller[^]),

MVA — Model-View-Adapter,
http://en.wikipedia.org/wiki/Model–view–adapter[^],

MVP — Model-View-Presenter,
http://en.wikipedia.org/wiki/Model-view-presenter[^].
—SA
 
Share this answer
 
v2
Comments
Andy Lanng 23-Jun-15 12:20pm    
Wow - A very complete and well deliberated solution! 5*
Sergey Alexandrovich Kryukov 23-Jun-15 12:21pm    
Thank you, Andy.
—SA
Ganga Prabhu 23-Jun-15 15:34pm    
Thank you Sergey.

I will keep you posted. I wanted to know if I am on right track.
Sergey Alexandrovich Kryukov 23-Jun-15 16:07pm    
You are very welcome.
Call again when you have further concerns.
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900