Search code examples
.netwinformsdesign-patternsuser-interfacetiers

UI and Application relationship


I've read a lot of articles about the UI ,buisness logic ,WCF ,IoC, but still, one thing is missing from my mind. I build a winforms application and a console app. the Console App is the brain. Now, in all the client-server architecture the client "know" the server , send him request and get the answer. My qestion is as follow:

1) How can the console application display a message to the user if he doens't know the existence of the UI? Should the UI check and pool for the messages every x msec? is it a good approach?

2) what in the case that the UI forms should display a ticker price ,e.g stock price which changes all the time ? should it request the ticker price from the console app every 200msec? or register a callback function in the console application so the console application can call it? However, doesn't it make the UI into a server now?

3) What happen in case that I want to add a terminal capbilities to my application (e.g telnet cli ), how should I design it ? the telnet server as a client and my console application as the server? is there a design that can help me to achieve that? CAB? I asked a lot of people and it seem that nobody is using it... is that so?

Thanks, Eyal


Solution

  • Your program should be designed in such a way that you can replace one UI with another. The program should be able to have the logic function independently from the interface that the user sees. Take a look at the MVC and Observer patterns.

    One good measure of your program is through the interfaces that are made available to the user [API calls, console based GUI, console based interface, net interface, web] I'm not implying that you should refocus the intention of the application to be on making it very flexible with the interface. I'm suggesting that your interface should have nothing to do with the logic and datastore of your application.

    Stock ticker: Have an oberserver pattern that broadcasts a new event every 200ms, or on changes. The ticker view would be a subscriber of these events.