Ddoocp Topic 2
Ddoocp Topic 2
Programmes
Topic 2: Event Driven Programming
Learning Outcomes
Event Handling - 1
• We’ve already made use of an event when building our first
C# program.
• Events are the most important element of the .NET
framework, they are the entry points we provide into our
program.
• When developing an event driven program, we need to
consider the range of what a program must do and how we
will present the options for functionality to the user.
• We also need to make sure that the programs we develop
are easy to use, and make sense in the wider context of user
interfaces
Title of Topic Topic 1 - 1.5
Event Handling - 2
• Events in the .NET framework work according to what is
known as an observer pattern.
• This is a design that permits one part of the program
(usually the UI widget) to send a message whenever a
particular thing happens.
• When we click on a button, the button sends out a message
to say ‘Someone just clicked on me’.
• When we move the mouse over the button, it sends out a
message saying ‘Someone just moved the mouse over me’.
Event Handling - 3
Event Handling - 4
Event Handling - 5
Event Context - 1
• We often don’t know when an event will be triggered when we’re
writing code.
• We don’t know in what order events will be triggered, and we
don’t know what may have happened previously in the
application.
• Events have to work on the assumption that they can be
triggered at any time. This is a considerable difference from the
way older programs are written.
• These would prompt the user for information, in a particular
order, process it, and then query the user for more information
before showing the output.
• The locus of control in such an application was with the
computer.
Title of Topic Topic 1 - 1.10
Event Context - 2
• In event driven programs, users may trigger events before
information has been provided, trigger them when the
application is not ready for them, or send the wrong
information into the application.
• The locus of control in an event driven program is with the
user.
• It is necessary for events to be robust enough to deal with
this. They must ensure the information that comes their way
is correct and fully present before proceeding to processing.
• Events need to be designed with error checking and data
handling built into them.
Title of Topic Topic 1 - 1.11
Event Context - 3
• However, as part of sending a dispatch, the event dispatcher
will send two other pieces of information.
• The first is the sender, which is the GUI object that triggered
the event.
• The second is the event arguments, these contain important
information about the state of the system when an event was
triggered.
• E.G. if we receive a mouse button event, we may wish to know
where the mouse was, what button was clicked etc.
• All of this is provided as event arguments, and the specific set
of information we receive will depend on the type of event itself.
Title of Topic Topic 1 - 1.12
Paper Prototyping - 1
Paper Prototyping - 2
• This is part of a philosophy of development is called paper
prototyping, and the idea behind this is that you use very
crude, low fidelity sketches of how you expect a program to
work.
• You can use this to quickly and effectively explore the
design space of an application and make sure that the flow
of the program is sensible.
• A paper prototype should not take you a long time to put
together.
• You can see some examples of paper prototyping here:
https://speckyboy.com/10-effective-video-examples-of-
paper-prototyping/.
Title of Topic Topic 1 - 1.27
Paper Prototyping - 3
Paper Prototyping - 4
Paper Prototyping - 5
• This process is important, it allows you to see what makes
sense to your users, what doesn’t, and what functionality is
missing.
• This in turn allows you to refine your prototype, test it iteratively
with other people, and settle on the design of an application
before you ever write a single line of code.
• Before beginning any complex user interface, of the kind we’ll
see later in this unit, do some paper prototyping and make sure
you understand the workflow of your own program before you
give it to anyone else to use.
• You might be surprised how far your expectations are from the
reality of your users.
Topic 2 – Event Driven Programming
Any Questions?