How to seperate GUI-Design and Core functions?

G

Guest

Hello,

I´ve a general question how to perform a strict seperation between GUI
design and core functionality.


To give a little example...

I´m importing an xml file into a MS SQL database.

For this reason I designed a class "Import" and a GUI-class "ImportDialog".

The ImportDialog contains a progress bar.

In the Import-Class I am sequentially reading the xml-file
and importing it to the database.

For every sequential step I want to call progressBar.performStep();


My question is now... How can I do it without loosing my strict
seperation between functionality (class Import) and design (class
ImportDialog)?


At the moment I am giving the progressBar object to the constructor of
the Import class (public Import(ProgressBar pBar)) but this seems to be
a dirty hack.

So... How do you solve these problems?

Maybe with using Thread-Programming?



Regards,

Martin
 
S

Simon Tamman

I would probably introduce a third object to mediate between the two:

e.g.

XMLImport fires progress changed event
Application block picks up the event and
Calls UpdateProgress() on the form.

Where the application block holds a reference to both the XMLImporter and
the form.

Therefore the form's only business logic is to take an integer and update
it's progress bar with that value (which is more UI than anything else).
 
T

Tasos Vogiatzoglou

Martin,

You could add an event to your import class, that classes can listen
to. This way, you have a clean separation of UI code with your logic.

With an event being fired in place, you could implement cleanly a lot
of functionality unrelated to your import procedure.

Regards,
Tasos
 
O

Otis Mukinfus

[snip]
My question is now... How can I do it without loosing my strict
seperation between functionality (class Import) and design (class
ImportDialog)?


At the moment I am giving the progressBar object to the constructor of
the Import class (public Import(ProgressBar pBar)) but this seems to be
a dirty hack.

So... How do you solve these problems?

Maybe with using Thread-Programming?
Martin,

If you are using VS 2k5 you can set the ProgressBar.Style property to Marquee.
Doing so will allow you to indicate progress by continuously scrolling a block
across a ProgressBar in a marquee fashion. I personally believe it is great for
showing that an event is still in progress when it's difficult to measure
completion status.

Good luck with your project,

Otis Mukinfus
http://www.arltex.com
http://www.tomchilders.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top