Upload
leslie-lloyd
View
212
Download
0
Embed Size (px)
Citation preview
Deep Withinevent-driven interfaces
• programming styles
• under the bonnet … the bits leak out
• modal and non-modal interfaces
• maintaining state between events
• other events: networks, timers, devices
edit delete
STOCK SYSTEM
deletedItem: 0763612
in stock: 53
on order: 500
confirm cancel
Major System Errorapplication aborted
invalid data key access#37683 in ac_ssdb
programming styles
• on demand
• event loop
• event-driven
on demand
• fascist programs!
• program in control (internal control)
• users do what they’re told
print “what is your name”name = read()print “hello ”+name+“ how old are you”age = readInt();print “you will be ”+(age+1)+“ next year”
event loop
• program requests events
• user controls what events it gets
while (not the end){
event = getNextEvent();if (event.type == mouseClick){ … }else if ( … …
}
event-driven
• external control:• when an event (often from the user) happens
• program function/method is called from the outside
• many (e.g. VB) or single entry point
on mouseClick(pos) … …endon keyPress(key)
… …end
handleEvent(event){ if (event.type … … … …}
under the bonnet what windows does!
• when an event happens - added to a queue
• when your program is ‘active’• Windows takes event from queue
• then calls appropriate bit of your program
• when it returns, if there is enough time - repeat
– N.B. slightly different for different event typese.g. TCP/IP
the bits leak out how it affects the interface
edit delete
0763612ref no:
STOCK SYSTEM
the bits leak out how it affects the interface
edit delete
0763612ref no:
STOCK SYSTEM
Item: 0763612
in stock: 53
on order: 350
confirm cancel
the bits leak out how it affects the interface
edit delete
ref no:
STOCK SYSTEM
Item: 0763612
in stock: 53
on order: 350
confirm cancel
deleted
the bits leak out how it affects the interface
edit delete
ref no:
STOCK SYSTEM
Item: 0763612
in stock: 53
on order: 500
confirm cancel
deleted
the bits leak out how it affects the interface
edit delete
ref no:
STOCK SYSTEM
deletedItem: 0763612
in stock: 53
on order: 500
confirm cancel
Major System Errorapplication aborted
invalid data key access#37683 in ac_ssdb
the bits leak out how it affects the interface
• what goes wrong?– user does anything – unexpected events
• no sequence control
• so if not careful ...
inconsistency!!
edit delete
ref no:
STOCK SYSTEM
deletedItem: 0763612 in stock: 53
on order: 500
confirm cancel
Major System Errorapplication aborted
invalid data key access#37683 in ac_ssdb
modal and non-modal interfaces
• modal dialogue box– can’t do anything else until it is complete
• non-modal dialogue box– can do other things while it is there
a design decision … but ...
modal and non-modal interfaces
• modal dialogue box• easy with internal control• hard with external control - event-driven
• non-modal dialogue box• hard with internal control• easy with external control - event-driven
beware!implementation should not drive design
maintaining state between events
• internal control easy!
• external control– data in different modules– data in interface– … and no ‘program counter’
print “what is your name”name = read()print “hello ”+name+“ how old are you”age = readInt();print “you will be ”+(age+1)+“ next year”
other events
not just user events:
• timers• when 2 minutes since last action, save data
• network• when web page arrives show it on screen
• devices• when IR sensor shows activity contact police
who it was
Alan Dix
http://www.hcibook.com/
http://www.hiraeth.com/alan/teaching/bigui/
http://www.aqtive.com/
and crackers at:
http://www.websharer.com/crackers/