17
Deep Within event-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 deleted Item: 0763612 in stock: 53 on order: 500 confirm cancel Major System Error application aborted invalid data key access #37683 in ac_ssdb

Deep Within event-driven interfaces programming styles under the bonnet … the bits leak out modal and non-modal interfaces maintaining state between events

Embed Size (px)

Citation preview

Page 1: Deep Within event-driven interfaces programming styles under the bonnet … the bits leak out modal and non-modal interfaces maintaining state between events

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

Page 2: Deep Within event-driven interfaces programming styles under the bonnet … the bits leak out modal and non-modal interfaces maintaining state between events

programming styles

• on demand

• event loop

• event-driven

Page 3: Deep Within event-driven interfaces programming styles under the bonnet … the bits leak out modal and non-modal interfaces maintaining state between events

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”

Page 4: Deep Within event-driven interfaces programming styles under the bonnet … the bits leak out modal and non-modal interfaces maintaining state between events

event loop

• program requests events

• user controls what events it gets

while (not the end){

event = getNextEvent();if (event.type == mouseClick){ … }else if ( … …

}

Page 5: Deep Within event-driven interfaces programming styles under the bonnet … the bits leak out modal and non-modal interfaces maintaining state between events

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 … … … …}

Page 6: Deep Within event-driven interfaces programming styles under the bonnet … the bits leak out modal and non-modal interfaces maintaining state between events

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

Page 7: Deep Within event-driven interfaces programming styles under the bonnet … the bits leak out modal and non-modal interfaces maintaining state between events

the bits leak out how it affects the interface

edit delete

0763612ref no:

STOCK SYSTEM

Page 8: Deep Within event-driven interfaces programming styles under the bonnet … the bits leak out modal and non-modal interfaces maintaining state between events

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

Page 9: Deep Within event-driven interfaces programming styles under the bonnet … the bits leak out modal and non-modal interfaces maintaining state between events

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

Page 10: Deep Within event-driven interfaces programming styles under the bonnet … the bits leak out modal and non-modal interfaces maintaining state between events

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

Page 11: Deep Within event-driven interfaces programming styles under the bonnet … the bits leak out modal and non-modal interfaces maintaining state between events

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

Page 12: Deep Within event-driven interfaces programming styles under the bonnet … the bits leak out modal and non-modal interfaces maintaining state between events

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

Page 13: Deep Within event-driven interfaces programming styles under the bonnet … the bits leak out modal and non-modal interfaces maintaining state between events

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 ...

Page 14: Deep Within event-driven interfaces programming styles under the bonnet … the bits leak out modal and non-modal interfaces maintaining state between events

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

Page 15: Deep Within event-driven interfaces programming styles under the bonnet … the bits leak out modal and non-modal interfaces maintaining state between events

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”

Page 16: Deep Within event-driven interfaces programming styles under the bonnet … the bits leak out modal and non-modal interfaces maintaining state between events

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

Page 17: Deep Within event-driven interfaces programming styles under the bonnet … the bits leak out modal and non-modal interfaces maintaining state between events

who it was

Alan Dix

[email protected]

http://www.hcibook.com/

http://www.hiraeth.com/alan/teaching/bigui/

http://www.aqtive.com/

and crackers at:

http://www.websharer.com/crackers/