BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

OO GUI

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi OO design
View previous topic :: View next topic  
Author Message
Peter Morris [Droopy eyes
Guest





PostPosted: Sun Dec 18, 2005 8:15 pm    Post subject: OO GUI Reply with quote



Hi all

There's a small project I have to write, and before I started I wanted to
post here for some advice/discussion.

My usual apps allow the user to perform any task at any point. This new app
I have to write has a set logical flow, like a Windows Wizard form.
Depending on which option you choose in Task A, you will be presented with a
different step, for example.

1) Visit site
2) Is this a restock visit or engineering visit?

(Engineering visit)
1) Select machine
2) Replace part
3) Close machine

(Restock visit)
1) Select machine
2) Restock brand A
3) Repeat #2 until all brands done
4) Count cash
5) Other options (replace part for example)
6) Close machine

As you can see there are some "if" type branches depending on user
selection, and there are also some common tasks that I could reuse.

What I want to know is this, is there some kind of well established OOP
technique for this sort of thing? I expect it is quite common. It's kind
of like a state machine, but with sub-machines in there too.

Any info/advice would be appreciated!

Thanks


--
Pete
====
ECO Modeler, Audio compression components, DIB graphics controls,
FastStrings
http://www.droopyeyes.com

Read or write articles on just about anything
http://www.HowToDoThings.com

My blog
http://blogs.slcdug.org/petermorris/





Back to top
Bob Dawson
Guest





PostPosted: Sun Dec 18, 2005 8:23 pm    Post subject: Re: OO GUI Reply with quote



"Peter Morris [Droopy eyes software]" wrote

Quote:
for this sort of thing? I expect it is quite common. It's kind
of like a state machine, but with sub-machines in there too.

There's absolutely nothing wrong with nesting statemachines.

bobD




Back to top
Lee_Nover
Guest





PostPosted: Mon Dec 19, 2005 4:36 am    Post subject: Re: OO GUI Reply with quote



Quote:
Any info/advice would be appreciated!

if you're gonna do it with ECO 3 you might as well use it's biggest addition - State Diagrams :)

Back to top
Peter Morris [Droopy eyes
Guest





PostPosted: Mon Dec 19, 2005 3:54 pm    Post subject: Re: OO GUI Reply with quote

I forgot to mention, as with a standard Win32 wizard I will also need a Back
option


--
Pete
====
ECO Modeler, Audio compression components, DIB graphics controls,
FastStrings
http://www.droopyeyes.com

Read or write articles on just about anything
http://www.HowToDoThings.com

My blog
http://blogs.slcdug.org/petermorris/


Back to top
Jim Cooper
Guest





PostPosted: Tue Dec 20, 2005 12:39 am    Post subject: Re: OO GUI Reply with quote


Quote:
I forgot to mention, as with a standard Win32 wizard I will also need a Back
option

Back as a navigation option still suggests state machines, but back as an undo
operation always makes me look at the Command pattern in the first instance.


Cheers,
Jim Cooper

__________________________________________

Jim Cooper [email]jcooper (AT) tabdee (DOT) ltd.uk[/email]
Skype : jim.cooper
Tabdee Ltd http://www.tabdee.ltd.uk

TurboSync - Connecting Delphi to your Palm
__________________________________________

Back to top
Peter Morris [Droopy eyes
Guest





PostPosted: Tue Dec 20, 2005 10:22 am    Post subject: Re: OO GUI Reply with quote

Hi Jim

I was considering starting an ECO undo block at each stage. Reversing that
block would undo everything, and then I would be able to display the GUI for
the current element within the wizard form. Sounds good.

Thanks for the input, I'll give it a spin and see how it works. Now, on to
see if I can get ECO working on the compact framework (fingers crossed) :-)


--
Pete
====
ECO Modeler, Audio compression components, DIB graphics controls,
FastStrings
http://www.droopyeyes.com

Read or write articles on just about anything
http://www.HowToDoThings.com

My blog
http://blogs.slcdug.org/petermorris/


Back to top
Leonel
Guest





PostPosted: Tue Dec 20, 2005 2:32 pm    Post subject: Re: OO GUI Reply with quote

Peter Morris [Droopy eyes software] wrote:

Quote:
I am tempted to hard-code the "what next" into the GUI, any other
ideas/suggestions?

"Select machine" could be a method in your "GUI workflow" class,
popping up the appropriate dialog and storing the results in class
attributes.

The GUI workflow class would have a state machine that calls the
appropriate methods in entry/exit/effect transitions, using action
language.

Is something like that you have in mind?

--
Leonel

Back to top
Peter Morris [Droopy eyes
Guest





PostPosted: Tue Dec 20, 2005 2:44 pm    Post subject: Re: OO GUI Reply with quote

There's one last obstacle in my mind.

StateMachines always move in a kind of forward-flow, unlike subroutines
which remember where they were called from and return to that point.

Some of the tasks in my flow would be self-contained tasks that can be used
from other tasks, and would have to return the logic flow to the calling
task when finished, like so.

1) Select Visit type
Quote:
Restock visit
1A) Select machine

1B) Select brand
1C) Restock

1) Select Visit type
Quote:
Engineering visit
1A) Select machine

2A) Select part to replace

As you can see "Select machine" is more like a "pop onto stack" type of
task. As is "Select brand" (it is used for identifying the current stock
level when auditing, and the new stock level for restocking).

State machines don't work like, well, not in ECO anyway.

I am tempted to hard-code the "what next" into the GUI, any other
ideas/suggestions?


--
Pete
====
ECO Modeler, Audio compression components, DIB graphics controls,
FastStrings
http://www.droopyeyes.com

Read or write articles on just about anything
http://www.HowToDoThings.com

My blog
http://blogs.slcdug.org/petermorris/



Back to top
Leonel
Guest





PostPosted: Tue Dec 20, 2005 5:03 pm    Post subject: Re: OO GUI Reply with quote

Peter Morris [Droopy eyes software] wrote:

Quote:
I don't follow what you are suggesting.

You seem to want to set the "next step" manually. I think you should
use a state machine where the button click "next" calls the trigger and
the transiction effects update the "executing task", going to the next
task according to the flow you have modelled.

So you start your state machine and you're on the "Select Visit Type"
state. The entry effect causes the GUI to update and display the
appropriate fields for the "Select Visit Type" state. When you press
next on the GUI, call the trigger on the State Machine.

Leaving your "Select Visit Type" you can have two transitions, with
guards set according to the visit type selected on that state. They go
to the appropriate next state. And so on.

--
Leonel

Back to top
Peter Morris [Droopy eyes
Guest





PostPosted: Tue Dec 20, 2005 5:17 pm    Post subject: Re: OO GUI Reply with quote

I don't follow what you are suggesting.

The closest I can come up with is to have a class for each task, and in a
base class have a "ExecutingTask" reference. When the task reaches its last
phase it displays a "Finished" button if ExecutingTask = nil, otherwise it
displays a "Next >>" button (which then goes back to the ExecutingTask).

I'd have to have a singleton somewhere that held a reference to CurrentTask,
so that the GUI always knew which task to display a GUI for. So, something
like this

1) Create a RestockVisit task
1A) This creates a SelectMachine task
1B) SelectMachine.ExecutingTask := Self;
1C) Singleton.CurrentTask := SelectMachine;
2) Create a SelectBrand task
etc

Looks like that might work, any additionaly suggestions/input always
appreciated!


--
Pete
====
ECO Modeler, Audio compression components, DIB graphics controls,
FastStrings
http://www.droopyeyes.com

Read or write articles on just about anything
http://www.HowToDoThings.com

My blog
http://blogs.slcdug.org/petermorris/


Back to top
Jim Cooper
Guest





PostPosted: Tue Dec 20, 2005 5:28 pm    Post subject: Re: OO GUI Reply with quote


Quote:
Thanks for the input, I'll give it a spin and see how it works.

Good luck :-)

Quote:
Now, on to see if I can get ECO working on the compact framework (fingers crossed) Smile

I think you'll need more than luck there Smile Even in relatively straighforward
apps I find things missing in the CF, so I would be surprised if ECO even
compiles properly in that environment. I also find performance an issue with
non-SQLCE code.

Keep us posted though.

Cheers,
Jim Cooper

__________________________________________

Jim Cooper [email]jcooper (AT) tabdee (DOT) ltd.uk[/email]
Skype : jim.cooper
Tabdee Ltd http://www.tabdee.ltd.uk

TurboSync - Connecting Delphi to your Palm
__________________________________________

Back to top
Peter Morris [Droopy eyes
Guest





PostPosted: Tue Dec 20, 2005 7:33 pm    Post subject: Re: OO GUI Reply with quote

Hi Leonel


Quote:
You seem to want to set the "next step" manually.

No, I meant that the CurrentTask would do it. Calling "Next" on the
CurrentTask is easy enough, in action script I can do this

Singleton.CurrentTask := new SelectMachine();
Singleton.CurrentTask.ExecutingTask := self;


The GUI always updates after the Next button is clicked. In the case where
there is a decision to be made as to which task is executed, I would simply
have guards on the transition, based on certain circumstances of the object
instance being manipulated, or on the value of a transient attribute on the
task instance itself.

I didn't realise that this is what you originally meant, I agree that it is
a good idea. The "ExecutingTask" and the generic "CurrentTask.Next" were
the two key points that I needed to come up with I think.

Thanks everyone for your input, it has been very useful!


--
Pete
====
ECO Modeler, Audio compression components, DIB graphics controls,
FastStrings
http://www.droopyeyes.com

Read or write articles on just about anything
http://www.HowToDoThings.com

My blog
http://blogs.slcdug.org/petermorris/



Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi OO design All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.