Q: Practical methods of separating UI from business logic

Hi,

I am building some app the core logic is like:

1
[capture some images] => [detect objects inside images] => [perform some processing] => [insert the results into a database]


The logic is fairly simple, now I need to put an UI on top of it, to let the user take the control. For example, the user can press a "Start" button to start the work. And click "Stop" button to make the program stop as soon as possible. Also, the UI will display the captured images and detected information.

I would like to make the UI making isolated with the implementation of the logic codes. Or even make the UI optional.


How can I do it ? Are there some examples ?

Thanks!

Edited by Hui on Reason: Initial post
Any UI framework/library will allow to do that. There is nothing really special about that. Just have your data processing to know when to stop - boolean or event, or whatever you have. And just set this condition from UI for processing to stop.
For simple UI dear imgui works fine. And it does not require creating any UI state outside of what you already have. You just loop over data you have and and render UI elements you want to show for your state.

Edited by Mārtiņš Možeiko on