Re: Auto selection



Responding to Tailorma_de...

I have a design question: How could I auto-select a new created
business object reprensentation in my GUI?

My application is divided into the business model and UI and I use the
command pattern. I can describe my problem with an IDE since it is the
same thing.

Imagine I create a new code file within a project. There may be a
dialog where the user has to specify the file name. When the user then
clicks on Ok the new file is created and it is added to the project
somehow. Now there is a project tree view in the GUI and within this
view a new node gets visible, representing the new file. Then the
question comes up: How can this node gets selected automatically?

I basically agree with Bossavit, but with a somewhat different spin. Your business model and UI are different subject matters that need to be abstracted differently. One uses subsystem or layer encapsulation to decouple them through interfaces.

If the interface is message-based, one gets a lot of decoupling because each side can map the message and its data packet to its own view of the world. So the first thing to think about <philosophically> is what role the UI plays in the overall application context.

Answer: it allows the problem to solution to communicate with the software user through a particular UI paradigm (e.g., GUI, browser, command line, smoke signals, etc.). Note that the problem solution doesn't care what the UI paradigm is. Conversely, the UI does not really care what the problem being solved is; it just cares about displaying information and acquiring user input.

IOW, the UI is quite myopic; it only understands display paradigms. If the user provides input, the UI just forwards that input to the problem solution as a message. Similarly, if the problem solution needs information from the user to solve the problem, it asks the UI for it by sending a message. The UI does its thing to get the information from the user and sends it back to the problem solution, again via a message. Finally, when the problem solution has some results, it sends them in a message to the UI for display.

A couple of notions are crucial here:

(1) The UI does not solve business problems. It simply acquires and displays data. IOW, the UI is technically complex but not very smart.

(2) The UI does so _on request_. It may be the user via a key click or it may be the problem solution, but /somebody/ is telling it exactly what to do. To put another way, the UI subsystem or layer has two clients: the problem solution and external UI mechanisms (e.g., the OS Window Manager for a GUI or the network for a browser). The UI exists to pass information between those two clients without caring about its semantics.

(3) The business model understands what problem is being solved for the customer. That problem solution must abstract a complex business domain, complete with lots of rules and policies. The solution also typically involves sequences of activities that require different data or provide different results to the user. So the business model needs to be relatively smart compared to the UI because it needs to deal with the Big Picture.

So what's the point here? Keep the application intelligence in the business model while simplifying the UI into basic data entry and display tasks that can be expressed in terms of simple interface messages.

More specifically, in terms of your tree one has a message dialog something like:

UI: The user clicked OK in the New File dialog. Here's the text box value from the dialog.

BM: I've created a new file. Insert it in your display. Here's the ID and some information about how it relates to other files.

In each case the message is expressed in sender semantics but the receiver maps it into its own view through the subsystem/layer interface (think: Facade pattern). So when the interface to the business model receives a message from the UI with a message ID of userClickedOKInNewFileDialog, it knows that it should pass the data packet on to whatever object in the business model is responsible for creating new files.

Once the file is created, the business model knows that the user must be informed of the addition, so it sends a message to the UI. The UI's interface maps that message ID into the need to insert a node in its tree display so the UI interface dispatches the message data packet to whatever object in the UI manages the tree display.


*************
There is nothing wrong with me that could
not be cured by a capful of Drano.

H. S. Lahman
hsl@xxxxxxxxxxxxxxxxx
Pathfinder Solutions
http://www.pathfindermda.com
blog: http://pathfinderpeople.blogs.com/hslahman
"Model-Based Translation: The Next Step in Agile Development". Email
info@xxxxxxxxxxxxxxxxx for your copy.
Pathfinder is hiring: http://www.pathfindermda.com/about_us/careers_pos3.php.
(888)OOA-PATH



.