1

In an application I developed with C#, I use a webbrowser control, it should navigate to some websites, then I would like to extract some contents from the webpages. I do it by manipulation of DOM and removing some nodes. It can be done automatically or manually with the help of user.

Then I have two modes, surfing mode and extraction mode. I think switching between modes and updating related controls and menus and responding to events... has made my program complicated. What is your advice to make it less complicated?

Does Separation of Concerns applies to GUI components too?

2
  • My main concern when creating a GUI is, is it usable? Does it help the user get his work done? If separate modes makes life easier for the user, then fine. If not, change your GUI to make it more usable. Commented Mar 6, 2015 at 17:13
  • @GilbertLeBlanc You are right, but I can offer modes to the user while I use different component for each mode (a Show/Hide approach) or use the same component Commented Mar 6, 2015 at 18:16

1 Answer 1

1

Separation of concerns is just as important in UI as anywhere else, if not more so. Anything that doesn't directly involve user interaction does not belong in the UI. It belongs somewhere else.

Consider what happens when you create a UI having the usual event hooks:

private void Form1_Load(object sender, EventArgs e) { listView1.Items.Add(new ListViewItem("this is a test")); } 

What happens if you put all of your business logic in your form? You wind up with a big ball of mud, that's what. That's why we put business logic in another module, class or DLL.

Whether this is what's happening with your application is an open question. As I see it, there's two possible approaches. You can have a single UI with two modes, or two different UI's. If the modes are dramatically different, I usually prefer two different UI's, as you can avoid all of the if statements that way, and your design is generally cleaner. You can refactor common functionality between the two UI's into a separate module, class or DLL.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.