Thanks for coming. I took a look at a paper
I had recently reviewed and went to the references and
try to pull out all the hard to pronounce words
from the type of, all the requisite equipment over
random combination. This is the title I came out with.
So today I'm going to try to make sense of
these words, including eccentric in multi dimensional and talk
a little bit about that. Problems in job in
general, but also in the context of the android
hurting uh party people were interested in uh maybe one
of them. So actually, what am I really
going to talk about with all these words? I'm
going to talk about that. I'm going to focus
specifically on this problem and that problem job. But
in the context of the android applications that turned out
that he just had problems there are not any different
really than even that. Problems in other areas for
uh reviews including in the swing greens and all kinds
of crime for any of the job. And I'm
going to talk about a new approach that we are
working on. This is really work in progress,
right? But a new person we're working on to
provide dispatched gives keeps some of the advantages of this
action mechanisms that are typically used job but combines them
other complementary advantages that are missing from most job designs
. But the president of a lot of modern trying
to get the best of both worlds. And before
I do that though, I'm also going to talk
a little bit about android programming and education and about
library pulses via that. Working on here again is
a work in progress I thought might be of interest
, especially after all the uh somewhat more research driven
talks that we've had a number of candidates, that
sort of thing. Uh This is gonna be a
little bit more practical, a little bit more design
Uh, and also give you a flavor of some
of the things are going on, you know?
Uh, certainly, uh, if you're interested in
working on these kind of issues I'd like to hear
. So why enjoyed and why I talk about things
in the context. Well, obviously a mobile apps
are really popular, not just with your client,
uh, people in general and most people, most
people use them. And android is also very popular
. The number of apps and android market uh,
is very close to the number that are available in
uh, itunes. And uh, one of the
differences is that android and java and java is used
as an educational language training program and that was the
most dominant language used for, for teaching introductory program
. And as a result, there are a lot
of educators we're looking at. Well, it's a
lot of people are interested in. A lot of
people are interested in mobile app, uh, use
that to make the introduction. Learning experience of people
who take courses a little more interesting, a little
more exciting and students to see the skills that are
bringing uh, things that could go right into google
play right into the marketplace, uh, they might
find out a little more relevant, a little more
interesting than some of the other examples that educators.
Uh, so that's sort of the, uh,
one of the reasons why, uh, some of
us, like myself, were interested in education,
uh, android, but one of the problems really
is, uh, that android as a development platform
, uh, really not intended to be a little
too complicated. It really presumes a certain level of
proficiency. And since we're just learning the basics,
uh, a lot of, uh, uh,
frustration, a lot of confusion when they confront the
basic and great. Yeah, and as I mentioned
, a little bit more about why am I talking
about here in the summer today? One of my
goals is to give you a picture of some of
the projects that are going on, you know about
, and also to talk about this a little more
design or just because I had an opportunity to speak
seminar in some of the design that's going on to
graduate sophisticated and I think a lot of time,
so, um one of those things is the design
of Sofia and Sofia, the simple open framework or
convincing in real applications uh is a library uh that
we're working on for educational, really simplify the enjoy
the FBI and make it more accessible for. Uh
One of our goals is not just to create a
beginner, only a P I. Or something that
uh that work for simple applications, but doesn't really
let students and see what goes on with real Madrid
applications. Uh instead of wanting to provide something that
naturally can be built up a whole scale applications of
this kind of professional development and that may also include
some teachers uh capabilities that professional developers will find.
You know, they're not just for beginners because they're
simple, but professional developers can use a little simplicity
, everyone's about to uh we have to do a
little less coding that we can do it more directly
if we can do it more understand that we were
gonna get about faster than to about. Right.
And so uh the idea really behind Sofia is to
provide ever abstractions for a number of the FBI uh
in a way that allows beginners to approach number of
things that are not so approachable um in the spot
SDK and also they can scale up professional quality acts
that non using. Um some of the areas in
the injury FBI Sofia focuses on improving, improving.
Uh Well, one of the things we have to
worry about is how the first see programs when you're
learning the program. So we're particularly concerned about making
sure that that's not too heavy weight or obstructionist of
a process and any of you who have written an
injury for any more probably know about how much it
takes to get a visa application to do something useful
. Uh, we don't want to have the right
uh, that much in order to see some results
. Also turned out a lot of work in the
past 10 years has been done by how to better
support students who are just learning program um if you
want to, allowing law urgent applications, graphical applications
like drawing the information came from an idea. And
uh those kind of balls actually put in really natural
because so many applications in google play our games while
because they changed the name to google play anyway.
Um, so, um, students who are interested
in engaged biographical content on mobile devices are probably gonna
want to write that kind of content and we want
to provide uh enough of the abstraction later that they
can do that quick. Right? And usually without
a lot of obstruction. And we're dealing with a
graphical drawing on a mobile device, It's not just
enough to provide a way for them to draw uh
drop shapes and paint images on the screen, but
you also have to bring about the kind of applications
are going to develop. And if you do,
you're gonna be interested in developing uh games or other
kinds of applications that do a lot of manipulation screen
then other work other than just being able to draw
, like collision infection, maybe a physics engine.
Those kinds of things are also also useful things to
have, but anyway, that the undereducated and provide
. So those are some of the things that we're
looking at, some of the other things. Uh
, 20 out a lot of the graduate students,
uh Donald work on Sophia has put members into some
of the clarity animation support so that students can uh
, animated shapes and simple, clean way without having
to worry about time, time call that and other
kinds of stuff, trying to make sure that you
can deal with the transition between activities or screens and
you have a multi screen applications, different kinds of
playoffs for different tasks. Uh, uses a a
more advanced kind of a callback design that handle the
transition between different screens and an application. Uh callbacks
, uh particular problems for beginners, providing a streamline
uh simpler way to do this kind of transitions is
important and actually relates to the other stuff we're gonna
talk about today is really going to focus on call
that a distraction. Uh things like handling multi touch
on a multi touch device and gestures dealing with the
common kinds of models of applications that people might not
support. Those are all things that we're interested in
providing. So there's a lot of work for months
of the uh so many things have already uh already
have quite a bit of work done uh and others
were just beginning, so finding interesting. Uh please
let me know. Um so I mentioned for beginners
, you want to make sure that uh you know
, if you want to use a lawyer or something
like it in the introductory course, uh initial programs
that they are going to be understandable, so I
want to show you very quickly the hell of world
using Sophia individuals who have not current an injury for
uh trying to put the world on the screen requires
some degree of code. Uh But here you can
see the whole world is probably comparable to the simplest
you would see in most jobs. Uh Right.
And um but in addition to simple kinds of uh
programs that are not interactive, we also want to
get into interactive. Uh I've already mentioned before that
providing for shape based drawing a reasonable obviously in our
case uh to manipulate collections of things on the screen
, repositioning things on the screen. Uh and that
sort of thing is important. So here's a couple
of examples of things uh that actually are implemented via
running, uh but that takes surprisingly little, very
little uh in order to get working one of the
version of pond that actually uses multiple people, uh
Two opponents controlling different patterns uh at the same time
and break out, which is a very similar kind
of all of having a little bit more color.
And of course maybe those work isn't just about growing
shapes, but it's also about animation. Uh since
you've got a screen that easy and accessible for students
. So it turned out that in addition to the
animation, you also have to think about collision support
and collision detection. Uh If you can improvise the
collision detection shearing and you can make it accessible for
beginners, then actually a game like breakout is pretty
simple because you have a ball bounces around and really
all you're interested in is what happens to the ball
, what happens to the bricks when they collide or
when it all happened right? And it turns out
that logic can be expressed simply in terms of those
kinds of defense. So I'm gonna come back to
break out again. We talked about action. I
mentioned multi activity communication, especially between screens. Um
, it turned out that even lately I just wanted
to do a little bit of work on music,
audio support because of a couple of examples. Representative
60 this year, there were a couple of the
assignments that people did have a beginning programmers do some
basic sound and efficient. Uh, one of the
simulating a guitar sounds, uh, simulating individual screens
and uh, courts. And it turned out to
vote for that for example. But on a multi
touch device, it's a very different experience than if
you're working with us. So, uh, there
are some kinds of things that were in the world
so totally a little bit about the uh, what
the Sofia android and have to deal with this problem
. Well, I already mentioned that the android is
really intended for professional developers and uh it's not so
friendly dinners. Um, it turns out that a
lot of uh great guy lives on callback features in
many places, um, and call that teachers are
not leaving in uh, event listeners are ubiquitous in
a number of uh, frameworks in uh, current
frameworks in particular, uh because he had great doing
great, it's all that as well. But the
problem is, you know, there's been a fair
amount of work in the past on how to teach
beginners reporting program, how to teach them in an
eventful world how to teach them to read about dealing
with this. Because events in principle are really real
world actions that people do understand beginners don't typically have
about understanding that when I put my finger on the
screen, something is supposed to happen or when I
put them out something that's supposed to happen, right
? And they understand that idea of a physical event
and they understand that idea that physical causing the program
to do something. Um that's not so much an
issue, but it turns out that most designs,
the language features that are used for handling are not
necessarily the ones of debt prisoners forced. And in
many cases they might be uh features that students might
not master and go after their occurrence. Uh for
example, if you're writing a swing interface is really
common for people to produce anonymous inner classes and interfaces
possibly by using adaptive classes that are wired. Okay
. And uh that's a bunch of jargon, basically
nothing for beginners. You think the concepts that both
appears don't matter during the first wait. And that's
really the problem. Uh It's fine to say that
somebody has been programming for a couple of years already
seen these and so they'll understand what we need to
. Uh but whatever it is, why we have
to do that anyway. Is there a better way
? So, as an example of uh dispatch?
Uh what really is? Uh Well, it's simplest
form, right? You can think of uh the
observed that where you have uh, a two parties
, right? Uh some object uh that might change
state and some other object is interested. The object
is interested is called the observer. It wants to
know why the thing is interested in. It's your
about changes interested. And the job that's typically uh
well, there's a standard interface for Observer provided a
job to fill its called Observer. It shows kind
of economical way that many events dispatched job work.
That is there an interface that defines a method that's
going to be used for all that is. And
to use uh the event dispatcher. You're going to
have to provide a listener or receiver that implements this
interface and provides its own definition of method. And
inside it says what to do when that handle the
to respond to uh education. So for Observer,
there's only one event of interest. Uh and that's
actually one of the problems are observed. Great uh
Observer general pattern. Uh One of the difficulties,
which is uh the interface only defines one. Uh
call that one point of entry for the Observer,
the one who is interested in the changes. And
it becomes the programmers problem to figure out what changed
. How do I communicate the details of change?
And if you happen to be watching a big object
with a lot of information, you might be interested
in every possible change, you might be interested in
some, but filtering those out, that's your job
deciding how those changes turning property, other parts of
the code, that's your job. Uh Another example
, this is an example from swing to get a
job or a desktop application. Uh certainly uh going
somewhere and amounts there is another Internet is provided by
job for event dispatched. And the idea is part
of the program wants to respond to mass actions,
uh then you're going to have to create a listener
or an observer uh that implements this interface. Okay
. And that means your listeners going to have to
implement all of these methods. Okay? And say
what to do whenever anyone of these kinds of events
arrives. Okay. Uh, the uh program is
swinging probably there's also in swing an adapter class that
goes along with this interface. Uh that is there
is an empty uh, object provides the implementations for
all these methods. Would provide implementations provide object that
does not mean well, it turns out to solve
or partially solved one of the issues that we're using
this interface based approach to doing a dispatch. So
I mean that uh so the bottom line is that
in java using interfaces to mark methods that are used
for call that purposes on the dispatch is the typical
things that most Okay, the present, one of
the benefits of doing this is that when your listener
, your code that actually responds to the says that
implements the interface, then check that actually does provide
the correct methods, correct signature, that they're actually
they're they're actually present. So that check out the
statics. And that also means that inside the framework
inside, wherever the dispatch occurs, that can use
the regular method and location uh to invoke that way
. Both the method is the way to respond to
. Uh also leverages how reporting works in java uh
because you're using our bases in working class and just
override uh provided definition or overriding definition for methods declared
. Uh however, while using an interface does provide
liberal advantages and also uh has a couple of problems
. Uh One of the issues is really the motivation
for adapters and swim and that is uh library designers
are forced to make a choice when they designed these
interfaces. Right. One thing you can do is
you put every single callback method and air base and
then clamped. We won't end up too many separate
. Another is you can bundle them together into related
groups. Right? And then the client only has
two different ones. But the problem is if you
let them together in a group like the mouse listener
, uh, then a receiver that's going to receive
the event notifications has to implement all methods and interface
even if you only want to use one or two
of them. Okay, so there's kind of this
trade off. You have a large number of very
fine grained interfaces which have problems or do you have
a fewer number of groups interfaces which requires people that
perhaps implement methods that they're not used to anything and
adapters are partial answer to that problem. The reason
why swing as adapted classes that provide empty implementations for
all the methods and the listener interface. It's certainly
you write your own listener. You can extend that
adapter and you're the empty implementations for the methods or
not. You only have to provide override definition,
Kara. And that's always good if you happen to
be in a situation where your listener doesn't have taste
class and you can put the athlete has a base
class, but it started about that works so well
. Uh, if you're already has, uh,
you end up having to implement those empty methods yourself
. So that's certainly one of the problems. Another
issue is that when the callback interface for a bit
dispatch, it's fine. The person who defines it
has to pick the parameter types for the dispatch method
. Right. And call back. And um,
typically, uh, what those library designed to do
is pick a type that's big enough to call,
to cover all possible uses of that event, all
possible listeners that any programmer might want to write in
the future. And so what that means is they
end up with parameter types and event callback methods there
apparently general because they really didn't have to cover a
lot of possibilities. It might be more general than
you need, or more general that you would like
to work with, but you're stuck with the ones
that are prepared in the areas uh, laptop.
Is that uh, with these interventions when you have
a listener that influence uh, listen interface, like
the mouse listener case? Uh, like the observer
interface, uh, there is one and only one
method in that listener that corresponds to each of the
injuries in the nervous. And so if you actually
want to do different things at different times or if
you want to use the same listener approach to multiple
objects that you want to listen to. Uh,
all of those, the event notifications are going to
converge on that warrant operation and inside the operation of
the party. So those are three of the disadvantages
that come into play the jobless approach to doing this
. Uh other languages have different approaches uh mentioned it
really briefly in objective c uh, dispatch works a
little bit differently. That's partly because it's really inherited
model from small talk and the smallpox is interpreted in
effect, what you end up with a kind of
a dynamic method look up where uh if you're framework
is trying to fire an event uh on mature listener
, it will check with that listener implements the appropriate
method for receiving even and if not, we'll assume
the listener is not interested in the And so in
that case, you know, instead of having to
implement, provide into implementations for many words, you're
not Houston and you just need the code and it
gets resolved dynamic right. Of course, it has
other disadvantages, and one of the big disadvantages with
the dynamic approach that he uses is that there's no
status check. So if you don't if you intended
to provide a method but it's not there, or
if the member states, the long type of arguments
run into runtime persons that at some time in the
industry, um C Sharp uses a different approach with
delegates. And delegates are kind of cool because they
are in between in a way what job provides interfaces
and what objectives in small talk through the method look
up and they give you a more of the advantages
of both techniques. With fewer of the disadvantages.
Uh Very interesting as well, but they don't quite
cover all of the problems I'm going to talk about
today. Uh They don't quite have all the advantages
of the solution and I'm going to talk about.
Uh Plus you can use on the job, so
let's look at an example uh example, uh get
credit for a lot of variety. Uh He came
up with a very quick uh we came up with
this example that he called irritated agents because he didn't
want to be in charge of copyright infringement. But
as you can see that it involves a couple of
characters, some avian looking characters that you can claim
uh pigs, and when you get them pigs dying
. Uh So if you recognize that you probably know
what's going on, but you can imagine that that
might be the kind of thing interesting implement. It's
easier easily for beginner might get a kind of a
captivating examples which are the basics of how uh simple
program works in this case. Um It turns out
that using Sofia we can model these objects there on
the screen, relatively simple uh simply as classic classes
with some behaviors. And so we have a class
represent the birds, class represent the pigs. Uh
In this case they stand a base class that uses
a kidnap uh when you're on the screen. Right
? Uh then we've got this kind of an example
. So let's talk about the event dispatch in the
context of this example. And here, one of
the things I'm interested in is when two things interact
when they hit each other on the screen. And
I already mentioned that we want to provide uh collision
detection. And that's one of the situations where we
do some events dispatched. You know, we detected
22 objects collided. Uh we send a notification somewhere
, code has received that medication, do something in
response. Right, So that's kind of the situation
we're talking about. And if you want to do
that interfaces, there are a number of ways you
can think about doing it. Uh here is uh
one rendering uh code for work with the kids uh
in that example using an interface. Now you actually
write out the interface, you can kind of imagine
what it is and the code is here here,
I have a class you can think of. This
class is representing the main screens, uh the application
uh and it happens to implement this fictional listener class
that I called collision listener uh for the purposes of
example and collision has at least two methods, collisions
, uh handling methods declared in the interface. And
so this class has to implement both methods you see
here and the work that is called on collision between
and that's in the collision between shapes. Uh The
second one, a lot of it's also all on
collision between. Uh but it is about collusion between
single shape and the edge of the screen that you
want to do something. Well, I don't know
the balance between, probably not. Uh but they're
probably going to do something different objects to each other
than when they come to the boundaries of the view
. Right. And so this interface will give you
uh, capability of distinguishing between those two. Now
, some things to know about the first uh when
you're dealing with the method that deals with collisions between
shapes, uh, like I mentioned before, the
person who writes interface is probably going to use the
broadest possible because this event handler has to work for
all the situations. All right. So in that
case, you know, if there's a base class
called shapes that all shapes centrum gonna be natural things
that the event handler, in terms of two shapes
right now, might, in this particular case that
one of the shapes, bird and one of the
shape pigs have two birds are two kids have other
shapes. For example, it's on the screen that's
gonna fall over, but they're all shapes and all
the solutions will be handled through the same. Uh
Right, so that's the first thing to know more
general types, there's years development. Uh The second
thing is because of a more general types. One
of the things that have to happen inside is,
okay, let me figure out what the actual situations
, right. If one of the things is colliding
is a bird and the other one's pig oils and
bad pig, but I need to know which ones
to pick. Right. So we have a couple
of tests here. Uh one of them is about
checking to see if a bird flying pig. One
of them is about whether it's a bird houses smack
. Right? Um, but that test I'm gonna
have to write result is going to be a one
time test. You have to put it inside my
handler, right? Why? Because the framework nothing
about the classes that I would and there's nothing about
what collisions or you can see if there's about the
base classes and it knows that any collision has to
be recorded through those. Uh, inside let's say
that this is a collision between, right? Because
I have the general classes coming in as parameters.
I have to do some downed asking about the features
of a side effect of the fact that the types
, the operation are too broad for my needs.
Uh, like I said, if there are multiple
methods in the interface and they don't care about this
, maybe I don't want to provide the interview,
I still have a right in this case, I
already have in their base class, I use an
adapter. I'm gonna have to provide it on the
implementation for all of the words that I don't care
about because they're in the interface. So it turns
out that if you look across this whole screen,
if only these three lines in the middle Mac,
those three lines of the lines that actually do some
work. Um in this case, all they do
is say, oh, well when a big number
of people, I need to call this method so
I can take care of itself and we need to
call this method longer so you can take care of
itself. And we also need to publish forward about
it so that it can uh us job right?
But that's the action. The rest of the stuff
, it doesn't zoom computational work the application. Okay
. In fact, the rest of the code is
actually dispatched. Okay. The rest of the code
is deciding how to get the event to the place
, where the action happens, it's dispatched. It's
just that I have the right instead of dispatch behavior
of the framework classes. Okay. And that's really
the bottom line. And what I'm talking about here
, we have a whole handler that does dispatch added
onto the dispatch provided by the framework and its necessitated
by the limitations of the job interface that I happen
to you. Okay. Okay. So the difficulty
is that writing is a bit challenging for beginners.
It's not the beginners don't understand the idea of when
the bird is the figure dot right. The problem
is the rest of that could have nothing to do
with kids or what they do when they fly,
the rest of that coaches, infrastructure is about writing
the modification to the correct destination. Okay. And
that's not good for begin. Uh, there are
other problems for beginners, like I said, uh
, in many cases you can't have multiple handlers for
the same event on the same listener class because there's
only one entry point and so either you have to
take the method and clouded up with even more dispatch
code or you have to have a separate listener objects
and java swing in particular, it's quite common to
use anonymous inner classes without purpose. Uh, in
fact, a lot of some designers end up saying
, oh, what you should do is your business
logic, that is the work that actually happens and
put it in your model classes and instead think of
these listeners actually as lucrative as part of your controller
that is simply about rallying the interceptions to the correct
action on your model. Okay. And the problem
is begin to stop care about any of that.
They don't need to hear about it. They should
have to care about any of that. The real
question is, if this is a dispatch problem,
why is it hard framework dispatch? Why I had
to dispatch. All right. Let's make the framework
and the work. That's why it's called the frame
work. All right. And if we can get
around that so that we don't have to write a
second layer, just that inside urban handlers, then
our lives reason work and students like every reason and
the whole problem with complex, complex. So,
um, definitely the essence of the problem that put
up there is the action. The rest of the
stuff is just that clutter. Okay? So,
uh, what if what if it is different?
So, I'm going to show you first is all
right. What if we threw away up this guy's
? All right. Uh The action on the pig
is a pig. Back on the birds on what
you put some methods And the birds actually take care
of uh where you put on a collision in the
big Well, it turns out you were right on
collusion with the pig. Well, you're interested in
a way that not use a more general, use
a more specific type inside. You don't have a
downcast inside. You don't have to do the instance
of tests inside. You don't have any. This
actually can get right to the real What do I
do? Right? That's something that's your understanding,
you do the same thing, uh, hurt And
you can say all right, well, when the
vertical axis pig, I need to take action in
the class that have a bird, right? That
doesn't need to be mixed. Help response. And
actually I don't really need to mix in some third
object. That's a controller object. Not give all
. I'm talking about what actually happened. Right?
And so that's really the idea here is trying to
get to this model and so some of the things
. So here we've got a more specific type for
the candle. Not more general. Okay. We
actually have some facts listed here at the argument that
we're interested in this particular case. I think that
people then I'm saying I care about the birds and
I'm also saying I don't care about solutions. Things
are with alternatively, down here in the first class
, I'm saying I care about collisions with pigs and
I want to do one thing that I relied.
I also might care about solutions to something else and
I want to do something different when I collided.
That's something else. Okay. But I don't want
to write the logic to disentangle it on the framework
for. Alright. So that's really the what if
we're talking about here is trying to go to that
kind of a model where you write this code without
any of the additional dispatch theory uh, without converting
that controller food. Uh and what you're doing.
Um Now in this case, it turned out that
once again, the actions that I have are just
my delegation to other methods and we're gonna talk about
how to actually underneath the rappers entirely. Very so
we'll come after. So, uh All right.
The basic idea here then is to place all of
that work in the framework and how are we gonna
accomplish that? We've been working on that we actually
have a working prototype, uh, that irritated patients
actually uses. And the basic elements of our solution
, our first uh, to use reflection, java
reflection. To look up handlers based on their signatures
. Right? Instead of having uh, an interface
government findings handle, uh, we're going to compute
the binding uh, for each handler individuals and we're
going to compute that on first use and we're going
to do that by basically doing what job compiles would
do if this was static line source group. That
is, we're going to not just use uh,
we're all reflection, which requires you to know what
method you want to call exactly and where it's unclear
exactly. But instead what we want to do is
you want to say. All right, I just
received an object can receive an event. Let's look
for any words on it. And also search through
its parent faxes ancestry all the way as we go
. And at each level we're not just going to
search for a fixed signature. What we're going to
take the objects interacting with the parameter that we want
to provide the handler and use the same kind of
uh argument, compatibility, test the job of compiled
so that we can find the most specific handler for
the actual data that we have and use it.
Right? And that's the idea now because we're using
reflection because the search is not nearly as fast as
just going into a method called uh you get an
interview. Uh there is gonna be some performance impact
what we like to minimize. And and one way
to do that is to actually catch the results of
your, you know, you have an object of
type X. And you're trying to pass it to
a handler receiver of pipeline. When you look for
the handler, you can actually catch that information so
that you don't have to look for it again and
every time the future. That same combination. Yeah
, exactly. But there still is gonna be a
performance of the uh from the reflective. Okay,
now all these, it turned out that the reflected
dispatches simple catching and simple actually searching on the internet
and simple. The only part of this recipe that
is non trivial is in effect the compiler style match
between the actual argument that you're using an interpretation and
the variety of signatures on the possibly multiple handlers there
are available on the receiver and receiver. Right?
Uh That's the tricky part but it turned out that
it's not technically challenging. It's just annoying to have
to do the work of the uh but that's the
thing that makes this work in a more interesting way
than just saying that we're doing reflection. So uh
it turns out you can use this not just the
collision events that you can really use it with any
kind of events. And use exactly the same work
with what you can think of as traditional events.
Now, android device, you're worrying about touch events
instead of mouse events. But the idea is basically
the same. And so here again, with breakout
, you can see that you can have event handlers
deal with uh interaction user interaction events uh on the
battle, just as easily as you can have object
object interaction events on the whole. Right? So
uh I didn't actually get all those probably work on
the side of life. Uh some citations somewhere.
Uh We're actually a little bit. And why do
we call this texture? Well, the main reason
why type centre is in the title is because here
we're actually talking about driving the choice of which in
order to use based on static typing information program provides
the signatures of handlers. Right? And so we're
going to use the type of the data that we're
trying to communicate with the listener as well as the
static type of the signature of the listener to determine
whether corrective actions. Right? And it's being driven
by type. Uh That's a big difference from what
you can see the most dynamic languages where you don't
have access to that type of information and you can
use this strategy. Okay. Uh so we're gonna
try that part of the value from job type system
that we're going to bring the game. Uh Why
is multi dimensional? Well, uh for help with
one of them is it turns out that when you're
trying to dispatch a particularly in the application. Uh
huh. There are two separate things that you can
think about at least now that introduced one of them
. And certainly the type of the object uh Your
communicate the handler. Uh That object lives in their
entirety and depending on the particular subjects that type uh
you're using that as one dimensional choice in which to
invoke. Uh But it also turned out that the
events when a person is interacting with the screen,
there's also a physical kind of layout contains uh the
interface itself. And so you're also going to try
to look at the most specific the lowest child and
the hiring, so to speak. The most specific
region specific object that contains uh the location of the
interaction. But you're also going to look at his
parents'. It's physical parent and grandparent and uh ancestry
in the physical layout. Do we do with this
as well? And when you handle both of those
inventions? Uh at the same time? So that's
one reason. Another reason because in essence we actually
are a kind of multiple dispatch, multiple dispatch.
Uh for the for the term before is the idea
of getting Hollywood dispatch. Where you decide what methods
, Both, not just on based on the actual
type of the receiving object, the one that the
methods being cold, but also possibly on one or
more additional arguments along with the receiver and that based
on the types of arguments dynamically, you might choose
a different methods. Uh Job doesn't quite a quite
a uh it's relatively rare mainstream languages. Um but
the uh what we are doing is actually a kind
of because we're doing the dynamic search based on the
type of the argument as well as looking up the
receivers, uh flat tire to find the correct call
. So we can do that once we're not using
an interface into dispatch because we're actually looking up ourselves
and that is more computational advantage making the decision.
We could use more information that make different choices instead
of in the same choice for every morning. Okay
, so this type centric multidimensional approach them that I
talked about the offers a number of advantages over job
. I mean job interface based dispatch and one of
them is the fact that well now you can provide
only the handlers that you need to provide. You
don't have to worry about providing implementation of handlers that
you are not interested in because there is no air
base is gonna require. Okay, so you only
have to provide handlers uh in words that you want
and you can also provide them. Where do you
want them? In this case, I should provide
them in classes that represent individual objects and interface and
you can provide the handlers on very low level.
Uh, subclass is very high level level general classes
. You can even place them on containers and can
believe them where it's most natural and what that means
is there's no interface implement. Uh you don't have
the right things that you don't have to worry about
the adapters. So you can inherit methods stuff because
they're not. So those kinds of problems go away
. Uh That's true that the cops will also go
away with the sharks delegates and uh objective C uh
doesn't look up, but in this case, work
for competing on the same frame. Uh one way
that we're different than other target is with this approach
, you can use the parameter type of your choice
, the one that is most appropriate. All right
. Um, for the your handle and by expressing
the parameter type, you're in effect imposing a limit
or a screening condition on what you want to receive
. Right? If you say online collisions with pigs
, that's all you're gonna get. Okay. And
that's something that is done together purchased provide part of
the reason why it is because of the multiple dispatch
that we're doing. And that means that your english
, you're not forced to type. It also means
because you can use a specific type of one that
you don't have to perform an instance of tests because
of the framework majority, anything that's operating since and
you don't have to use downcast because you've got some
moralistic president parameter. So there's no captain. Uh
, that's uh, another thing is you have multiple
handlers, right? Because johN support overloading as you
saw the bird here that have one handler for a
separate collisions approach. And the reason why we have
all the ones because job supports overloading and because we're
doing the search dynamically, so we'll find the correct
one for a particular object involved in the rank.
And that means no. Again, no instance of
tests require. Uh, it means you don't have
to write a internal difficulties that kind of statement and
say, well, it was one of these things
I want to go this way. Something else going
that way. Uh, you don't need to use
anonymous classes. Quite different behaviors for the same method
being right. Have different actions for the same kind
of event because it's coming from a different kind of
uh, disadvantages for this approach. Uh Actually,
the biggest one is performance uh, and that you
have to pay for uh, reflect based dispatch instead
of a regular uh, reflection reflective base. This
performance is generally improving JBM. And one of the
things is if you're in with interactive events that are
occurring human time scale, then the small plots only
in the point of the dispatch is not such a
large number that compared to the time scale. So
that's the primary disadvantage. Another disadvantage is the reason
that look up dynamically. That means we are giving
up one kind of static check, right? We're
still going full checks on the types of signature of
the methods to make sure that the right text values
are going into the method. However, uh if
you use an interface and you say I declare this
is about the listener. The compiler checks that every
one of the handlers is properly declared that you have
a proper method means with the proper visibility, proper
return pipe. Right? That will be statically checked
by this approach because we're going to look up so
it's types based on the arguments, but you don't
get to check whether the method exists. Okay.
That also means you don't have to explicitly state just
to make sure you don't have to explicitly implement the
interface, but that does result in a little bit
uh lost their status check. Uh There are also
some additional considerations in terms of multi dispatch, there
were mentioning one of them is what happens when multiple
objects to be communicated handler instead of a single object
. Also, when you think about what happens when
multiple receivers are listening for the same kind of event
and that event occurs. How are you going to
deal with that? Um, or if one listener
happens to have multiple handlers? Multiple handling numbers on
the symbolism that all are really intended to respond to
the same kind of event. Um, and there's
there's a couple of other items here when you get
those for multiple objects events. A good example,
there is a break out that ball passing around for
assuming, I think in terms of uh one ball
, one brick, right? But it turned out
if you're lucky, you're the ball one goes up
might actually get multiple at the same time and you
deal with that as several single brick interactions. In
this case, when the ball is bouncing changes direction
, but it has several single brick interactions that I
wish, or do you want to hear about all
at the same time it hit three bricks at the
same time, it's too, at the same time
it was okay. And so we've been working on
that figure problem and devise an approach where, for
example, at least with collision detection, uh,
if you want to dispatch on a single object encounter
and you have to hit three bricks and you get
three event notifications. But if you like, you
can roll it all into a separate handlers that wants
to handle an arbitrary set of options. Right?
And you do the same kind of type patch on
the arguments to the event handle. Uh the other
thing to notice is uh in this case there's two
separate methods that might respond to the same kind of
event when the ball hits brick and how do you
deal with that? You want to go through the
fire? You want one to fire. And the
traditional version of three frameworks is to say, well
, your handler should return value and say whether it
consumes the event or whether it would like to allow
other listeners a chance to act in the event as
well. And we can do that also to say
, well, if you would like to preempt that
is, if you'd like to this handler to swallow
the events and keep covered english and seeing it,
then you can declare your handler with boolean return pipe
and through the results. Tell us for this particular
event or you gonna swallow it or do you want
the product? Right? Uh, but because we're
using reflective look up, we can also say beginners
and people in situations where it doesn't matter, can
simply use a void return type and he's an automatic
and you can control for the signature how much tailoring
of the handling of the events that we like to
impose and in a simpler, more common dates,
you don't have to uh, if there were multiple
objects that are listening to the same event, uh
, for example, the ball and maybe a higher
level object represents a practical, you all floating around
uh dispatched to those works the same way we would
do is dispatched to also handle words that are responsible
for receiving but allow any other premium or swallowing the
event. Keep it probably uh, alternative choices.
Uh, probably remember many examples. This is from
the all star break out with the paddle where I
could in and handle for a touch event when a
person drags and paddle and it turns out that something
years well, uh, as a result of the
interface is required. Most listeners at this level you
some kind of engineer event object passing the listener that
represents all the information we know about the event and
you have an unhappy it to figure out the particular
details. Uh, computers in particular, it would
be nice even if you can't really say what specific
subclass or general class. Uh we would like to
accept you have completely alternative parameter profiles that would uh
basically request that the framework do some limited unpacking 40
and that's just the and there's a lot more convenient
for beginners. Uh Final comment is about main flexibility
and here uh this is again that in the event
that once they call it a diamond that I said
before the really the advantage urges that you're doing away
with all dispatch except there's still one line of dispatch
coded right up there. There is a direct translation
between one collision with a method called and then saying
inside, I'm going to say what actual method on
the object. I want to do the real work
. Right? So there is one line of dispatch
code and you can actually imagine providing more flexibility in
terms of naming choices by using annotations and allow the
programmer to say, oh I have this thing called
guy and I would like to use it as the
event inward when I collided with. Okay, it's
a relatively small change. That is a natural extension
of the reflective look up, but it has a
lot of extra flexibility and then you don't really need
intermediate objects to handle different conditions for uh isn't complicated
from different sources because you can have as many members
in here you want with different things using anything you
want, but still highlands the appropriate events. In
fact goes further and say for beginners, they might
even care about the pictures. And so you can
imagine even uh uh signatures more flexible. Uh so
uh in summary, this sort of health centric multi
dimensional solution um is what we're looking at for.
Sophia I think you are. I hope that you
found somebody design issues interesting and provoking because most people
program uh seeing these issues in some context, but
this is a different approach to resolving and handling it
. Uh One that allows a lot more flexibility and
takes care of the drawbacks. So thank you very
much. You have questions I have to try to
them. Uh