okay
so yeah
welcome to the talk
I'm just for leaving this talk I start
that a prequel
and the prequel has a title 22
000 so the millennium
and the start of an undiagnosed PTSD
post-traumatic stress disorder
so I am Danita Clark and I'm president
and
Microsoft MVP and it coach at the dsoft
a nonprofit in Belgium who connects the
I.T industry with the social industry
and I'm very happy that I'm an MVP but
it's not to talk of today I'm not going
to talk about my greatest and latest
inclusion and software IDs it doesn't
matter
I'm going to talk today about my hunter
my mental health Journey
and things that not a lot of people know
of me
but it's my time to work it over time
um
since I was in 2000 my whole childhood
dagback difficulties I was different
different than the other child
and my parents needed help to find it
and they placed me to
a clinic where they needed to diagnose
my autism and unfortunately they not
only give my Otis mayonnaise they give
me a big traumatic experience
of the psychiatry
and it was a real big to Oma being being
afraid of being punished being afraid of
being away from my parents being afraid
for being locked up
let's say it's a nice backpack to start
your life your education your career
and so that impact your life and that
makes that to make small choices based
on anxiety so my whole life I am making
small choices based on anxiety should I
eat twice tonight
or not because I lost 40 kilo I maybe
ever eat flies I will become too fat
again should I eat two potatoes or three
or four or five I don't want to get
right anymore but I also don't want to
have anodexia oga a low energy power
so but will I be punished if I make a
choice and of course I only doing very
legal things not that a joke because I
really don't date to do bad things but
even for the very legal things I'm
afraid to being punished
and I ask everyone everything and at the
top of my 2000 experience 2017
I had my first relationship
and at this time still my only
relationship it was a lovely girl lady I
don't say her name due to privacy
it was a relation based on anxiety
we egg reinfoxing each other's anxiety
let the best intent but it was
I'm not going to detail just on both
relation with respect of her but one
thing is really important to enjoy the
rest of this talk if I was already
afraid anxious about psychiatrists and
psychologists
that relationship make it works
and 2020 who happened who knows what
happens in 2020 of course
no not kidding most people when being
afraid of getting sick due to covet
essay legitimacy and there are also
people not being unfaithful having it
but just messing the life missing
conferences missing travel missing their
friends they just a bit worked
I was scared to death
not for to death and the sons of having
covet but being punished if I walk
outside being more and more regulations
that I was not able to see my parents
anymore it was really not okay even I am
going together with an organization
itaka where I'm a double position client
and volunteer
I needed a special attached paper that
my parents always were able to visit me
and I them even when police shoot
control specific and folks lockdown
but that wasn't enough
and my anxiety was to the maximum and
physical tensions and pain
and yeah you know when he's going the
wrong part it can always be works
because there was to be my first
conference again would be in November
2021
at my birthday
I just catch covet in that moment myself
so my first conference birthday thing I
was in lockdown and to be honest I not
wasn't physically too sick
in my situation I'm not saying it's not
the world's disease in my situation as a
healthy man just lost at that time 40
kilos physically I could more than
handle it but my PTSD it was by anxiety
it was not not okay it was being even
more afraid of myself and I didn't like
to talk about it with my GP with my
coach due to my PTSD they will send me
to a psychiatrist
and it was oh my God test work dark days
so he became 2022 so we banned November
2021 not that good
then January 2022 this year
I really realized Danny you need help
and why did I know this I have one thing
that saved me
I have a very strong
limit bugging on days that I can't feel
the Press but normally I can be anxious
very anxious I'm constantly anxious most
of the time but also very happy positive
thinking and if I I and the body the
treasure dogs first days is maybe three
or five days Theory and a year of course
foreign
[Music]
I talked to my coach Alco who
unfortunately I knew Desi egg since last
week's I need to change coach just
because he has another job you know
there's no budget and social care
against okay but Alka I'm happy forgot
what you did see what's your name she
really helped me about my limits on both
do she say me you can't go to your
general practitioner and saying he that
he don't that he cannot send you to
upside countries psychologist and really
help you and the conversation started
and my GP let's say the way to heal was
started
foreign
good afternoon everybody and thank you
again for coming here from me this time
my childhood was not as eventful as
Denny's
however I did have various health issues
and
they put me in hospital a few times
which caused me to miss an amount of
school between the ages of 9 and 16.
thankfully the doctors didn't tell us
that it was anything serious so it was
just the time that I was missed but it
set me apart a little bit
on top of that even when I was at school
I was always the outsider
and
over the years from I don't know if that
tracks in Norway but from primary school
as a young child up until
college and university I went through an
amount of
mental and
physical bullying from the people that I
went to school with those wonderful
school years
best years of your life
really not even close
and for all the people that love to use
the English phrase sticks and stones may
break my bones but names will never hurt
me as a way of telling me that what was
happening was okay
it wasn't it was really bad
and that constant low level abuse
really affected me
to the point where
from a really young age I and until now
I I have dealt with analyzing ideation
I'll be honest I've been dealing with
this that long and that often I didn't
know it was weird until I was speaking
to a therapist about it and they told me
that it's not a usual thing and it's
taking energy from me
put all of that together through my
childhood
and I found it very very hard to make
friends
I'm 46 now and I find it just as hard to
make friends and it does affect my daily
life
my prequel I I kind of want to take you
back to 2018 before covert
this was the lowest part of my life
amazing
I had a job that I adored
I have had an amazing family it's had
because it was 2018 but I still have
them
I
had a young son who was just absolutely
squeaky I really should have been flying
but I wasn't I was supremely struggling
I couldn't do the most basic tasks
I would turn up to the office every day
but I couldn't do any of the work that I
was supposed to be doing I honestly
don't know how I wasn't fired or the
very least someone pulled me a sign and
say hey why aren't you pulling your
weight here
rather I would get in I would sit down
on my desk I would stare not at the
monitors but pass the monitors I would
bite back the tears and try and keep a
mask on my face and I would just want to
hide in a dark room or under the desk
Dad I'm gonna be honest home was
probably even worse
I work 36 hours a week when I got my son
I went down to 36 hours so on a Friday
afternoon I could spend time playing
with them and be with him and do stuff
and that really didn't happen
Friday afternoons were just spent on the
sofa
huddled in the corner
from the outside I was just staring into
space I
just look like really terrible
inattentive mother
inside my head it was a totally
different situation
I don't have
the language
adequately express how I was feeling at
this time
it's kind of a very strange nothing and
emptiness but that doesn't cover it
but on top of that I had a voice
screaming at me as well
you've taken 36 hours to play with your
son
why are you on the sofa get off this
over go play with him
why aren't you moving yet let's get off
the sofa joining his game it's what you
should be doing for why aren't you
moving
hours and hours long stuck on the sofa
with this
the guilt
I've not been able to physically move
and join in his games
still haunts me now
and at some point
it got too much the mask started to slip
and my partner noticed
and she said you need help
she convinced me to get an appointment
with the doctor who thankfully believed
me
and sent me to a therapist so that I
could start to work on my recovery
so Danny I need a break
maybe you can um
manifested itself for you
of course I can
so it's well known I already said that I
have autism or that I'm on the autistic
Spectrum
it's well known that those people have
difficulties with making eye contact
just common sense
but if I'm experiencing anxiety
my abilities to make eye contact uh
really really decreasing in the under
any logical term
and so if I need to talk with my coach
over my GP about stuff really deep
mental stuff my darkest thoughts my
anxiousness
then I cannot make eye contact with them
and if you don't make eye contact even
if people want to help you like and then
panic attack it may look selfish or
disinterested are not alert and then I'm
thinking a bit about the whole talk you
will see that I have the regional part
and emotional part and they are never
aligned
of course not
um so I know I came to the point that I
say to my coach or my GP okay I am
entirely going to look to the other side
like doing to the wall because Daniel
will hug my story
if I need to make eye contact you won't
talk at all
and it also comes the extreme need for
confirmations
you know
I already need lots of confirmations but
in time of anxiety I'm so unsecure I
should really call my dad to ask what to
eat tonight if I gonna have a drink
tonight how many potatoes or how many
meat I need to eat it's not okay but
it's only my parents and if it's my
parents and my coach what is it it's not
past but it's okay it can't be works
because you know I have an unprofit if
you need to call to your customers
and you need to ask them as they are
angry on you if you did something wrong
if you ask too much money everywhere too
late
it's not okay
and I'm calling on everyone appreciate
all the conversations so you have your
unique persons like my Province my coach
my GP
have your custom works and then you have
other people like friends or the people
that you interact with during the day
you got it so imagine imagine how
Negative they react if you need to ask
if you pretend that you are clever and
you can travel the world but you ask the
dumbest question did I do this good
I since I was 16 years old due to stress
pressure and my anxiety
it was causing physical tensions
So Physical muscles and organs organs
for coming together
tons together
and hurt hurt like hell
and even becoming inflammated
and of course there always should be a
workspark there's a taboo with this
because the location I will not say
there with the sun are very
it's a nice place let's say use a
hashtag no comments
and being a minority and a minority is
is something hateful
so
I'm going to sell support group of
people at autism
not all of them but the majority of
autistic people are introverted
and don't like the stuff like
conferences traveling all the stuff
I'm autistic extroverted I need all the
stimuli
and I'm suffering a PTSD and they are
also post-tromastic species of the that
I don't know everything about but a lot
of things they really don't understand
that I'm anxious of stuff
who has nobody else is anxious about
other things that they are anxious about
I just do that the biggest pleasure
Stacy have you something else on my
funny cocktail
I have some things and
for how my anxiety manifests is actually
a really tough question to answer
because there's such a wonderful
cocktail of stuff going on in my head
trying to figure out where some stops
and other stuff starts
it's really tough but there's a few
things that do come through
first one is what I said in the opening
that analyzing ideation
like I said it's happened that long and
that often that I honestly didn't
realize it wasn't normal now I do want
to stress that for me it is just the
ideation working out how to do it and
working out what the chances of it
working are and how I can't upset other
people by doing it and I could never do
the last two which I'm really pleased
about
I was working out with my therapist when
I must have started this and
I got to the point I must have been
about eight years old
when I first did this and
if something negative happened
so I couldn't complete a task
somebody bullied me thankfully that
happens less now than as a child
when I was clumsy which happens really
frequently if you're in the hotel at
breakfast this morning and you heard a
smash that was me dropping a plate and a
load of butter down my dress
this is immediately where my thoughts go
I also suffer from depressive mood
syndrome and
the line is a bit blurred here because
that is a diagnosis all by itself
but my depressive mood to trigger
anxiety attacks and my anxiety triggers
depressive mood attacks so they can be
kind of self-feeding
and this is what was happening when I
was on the sofa with my son just
not being able to move that really weird
empty feeling so I I can't say how it
felt but it was the worst feeling I've
ever had in my life
and I suffer a little bit with emotional
control problems and that manifests
itself in a few different ways now I
love coming to conferences because I
love seeing what I can learn I love
being inspired by other people and I
love seeing all the awesome new
technology I'm a geek
but it also means being with other
people and that is something that I
struggle with
more often than not traveling to a
conference or a meet-up especially in
the Netherlands when I'm driving there
I would be literally crying and having
to force myself to go forward because
all I want to do is turn around I use up
so much energy I get exhausted before I
start
and it's not just conferences I I can't
join in with
normal things my colleagues arranged to
go out after work and I just come up
with excuses
or I say yes and then I make myself
physically ill with stress leading up to
it
or I forced myself to go and I spend the
night climbing the walls biting back the
tears before I eventually have to leave
and break down
now I keep my mask in place my
colleagues generally don't know that
this happened to me
but as soon as you get out of sight that
mask disappears and it's awful
and it just means that a lot of the time
I just simply don't join in activities I
want to desperately
but I just can't get over the fear of
doing it
and it even comes down to things like
small talk having lunch with your
colleagues is something that is
incredibly difficult
for me to do
I just end up sitting there silently
listening if someone asked me a question
directly I'll give an answer and as soon
as it's out of my mouth I think well
that was stupid
Knox I want to say stupid things if I
just assume that anything that comes out
of my mouth is just blah
and it runs through my head in the world
I am just the biggest fool in the world
and everybody else thinks that too so I
just try and hide in the corner out of
the way where nobody can see me
put that all together and basically I
just spend my life assuming that every
interaction I have with another human
being is just them being polite to me
just long enough so that they can then
go off and find somebody they actually
want to talk to and somebody that's
worth their time
which leads me to shooting myself off
from the world
friends family strangers
it doesn't matter but in myself in the
same room as other people is really
dangerous for me and my mental health
but I want to circle around one bit
because there's an important Point here
and if a look at what Danny said about
how it affects him and the way it
affects me there's two things
we have the same things in different
things
so for example that need for validation
that's absolutely me it's
I can't cope with if we're saying
nothing you're doing it right I need to
know that I'm doing it right and that's
whether that's my job or whether that's
being with my friends and I feel really
bad for needing that validation because
I know I'm not the lowest maintenance
person to know and I apologize to
everybody for that
going back to Danny there are some
things that are absolutely not the same
and I want to go back to 2020 to covet
because that whole situation for the
world was terrible obviously
as far as my social anxiety goes it was
actually perfect because I could lock
myself in my house I could work remotely
I didn't have to socialize I didn't have
to see my colleagues apart from Zoom
calls and I actually recharged an amount
of time through that
says my things that are different Denny
what's different for you
maybe start at my similarities
I was also bullet a lot even after my
autism diagnose
uh but yeah it was not added in this
talk uh I have other talks talking about
my bullying
um and of course I have also differences
and I never had the and I live in
aviation
um even in my Works they even if I call
the past day is not in that part
um and what I have is just nobody was
interested in me like at the company the
factory for people with disabilities I
couldn't like I couldn't be a software
engineer or be able to program others
why you shouldn't be there
and yeah
emotional old books of course you have
it have you always uh
if people don't see you if they don't
want to see and then they want to
encourage you that you are wrong
um
so
yeah
you know what I mean
ah this has been really dark hasn't it
I'm afraid it's going to get darker just
for a few more minutes but there is some
light coming at the end don't worry
and uh well so let's get on with the
darkness so we can get it out of the way
and for this one I'm going to ask Danny
what have you done to help your anxiety
which didn't work for you yeah of course
we try things that don't work
unfortunately so I I am I was an expert
I would say I was but I'm still
unfortunately and next book and pseudo
positive thinking
so it's not the same as positive
thinking positive thinking I really
believe and that's good
said though positive thinking as seeing
the good things
that nothing is making fairy tales to
yourself that you know they are fairy
tales it's like in March 2020
it will be next month I will be
traveling again it's not that bad it's
also it's not only about each month
postponing is also that method not only
that then you are going to evaluate
yourself I'm not that anxious then I was
in 2017 when I had that I really call it
my relation based on anxiety it's not
that bad
and then you really need to look at the
mirror and say Denny are you kidding my
friend oh you are lying isn't really not
that bad
is it it works or at least the same then
he didn't need any which fairy tales do
you believe in
so yeah that episode of pseudo-positive
thinking
my
it's sad to say that but my autism self
support groups that really helped and
the fact of my autism really my anxiety
and my ultimate completely different
things
and for the whole anxiety part in this
difficult time it didn't help me at all
they couldn't understand that I need
stimuli I should be afraid of catching
kovit and and not be able to travel as
Justin imagine everything that's not
that bad and not be unable to go to your
provincial you even shouldn't want to go
to your parents and these times
they really didn't the people that I had
in the group they didn't do any do they
best to try to understand me that I'm
not only a person with autism but also
somebody that really severe anxieties
that really traumatic experiences with
PTSD even I say that myself and to the
void
and of course I know now we are going to
very specific topics but also didn't
help us decline in my own PTSD and sorry
sorry if my Province I'll be watching
this talk and they will do because they
are [ __ ] proud of me
but they they always acknowledged how
traumatic that experience in the child
Clinic was it a child trickity and they
shut me off talking about it in the past
you are you you put too much you think
too much about this don't think about
that so they there was a time that they
are I know declining my own PTSD you
shouldn't have PTSD just for going to a
clinic
but also myself you are thinking yeah
no no no it's really not that too it's
not okay then that
that times in the clinic
has even way more impact on me than I
can think this time it even works and I
take the impact it's not okay that's the
first normal thing ever perks on subject
anxiety or depression or just mental
health the first logical thing is
going through a therapist yes
don't don't trust them because there's
something broken and no I shouldn't say
they are even bad as I said 17 I just
have a confirmation of my ID
so you the club but I also was declining
my PTT I was not failing to talk each
day about my anxiety so let's say I was
in the quantum superposition of drama
and of course the people that you talk
to just be ignorable just too normal
don't ask for experts things you don't
need help you can all do it just do it
normal you know
Stacy what are yolks things that didn't
work
I have some things which they kind of
like quite similar I mean the first of
all was just simply ignoring it didn't
work
as I said I've had this since I was a
child and for the longest time I just
tried to ignore it and carry on with my
life just pretend it's not there
and obviously that didn't work there
were there were Downs
um
but I think I can count on one hand
the amount of days that I can actually
say I was if I understand the term
correctly happy because I don't actually
know what that's supposed to mean
so simply trying to pretend that this
wasn't a problem and forcing myself to
continue isn't an option
I also got advice from lots of people
trying to help me and that didn't work
either and the first one was just smile
there were times when I was doing my
best not to collapse as a complete mess
on the ground and somebody seriously
said to me you just need to smile
because that's going to release
endorphins in your brain and that will
change your mood
I don't know if that works for people
who aren't neurodiverse but I can tell
you it doesn't work for me
it has Zero Effect Factor has Less Than
Zero Effect because it makes me feel
actively worse because I am failing and
improving my mood by doing something
that everybody's telling me should
improve my mood
the other one that people like to say to
me about going out with colleagues and
things is do it anyway the more you do
it the easier it will get
I tried that and it did not get easier
if anything it got worse each time I
would try it I would be more of a wreck
before during and after and also trying
to figure out in my mind what am I doing
wrong that this isn't working for me
after six months I gave up because it
was just obviously going in the wrong
direction
and the other one and I know this works
for other people and I'm not trying to
say it shouldn't work for anybody but it
really doesn't work for me
yoga meditation and mindfulness
I have done yoga and you know what the
physical exercise part the stretching
I love it for the body I like yoga it
worked
didn't do anything to help my head but
for the body it was fine
what didn't help is being in a small
vestibule with 20 other people for 10
minutes before the start of the class
and then being in the class with them
them seeing you make your mistakes and
making a fool of yourself and then
leaving afterwards through one tiny door
figuring out where am I supposed to join
the queue to leave there's people
putting their mats back do I need to
wait back before I put my mat back and I
put it back now and it's it sounds
ridiculous when I say it but that is
what goes through my head
but the yoga itself physical exercise
awesome can recommend that
for the meditation
answer the mindfulness that was just
plainly awful that does absolutely
nothing for me and each yoga lesson
ended with 10 minutes of meditation
and at least half of them saw me biting
back Tears by the time I left and the
other half I was just so supremely bored
by the time it finished
now I'm going to be honest not all of
this is down to my anxiety I have a
couple of other issues too one of them
is I'm an infant I cannot visualize
anything in my head the Apple test
that's been doing the rounds I just see
a black
think there's nothing there so spending
10 minutes with somebody telling me to
imagine a scene picture yourself here
put yourself in contact with your body I
haven't got a clue what they're talking
about and I literally spent 10 minutes
okay I'm on a beach the sand it's gritty
there's a sea in front of me and this is
just a narrative description going over
and over in my head with me going why am
I not relaxing why is everybody else
this working and it's not working for me
it was
awful the other issue that I had is
misophonia there were certain sounds
that just completely trigger anxiety
attacks in me
half the music they use for this
meditation was actually quite nice if
you could filter out the instructor you
could kind of do something and half of
it just had certain things in it at
weird places that totally triggered you
and again I just want to climb the walls
and even if I could get past that
meditation in my head goes like this
okay relax
breathe in
breathe out
wait was that too fast how long should I
be holding my breath for
am I relaxing yet I'm not relaxing yet
oh crap I forgot to breathe uh okay I'm
still not relaxed what why can't I do
this
10 minutes long is not a good thing to
go through
mindfulness I don't know if I'm doing it
right or not but what I can say is being
in the moment and living what I'm doing
I can forget what I'm doing halfway
through doing my shoes up and I wish I
was joking there but I'm not
I can't be mindfulness about I can't do
mindfulness in what I'm doing because I
just zone out constantly and I've got no
clue so again the similar spy will start
why isn't this doing what it's supposed
to for me
this all sounds really negative
I think we're done with the dark stuff
now there might be a few bits put in but
I think we're done with the darkness
stuff now but I do want to really
stress all these things that we've said
haven't worked for us
it's the effort that we've put in and we
didn't get the payback
that we wanted circle around to what we
talked about after how it manifested
we're all different and we have
different manifestations of what's
Happening here because it didn't work
for us doesn't mean it's not going to
work for somebody else it simply means
that Denny didn't respond to the things
that he did and I didn't respond to the
things that I did I would not want to
tell anybody not to try anything because
maybe it might be life-changing for them
now let's get some proper positivity
into proceedings and start to smile
Denny yeah what did work for you a lot
of things but first they always say it
specifically at the 10 is to be where
guys approve of the pudding
in the eating
and you are saying that not the same
things are working for each of us for me
mindfulness yoga
and that stuff helps it really helps but
not enough
but it can help me by example getting
release tension and getting some basic
Quest I do batting exercises but just
started off
um
one of my customers RTD soft my
non-profit that I found it has an
practice of emotional Freedom techniques
and I'm a special one I really like this
mixed interactions where I am customer
but they are also customers of me it's
like different hats so I was making a
portal for that person
and I ever say I'm going to be customary
with you too I need some EFT for you
of course it was nice
it's like tapping on your face or on
your head so it's really tapping and
saying some mantras
was
didn't really help but I really don't
want to say that it was
counterproductive because it's not in
the last session for a reason
at this time it comes from the
alternative slash spiritual face like
flowers attraction is also come from and
I use it but that was specifically at
the time at my peak of anxiety this time
is all since covet and this time that I
really need to tank tank the [ __ ] God
damn conspiracy theorists
because thanks to them even nothing over
those spirituality is taking sogis
anymore thank you so much
and then you don't dare to give it to do
it fully
because you are afraid because it's
taboo to do spiritual stuff alternative
stuff
and if you does something if you don't
do it fully it you need to surrender to
these things
if everything has lies down on covet and
all the [ __ ] conspiracy sorry for
that worked I think I will try to do
that again from some little issues to
fix them still
so it was not available
[Music]
it's putting intentional pressure on
physical pops like example a towel
or a wall not at all
I should I will not put physical tension
on it
and so it's it's like thinking on a
problem or something that really makes
you afraid
meeting in putting real tension on it
breathing out
it was very special because it released
my attention I really the last month's
here let's say I had Chronicle tension
and pain physical pains you know in
strange places it was it could be over
four days or for I don't say weeks but
then they started to have panic attacks
and that I didn't have the fog so it was
very special it was a bit of
counterproductive because I knew the
psycho with it was a psychotist but that
ideation of a tragic techniques and
again I didn't trust it enough and I
didn't do it to the fully because it
couldn't focused and in the first
scenario maybe that I will need to go to
that person even they promise you will
not be needing to go ah
strange veins that I have
was a psycho-education
because I'm living with anxiety for such
long time and I was never daring I never
able to go to psychiatric clinical it's
also existing daycare or psychologist
one of the things that I do the psycho
education it can be one of one organic
group that you really learn on things
about anxiety because there's things to
know about it so I was not abled with
all the ZX and the same person Jordan
let's call it was able to give me it was
really a half a day psychoedication that
some people
I longed those really I didn't know even
that type of different kinds of banks of
anxiety and there are three girls are
not only triggers but three triggers and
and not only symptoms but three symptoms
and in fact you can know if this
happened this will automatically lead to
anxiety and panic attacks that was
whoa that was really really helpful to
learn this stuff like especially the
things who come before and if you can do
let's say quick fixes before it's going
too bad
as always was getting better but the
real real thing there's only being one
thing that really helps me is being just
100 I don't know sorry 100 is always a
lie so if people I want I plan to send
this link to my coaches and my GP I know
I'm saying 100 there's a lie so I am
maybe you see me speaking at the
conference I'm not in yoga and yoga
physics it will be better but being open
and vulnerable and trust them really
trust them I'm being really really open
and vulnerable about even your darkest
darkest thoughts are the most ridiculous
things that I'm anxious about just like
walking outside the stream and being
arrested it's not really that thing that
happens a lot
and that really helps I really and also
explaining how bad that I feel and some
reactions and sometimes also a bit about
my traumatic experience that I had
before but also being able to say to
them I really don't dare to talk about
it I feel that there's a problem but
maybe if I talk about it I will reinfox
and Law of Attraction and it will happen
again just being able to say those
things to them
that's magical honestly and that really
helps me
and sometimes you need to do it's like a
status and and it's not org you need to
be open you need to do that exercises
and some breading and some project you
need to knowledge and sometimes they
sell No Love
I need to take some medication
and for some people that's really taboo
because people are very very irrational
they forgot one thing they forgot that
your thoughts are in your brain and your
brains are physical physical part of
your body your brains and anxious
feelings and depressed feelings these
are just
different ways of working the the body
and so they take if I really hurt my arm
or break my leg it's okay to take
medication pain Kelloggs if I have
inflammation let's take medication
but if I have mentally deep problems
that's not my body I just imagine this
no no this Arc stuff in your brain so I
don't say you need to do this and I will
not say any name
because it's just like physical
medication for physical things it's just
the same it's your own GP doctor or
specialist in The Psychotic it doesn't
matter so especially starting old GP
that need to decide what medication is
needed for you and will maybe how to
cure you
yeah
so Stacy what did help for you in fact
well the first thing that really helped
me is actually what I'm doing right now
so thank you everybody because speaking
and standing on stage
has been amazing in my life and this
seems really counter-intuitive because
I've just told you that I struggle being
around people I struggle with crowds
I get anxiety whilst traveling and yet
here I am in a different country in
front of a load of people with 2 800
people I heard walking around here and
I'm saying that this helps me
it's really hard to explain the
traveling in the hallway track totally
trigger me that still gives me humongous
amounts of anxiety it can be really hard
but when I get on here on the podium and
I get to talk
and I get to share in my technical
sessions my knowledge with people and
hopefully introduce them to awesome new
stuff
and in these sessions where I get to
just like be open
and try and help people going through
the same thing
I just love it
there's also something to remember and I
mean this in the nicest possible way but
this is not me having a random
conversation with somebody in the
hallway track this is basically me and
Denny having a monologue
when I was young I always wanted to be
an actor I don't know if life is in the
room but he asked what's your dream last
my dream is to be an actor but I never
followed it up because it caused anxiety
thinking about it
maybe I should try it
but being here and doing this it makes a
huge difference and the energy that it
gives me is spectacular
it also gives me a connection which I
wasn't used to or expecting to be honest
when I started speaking in 2019 I met
this amazing group of people it was the
other speakers and I have never met
another group so supportive so wanting
you to succeed so wanting to help you
and I'm just honored that I can call an
amount of those people my friends now
and I never expected to use that phrase
ever
but it's not only the speakers it's also
you the attendees
I struggle in the hallway put me into a
room with a thousand or 2800 people
and I get so lonely it is physically
painful
I cannot go up to somebody and start a
conversation
however if somebody wants to come up to
me and speak to me I can't kind of do
that conversation and some of the
discussions I've had after I've got off
the stage some of the people I've met
have been absolutely amazing and the
energy that I get from all of this as a
whole more than makes up for the energy
it takes to actually get here and deal
with the anxiety
on a more therapeutic side something
that has really helped me is EMDR eye
movement desensitization and
reprocessing and I said it correctly
first time that did not happen during
the rehearsals I can tell you
when I was working through therapy one
of the things that
came up was as well as anxiety in the
depressive mood I also have cptsd
complex post-traumatic stress disorder
that one's easier than EMDR
and it
it's PST pstd okay maybe it's not that
isn't just built up by one big event it
is something that happens with lots of
possibly small insignificant events that
just happen over time and this CPA no
and that just totally contributed to my
anxiety
so what is EMDR and how does it help
well it's a therapy that uses eye
movements to help you process the trauma
I have no idea how it works it sounds
like magic but it actually worked it was
awesome basically you visualize the
trauma and then the therapist waves
something in front of your eyes and you
follow it with your eyeballs which is
really exhausting it's amazing how much
energy it takes to move your eyes
and it somehow helped reprocess
something in your brain and it helps you
move on a little bit
I said visualize which is interesting
because five minutes ago I said that I'm
an a fan and I can't visualize and it
actually took me a while to find a
therapist that was prepared to try
things to see if they could work with me
and what my therapist did rather than
visualizing an event because my memory
doesn't work like that either I can't
pull up individual events from my
childhood that well
she worked more on clusters that all
brought about the same emotions and what
she would do is speak to me until those
emotions surfaced then she'd do the side
to side thing and
we'd work on it that way it was really
hard
some clusters took more than one session
to work through and at the end of those
sessions I was broken and I was broken
for days after it finished
but I kept at it and over a course of
about six months we managed to work
through them all and like I said I've
got no idea how this works seems like
magic
but I still have all the same memories
but they really don't have the same
emotional impact as they had before
the last thing that helped
acceptance and self-introspection
this was the hardest thing to learn but
I don't know if I learned to accept
myself or it's just at some point I did
and accept myself as in my foibles my
flaws my weaknesses my strengths because
people tell me I have them
my quirks my idiosyncrasies my
everything
I am who I am
and I'm not going to change anymore
I'm not going to be somebody else
and I'm not going to be somebody else's
idea of who I should be
I'm gonna try with the last one I'm
still struggling but I'm working at it
so
hi
I'm Stacy I adore building stuff with
Lego I have a house full of it I love
the Marvel MCU sorry Jimmy if you're
ever watching this but hashtag team
Marvel I love cars and speed and
adrenaline and gadgets Tech is awesome I
obviously love 50s style I love books do
I don't read as often as I wish I did I
love stuff which other people think is
childish or silly
who's silly I like to be serious too I'm
me
I'm in no way chord I still have anxiety
I still have depressive moods I still
have lots of problems though I think I
have accepted that I can be content with
my life and see Joy without actually
knowing what the term happy Means and if
it applies to me
when I got to this point I actually
started to see the layers underneath the
anxiety and I started to explore those
too it's like Shrek with the onions I
have layers
and as the next one was visible I
started to work on it and after some
time and a lot of research
probably also got undiagnosed ADHD and I
say probably because my therapist has
worked with me on this and gone yeah you
fulfill the criteria it's a good chance
but you can't get a diagnosis without a
psychiatrist where I live and it can
have legal implications and I don't know
if I want to go down that road yet we'll
see what happens in the future
but it doesn't matter
whether or not it gets made official
knowing about it and looking at the
accommodations that you can do to help
that have helped me in my handbag
there's noise canceling headphones
because if the noise out there gets too
much those headphones are on and it will
bring me down just a tiny weeny little
bit
I make sure that I can escape to places
I can see stuff coming now and I can try
and
not control it before it happens but I
can try and take mitigating steps to
stop it all of this has helped me lower
my anxiety
a reasonable amount
if any
back to you
just a small thing to add from my side
as at we didn't help it's just the same
this is our experience there's my work
for you what helped Focus but it also
may not work for you
one thing that definitely else helps is
if you have support from your friend
from your family
but not everything that people say or do
even not everything they say or do but
the best intent is good for you
people can't say advices but they're
really really best intent
but that does make it works
and then being able to think about it to
reflect about it to feel about it and
then to talk about it as something is
really really a skill
I want to give you also some tips what
can you do
and the people watching this talk and
all the other people that should know
this kind of talk should be broadcasted
on National Television instead of the
other drama
and just listen to me and don't judge me
if I'm afraid of X by example being
alone at home and maybe not being able
to contact but that I should be afraid
of that catching covet and dying even if
I'm willing to explain something
please don't act as you are pretending
they ask that I am at the time there are
people saying that I potent
that I know was good for me but that I
don't know
if you do that you will be stronger the
trust in you will be completely over
maybe you want this
um and if something not relative or not
relevant or not believable from York
perspective
that doesn't make it a lie in my
perspective
and be kind
some people I don't do need the heart
hand
as some people need the soft hand and I
am a white middle-aged man
35 years old
but I definitely need the soft hand I
need to cuddling
I need that of a good thing on the world
oh you did it good too yeah you did it
do it yeah that's okay you feel safe the
hard way like on sometimes on television
the personal coaches there's the whole
table Justice For me even mug
and sometimes it's a shame to say it in
my situation
um so if you really think you need to
reinforce the heart the heart heart
methodology okay first of all be
completely collapse even more than it is
done
uh I just need to say one thing mug
must really also have for me is being
traveling being at the conference being
in the scene and faithless has a very
famous song
gold as a DJ
but I am saying conferences are my
therapists
ah and for me the tip for how somebody
can help me
talk to me it's really that simple
if I'm standing in the corner at a
conference at a party
wherever
come up and speak to me I would really
appreciate it
I might not be up to having a
conversation because it might be too far
gone but believe me I will appreciate
the effort
and if I'm having a major attack
also talk to me
there was an
absolute non-zero chance that I will be
physically incapable of actually
verbalizing an answer to you
but if there's just somebody there and
they're supporting it makes the world of
difference
someone being there until you come back
down to earth
so
that's how experience is but obviously
we want to give you some leaving
messages too things that you can do
take away with you and think about
now the first one is Denny and I
are not therapists we are not experts
and we are not professionals we are just
people who have been through this and we
want to help others and that means and I
know repeating ourselves here everything
that we have said is only valid for
Denny and for myself other people may
have entirely different
um responses
we also want to say that if you are
talking to somebody who's got mental
health issues please remember that
you're also not a therapist and
please think about what Denny said with
the advice and what I've said with the
advice so much that's been given to us
over the years has been given with such
truly good intentions but it's had
totally the wrong impact
and this memes that go around the
internet that you've probably seen
comparing mental health to physical
health and I love them because it
totally visualizes how it is in my head
I have a trick knee
it plays up occasionally and it is
seriously painful and you know what when
I'm in agony not one person has ever
told me to just go for a walk or to just
go for a run or to just think happy
thoughts and the pain will go away now
obviously they tell me sit down you
can't stand up
and they tell me to take it easy and to
stop running for a week and I ignore
them and make it worse
and mental health
is the same and yet people just
generally don't really treat it that way
I just get you're fine everybody has
anxiousness
everybody struggles with these things
and they're saying it in a really
supportive way and it's what they think
they're doing but actually it's just
dismissive to me
it comes across as saying that you're
not really struggling
I'm not having problems my issues aren't
real everybody has these and they can
carry on
if that's true then why the hell does it
simply destroy me when it happens to me
so if you're talking to somebody with
mental health issues please please don't
give them the advice that you think that
you should be giving them don't tell
them what they should do or what they
should feel listen to them and let them
tell you what they need
Denny this is so important
so important and I want to thank you
that you are not a therapist
otherwise I wouldn't be able to perform
this code talk with you today because I
wouldn't beg
but yeah we are all different we all
have different experiences there's no
one right way of having social anxiety
there's no wrong way it's not that by
example that but my experience is that
all the therapists are bad of course
it's not true it is not that but it's
also not that everybody having
difficulty should go to be mandatory to
go today if you don't date then it is
just listen listen be the most important
thing and most of the time people know
what they need and people know what they
need and which specific situation
so just listen to them and ask what do
you need how can I accommodate you do
you need facilities what can I do to
make you feel better and understand and
don't don't judge
you cannot judge about an object's
emotion it's not working
so it's for everyone different how
anxiety manifests when the young Angus
were not like no he I'm doesn't look
anxious only I'm not I'm not anxious at
that moment but as you saw me last week
at home and my coach I had again very
anxiety and between two conferences
I know maybe you can't imagine who was
Denny
a week ago
on Tuesday night
and so don't say it's a lie because you
didn't see so
as I said conferences are therapists
and it's okay to talk about this yeah I
really it's great to talk about it and
it's okay to say that she shouldn't
block you but it's also okay if you
don't talk about if you you cannot do it
if you are on a point that you really
cannot talk about this they cannot
mandate you to talk about it it's also
okay
they look in fact I say the truth in
fact it's just all about acceptance and
not judging if I want to talk about this
it's okay you shouldn't say
about these things we don't talk about
if I have the need it helps to talk
about do it
but I shouldn't require you yeah also
tell you your my your darkest thoughts
please so it's all only personal
experiences
but thankfully I see there's more and
more returning point a nice Peak was
started speaking at conferences 2017.
they wouldn't be so many people
ought to talk about dark Mental Health
so
task wait
and I I think I just want to totally
Echo what Denny said that my whole
reason for writing this talk with Denny
and for putting myself through a little
bit of Health to open up the amount that
I have done to do it is
when I was really struggling it was such
a taboo nobody was talking about it and
I was terrified that if I said a word
people would just
totally judge me and think really bad
things about me
and so I want to start that conversation
I want people to feel that they can talk
about it if they want to but also just
like Denny says
if you can't talk about it if it is too
hard please do not look at us and think
I should be talking about this and force
yourself make sure that you look after
yourselves too please
I want to thank you so much for spending
this time listening to us
oh and apparently we have a last slide
ah yes that's life but thank you so much
[Applause]
question
because we are Tech heads we know that
means
I'm talking helps and like Dennis said
it can be hard
for your GP or friends and family and
I'm currently volunteering for a health
line okay well Jeff is also asked for
all the regions here or people living in
Norway
remember that
that you don't need to if you're a
student title you can call us but you
don't need to be suicidal to call us or
a local helpline where you live
talking about it Robert ducking can't
help
can help you are Anonymous we can't
punish you we can't do anything
but yeah talk about it don't have it
don't do it in your hand awesome thank
you very much can I get the link for
that so I can tweet it out when we're
done yeah thank you
any other comments or questions or do
you just all want to escape now oh wait
often works man just come to us
afterwards not in the public everything
is possible
thank you thank you again yeah
all right have everyone arrived in the
back there it's kind of hard to see but
I can see some familiar faces uh Martin
yay hey Martin all right hi everyone I'm
Theodore
I'm Matthias
and yeah so how did we end up here right
we um we sort of recently inherited a
rather large application written in
F-sharp and one of the first things that
happened after we had inherited it was
like somebody from the F sharp Meetup
Community came and said oh how would you
like to keep a talk about F sharp
and yeah we were sort of like oh yeah it
would be very nice to give a talk but we
have uh we have experience with this
system like a month and we haven't
written that much F sharp you're really
sure you want to talk from us and they
went yeah yeah we want talks
also all right so what do you suppose
that we should talk about then yeah we
don't have this much experience well you
can just talk about inheriting a system
we haven't had a lot talks a lot of
talks about that
so I guess after some Shin kicking and
arm twisting from some people you know
who you are we ended up here
so yeah the outline for this talk is
like we're going to try to give you some
context uh to bring along on this
journey because like a good story isn't
good if you know where it's set
and then we're going to try to dive into
our personal inheritance story and we're
going to try to do that within a
framework that sort of gives you a
couple of tips on how you can make your
newly written application a little bit
easier for the next developer
and then finally we're going to talk a
bit about ownership and um and sort of
reflect on whether or not we feel
ownership of this application today so
those of you that have worked on the
application we're going to talk about
this is hopefully the most interesting
section for you
but all right let's start with context
so
um where do we work well we work at nrk
it's a Norwegian Broadcasting
Corporation and uh like we do television
and radio and all those good stuff and
of course we have a streaming service
you can't like produce video and not
have a streaming service these days and
it's um custom built in-house we're very
proud of it and we're sort of working on
a part of of that big project
but you didn't come here to learn about
nrk although we're going to sneak a
little bit of nrk into everything we do
here
so let's move on to our self
um I think in most talks you don't
really need to know a lot about those
giving the presentation but in this
instance it might actually be a point
because I mean everybody's experience is
going to be shaped by what they've done
previously so in order to understand why
our experiences were the way they were
you probably need to know a little bit
about our background before we started
inheriting this application
so let's talk about me it's my favorite
talking point
I'm sort of I ended up being this kind
of.net Enterprise guy uh I didn't plan
on it and I guess some of my study mates
have sort of uh might be quite surprised
I ended up that way but you sort of you
start working and don't not have all
these nice features and then you get
paid a lot to work on like business
critical applications and they made it
without net and Microsoft support and
all that stuff
so in the new team that doesn't know my
other background they're sort of like oh
Theodore yeah he's the guy that likes
MSN and Microsoft learning and he
probably reads all that stuff before he
goes to bed
I've been F sharp curious for a while
and I've done a little bit at home and
um sort of like small projects at my
previous place of employment but never
in the scale I do now with nrk
but Matthias I am Matthias I've been
working at Nokia for two years
before that I worked with a power
analysis tool
uh with written in Python so I hadn't
touched.net before with that
so switching to F sharp was okay because
it has at least less brackets than C
sharp so probably the.net language that
looks most like partner
and we think that we might represent two
archetypes that move into F sharp so
like the.net developer that's done a lot
of C sharp but not a lot of F sharp and
the developer that hasn't done a lot
of.net at all but finds F sharp to be a
curious language
so it wouldn't be nice to tell you a
story without giving you the context
it would be like telling you a fairy
tale while you're assuming it was a
SciFi thriller or something so
PS personalization the application we're
working with
that we're inherited is all about you
it's a system that handles
personalization in nrk TV and energy
radio
so what do you mean when we talk about
personalization
yeah it's a really broad topic and I
don't think we can say that we handle
the entire uh problem of personalization
at nrk but we do a slice of it and of
course recommendations for instance is a
personalized service that doesn't fall
under our umbrella but we're going to
talk mainly about two features that I
sort of our bread and better
and that's our favorites so if you like
a particular show or a standalone
program or a radio program or a podcast
you can put a favorite star on it and
then you'll get that presented to you
much further up so you can find your
favorites uh easier when you log on
we also do consumption and the idea by
tracking consumption is that when you
wake up in the morning and press play on
the newest news show and then you make
yourself breakfast and then you finish
your breakfast the show is half played
you move along you go on the bus you
open your mobile phone you press play
again then we know that you left off at
that point and we can start and pick up
the playback from the same point so you
don't need to seek forward and backwards
and all these features are only for
logged in users so you if you don't have
an nrk account yet please create an nrk
account
um but yes there are some consequences
of this functionality being sort of
personalized and can you tell me more
about them so uh functionality for each
user is separate and independent from
another so if there is no shared State
between the users
and we need to handle things pretty
quickly when someone asks for their
favorite shows or how long they have
come in a certain episode
so also an area can be isolated too and
only affects one user and boy we do care
that stuff works at an okay so we have
divided each service in different colors
we have red
that is very essential
and we have yellow that is somewhat
essential and we have green as it's nice
to have features
and the architect typical red service is
typical the front page or playback
you expect to play episodes and movies
at an okay if that don't work something
is deeply wrong people tend to complain
if their News television program doesn't
work and especially when stuff happens
in the world it's uh yeah it must work
it's a red service yeah so PS
personalization is a green service lucky
for us it's nice to have feature
and we do think that the inheriting uh
nice to have feature service makes
things a lot easier for new developers I
mean the
sort of when we had to get over the
hurdle of doing the first deployment it
wasn't that hard because we knew even if
we break stuff it's not going to be like
a massive failure on lrk sport so maybe
in hurting green systems are a bit
easier than everything in red system
so let's also have a a quick look at the
traffic in PS personalization
even though we're only serving
authenticated users we are having a lot
of traffic between 50 and 80 million
requests every day
the majority of requests are progress
reports
so when
people use energy TV or radio we want
the users to register progress at least
every 30 seconds but also at pause and
play and skip
so
during the day that will get a lot of
traffic
so whenever you press play on nrk please
think of us we think a lot about you
when you press play
so let's look at the average workday
I like to think of it as it starts it at
6 a.m and up to uh Peak at around almost
eight people are going to the to the
jobs
they're getting updated on the recent
news
listening to podcasts
I do think you're a bit optimistic okay
so uh I remember we took a look and it's
like a mostly children's television
programming at the start of the day yeah
so yeah maybe some people are using an
archae like uh yeah daycare service I
guess daycare is sort of a public health
kind of thing in Norway so yeah
yeah public service that makes sense and
if you look at average Sunday we can see
that
the peak starts about the local Peak
starts about the same time but it's
lasts longer during the um
the day
and it also gets a peak around the
evening uh the average Sunday gets
around 1700 requests per second
and
a little bit about the big dates in case
personalization
uh Easter Sunday 2022 was that they were
the most traffic
we had almost 2 100 requests per second
um yeah so it was like a regular Sunday
but on speed
I guess Easter is a big time of year for
us so for the best mix of people staying
at home and people wanting to watch
stuff and all those good things
and also a small curiosity around seven
o'clock
there's a small dip in traffic that
means people are going from on demand
streaming to live streaming we don't get
any traffic from the live streaming
service
yeah so we have a sort of a Hallmark in
every in Norwegian home is actually
turning on old style television and
watching nrk news at seven o'clock
doctor
but at some point we'll turn off a
regular TV and only get everyone in on
video on the mount and finally there's a
big difference between the minimum
maximum in traffic here so like a
scalable system would be nice
but you're probably dying to learn
something about inheriting applications
so
let's talk about inheriting an
application then
so before we're going through this
section with uh some small stories about
our experience of inheriting PS
personalization we thought we wanted to
give you sort of a mental image and
framework for thinking about how
applications are experienced by the next
developer
so let's say you're the original
developer or you're a developer that's
been there the most you have this wide
understanding of the entire application
you're able to see the entire horse and
the background and the man on top and of
course you are because you built most of
it yourself you raised that horse from
it was little you you probably are the
guy on top
and you might have even built the
buildings in the background
and the thing to remember is that people
inheriting applications they don't view
them like this they're not going to see
the entire horse what they're going to
see is
only a slight part of it
like when you're inheriting stuff you
view it through this tiny peephole from
it's like being in one room and standing
on one side trying to look through the
keyhole in a door into another room and
finding out whether or not there is a
horse or a donkey in the other room
it's pretty hard
but if you keep this mental image in the
back of your mind as you develop you can
use this understanding in order to
facilitate that kind of viewing of code
better so we have picked out three tips
that we hope are going to be beneficial
for everybody writing software that they
actually want somebody else to maintain
later
so let's start off with the first step
the first tip is sort of like
sidestepping the entire problem
as long as you're able to put code and
other important stuff within the same
cone of vision then there's no problem
you can work with that without
understanding anything else
the only problem is
um like if you want your software to do
anything interesting it's really hard to
only write software that works this way
because in order for some tiny piece to
do something interesting it usually has
to communicate with the entire whole
but there are a lot of techniques you
can use to make things a little bit
easier like trying to put stuff that
changes together in the same place
spending time on folder structure and
naming and sort of trying to guide the
developer in the right way and feel that
they are the same place when they work
with the same sort of related things
it's uh it's simple in principle but
it's really hard to do in practice so uh
we we're going to go through some
examples that we've seen in peace
personalization starting off with our
the main mole so here we have an example
of discriminated Union
so you learn a lot about the domain when
you're reading the code for this one
in this example I learned a lot but what
you can favor rise in energy TV and
radio
so you can see that you can favor his
favorites a TV series a radio series
podcast series TV Standalone program and
radio Standalone program
so fortunately having a concise type
domain model
helps a lot keeping of the keeping
important stuff in view and I mean the
first time I saw this I was like why our
TV series not just the list of
Standalone programs why is this a
separate concept this makes no sense
whatsoever
yeah you explain it yeah and what we
learned was
TV Standalone program it's just a fancy
word for a movie or a documentary yes
with something completely different
entirely
so although things in the main model
might look really strange at first
glance It's usually the start of a good
story so I started Envision everyone at
nrk going down to Kulu Sam like a movie
theater and they'd be like oh let's go
to the single Standalone TV program
together and that's why I think it's for
this next big Standalone program it's
going to be great
and as an aside
um our domain model and actually most of
the code we have written are written in
the region and at least for the main
model we have found that to be
beneficial it makes it a lot easier to
communicate with the
non-programmers uh or people not sort of
into that slice of code and when you
hear other people talking about stuff
that is related to the stuff you're
working on it's a lot easier to relate
the same words get used over and over
again
and I mean here in Norway we like to
think that we are really good at
speaking English and understanding
English and I guess we are but as we
most definitely felt while preparing for
this talk it's sort of a big gap from a
native speaker to in Norwegian English
speaker so you don't need to make your
job harder if you don't have to at nrk
it's a Norwegian working language we can
use Norwegian and the concepts are
Norwegian so yeah don't be afraid of use
Norwegian in your code yeah and the code
is not only Innovation we also have
Norwegian dialects so some parts of the
code is written in chandesh so we have
a Moodle tester
[Laughter]
and we tend to joke that that's because
since nrk have to produce stuff in both
like in several written versions of the
region this is sort of our district
mandatory
distributed language Norwegian dialect
part we should probably have some Samia
there as well
yeah and in the beginning your vision of
the functionality that application
provides is also Limited
so therefore it's a lot easier to start
working on features that has a limited
functional scope
so when I start started working with the
past personalization my first feature
was to move database level series
serialization to Bluetooth buff
that was hard because you needed to know
about the know a lot about the domain
and touch
uh almost the whole code base
is this thing going to be serialized to
the database yes it is and you can ask
that question again and again throughout
the code base yeah and the other
personality was part of
to me was a radio clip it um it had a
much more limited scope
so I didn't feel anything about these
problems because I arrived in November
and in November I got the story from
guide we're starting up doing push
notifications it's this kind of separate
thing on the side you don't need to
learn about a lot about the other stuff
and it's been smooth sailing ever since
I guess the drawback is that I only know
about push notifications now but I know
them very well
yes so what do you do when you can't
keep everything in view well there's
several thing you can do and one of them
is to think of your code base as being a
mountain landscape with higher Peaks and
dangerous streams and other things
places where things could go awry
and like when you're going from a Hut to
another Hut there might be a part and on
the long the way you probably want some
science to tell you that you're heading
in the right direction
so we want to make the case that using
sign posting in your code could be a
good thing in order to help the next
developer
so you can signpost in a lot of ways one
of the more simple ways of doing it is
just to write some good comments
and that's an easy thing to say but it's
really hard to do in practice
so um with a comment or two you can sort
of hint that all right if you change
this piece of code you should probably
also be looking in this other place of
the code base
and by doing that you can give people a
little Health heads up that there are
more pieces to the puzzle than the one
you're currently viewing
and we felt we had done a good job at
this
um here is an example from
personalifications uh so due to
constraints and let's leave it at
constraints we ended up with saying that
all right when you first use push
notifications we don't want to enable it
by default that you get stuff pushed out
to you so we want sort of the default
initialized value to be false and we
have that two places in the code so
there's like the main place and then
there's this little place on the side
where you need it because architecture
and reasons
well we're going to fix it we're going
to put up this nice big sign saying that
if you change this value you need to
look in this other place as well
and we were very happy with ourselves
and we even said like all right we're
going to try to break this now before
the talk so we can see how it breaks and
we can make other cool slides showing
the story the only problem is that we
realized we put this sign on the wrong
end it's not at the start of the journey
it's at the destination
so when you change this you go to the
other place you don't know about the
sign at all you changed it but then
hopefully the other mechanism for doing
signposting kicks in your test Suite
right it should probably check for these
kinds of inconsistencies
so we got the test failure and it looks
really good up on the slide like yeah
it's uh do you have uh push
notifications enabled no you don't have
but it should be that you have it
um the only problem here is like um the
output is oh you have a mismatching dto
error uh so the failure message itself
doesn't really tell you anything about
what you've done wrong it's not like oh
it's a mismatch between two
initializations it's like oh the this
value has changed and it's not the same
as it used to be so we go into the test
suite and you look at that to say oh of
course it has changed I just changed it
I should probably update all the tests
so then you go through all the tests and
you update it and success yeah it works
all green tests without changing the
the destination yeah so um signposting
can be very hard and comments can be
good and tests can be good but it's hard
to getting them right
anyhow for our story can be an
inspiration and probably trying to break
it is the way to discover whether or not
you've done it the correct way or not
and let's talk more about comments
so
um how many hair actually like using
documentation comments
yeah great great now you don't like it
my guess is like um I really love them
it's like oh is there a way to write
comments that is even better than
writing regular comments wow
um but my guess is that it's sort of the
most untrendy language feature that
somebody's going to evangelize at NDC
this year I hope so
but like they're really great and I get
why most people hate them because uh
they can be rather large and take Focus
away from your code and somebody has
probably worked at a place where it's
like it's mandatory to do documentation
comments on any public anything anywhere
and then you get like this Auto
generated documentation comments with
sets like things
name gets name returns name and
parameters none return value string yeah
so like any tool if you do bad stuff
with it the result is going to be bad I
mean I do think that if you're um if
you're using documentation comments to
sort of describe the themes in your
application and you spend a little bit
time on getting them good they can be a
lot better than regular comments again
because you can view them from both
sides the side can be available at both
the start of the journey and the
destination at the same time and you can
get compiler support like oh I'm
referencing this type that you should
look at and it has changed the name and
then the compiler actually knows oh this
is a type reference and I should update
them warn you about that then you can do
a hypertext linking and examples and
more and use documentation covers all
right I'll stop
and having a complete complaint
complaining compiler can also be an
advantage it's like this F sharp
programmer's Pathfinder
so here we're looking at the example
where we use the
discriminate Union type from before
we are not using the radio series uh
field
so the the compiler complaints we've
forgotten about the radio and that's
sort of quite usual for myanmatez
because we're for people in the team and
two of them are sort of radio persons
and two of them are TV persons so
whenever we do stuff we tend to break
the radio stuff
yeah so using the compiler means it's
easier to locate where you need to
update the code
and it also makes you more confident
that you did it right and you avoid a
lot of the usual bugs so furthermore it
makes you take an active approach to
error handling for example if you use a
result type
in if you handle the OK result type you
also need to handle the error result
type so what to do when an error occurs
so if you want to log it error or do
something else you need to handle it
and what we're hinting at here is that F
sharp has a lot of nice features that
can make you write code bases where less
stuff is allowed
and one less stuff is allowed even us
typing randomly at this application we
doesn't understand tend to produce more
working code than if more things are
allowed
it's a bit like eating vegetables you
might be complaining when you're stuck
there for the fifth or sixth hour on the
same compiler but in the long run it's
probably good for you and you'll you'll
need a more Health than stress-free life
thank you
and
now we're showing you a couple of ways
to sign post your code a lot more exists
so be create create creative with your
signposting but don't do overdo it
because too much signposting obscures
what's important
all right let's move over to the third
and final tip
so you can do sign posting but when you
walk in the mountains you usually have a
map as well and drawing Maps is a nice
thing to do about code bases and
application features and all this stuff
as well
and the important thing to have in mind
here is like a map is a way to
communicate some kind of concept and
it's always going to be a simplification
of what you're trying to describe and in
order to make that simplification you
have to prioritize you want to show the
important stuff but you have to leave
out the stuff that's not important and
making that decision and actually
managing the focus on the important
stuff it can be hard but it's like if I
want to go on a trip and I need to know
if it's a steep Mountainside or a flat
mountain side I need a topological map
if I want to know about the rain at
certain areas I need a methodological
map if I want to know where this talk is
I probably need the undersea agenda and
the plan of this building
and if you use the wrong kind of map to
try to communicate another kind of
concept you always end up with problems
but one of the easiest way of making a
map is to write documentation I guess a
theme for me this talk is like the more
the less cold and more words you write
the better it is
but writing documentation can be really
good and the nice thing about using like
such plain building blocks as text and
images is that they are infinitely
adaptable if you want to communicate
like an abstract feeling of loneliness
you can certainly do that with words and
images it's not usually done in
documentation but I've seen other people
do it
uh and again if you want to like
underline oh this domain concept it's
used in this kind of way and all these
things you can fit your text and images
into
the drawback of course is that it's
usually totally separate from the code
and you have to remember to update it
and it takes a lot of time to write and
actually writing text that communicates
a complex concept efficiently is rather
hard
so yeah we have had experiences with
this in PS personalization as well uh
the first experience usually is oh you
have documentation and that's a good
experience
the next experience 10 years later is oh
yeah this is not that rough today this
is it and I have to be fair peace
personalization isn't that bad but it's
still like yeah some parts of it isn't
isn't that up to date and I heard you
told me that you worked a little bit on
it
the documentation yeah yeah so I and I
arrived after Matthias so I guess I
benefited from your updates
and yeah
um
and the The Experience have been like
all right if we have documentation
that's not um up to date maybe we have
too much documentation covering not the
important stuff we should cut them out
the documentation and really focus on
only keeping this lean set of
documentation up to date
and that's one ID but in the next around
the next band you see like oh this
concept is rather important we should
probably have documented this and then
it's not documented and this leads you
down to thinking all right we should
write more documentation
so I guess the sum for us at least is
there's no winning in documentation
there's only a grind and you can only
strive to do it the best of your ability
but what you do when written
documentation isn't enough
you turn to living documentation so
people can be a great can be great
documentation because they can adjust
how they communicate Concepts on the fly
so it fits your current needs
so being in a programming Pro
programming mob is great for this since
you're always supported by your fellow
teammates in this person is it PS
personalization we do a lot of code work
in mobs and that works great for us
and being at an organization where you
can actually work together as a team in
that way where you're not sort of just
thrown a project it's like yeah for from
two years ago somebody made this thing
and we want you to update it being a
place where like you have long-lived
teams and where people actually value
communication as part of the development
process is really nice and I think it's
one of the keys that one of the reasons
that we felt we came into and learned
peers personalization as fast as we did
I know not everybody has that kind of
context where they work but we still
think that's one possible key to success
where you're doing long-lived systems
and want them to be alive after the
first developer left the building so for
me it was great to have the programming
mob to get to know the domain model the
F-sharp language and net in general
so we talked a bit about F sharp already
but now we want to focus on the
experience using F sharp in a production
system
so before we started at
nrk and PS personalization and we heard
that it was written in F-sharp we
thought it was going to be normal
nuts everywhere
it would be crazy custom
um computational expressions and
peculiar Point free programming but it
wasn't the case
uh you see they see the code in reality
here
this is code that you have seen every
other place written in any other
language so
we was I was both disappointed and
relieved
I mean you sort of expect to become a
part of this select group that
understands category Theory and then you
open the application it is like
yeah it's some asynchronous stuff
because we're calling other apis
and then there's a lot of match
statements
so we try to make the joke that have you
seen the meme whereas the there's a guy
standing and there's a lot of if
statements and he's wondering like oh is
this artificial intelligence or machine
learning
and I guess our reversion of this would
be like a bunch of much statements and
like oh yeah it's dysfunctional
programming
yeah and you can probably build
production grade uh F-sharp with more
advanced functional programming Concepts
but if you do you have to be precise and
keep things understandable if you do so
all right
let's talk a little bit about.net and F
sharp
so um uh I don't think we feel like
insiders in the F-sharp Community yet
that probably come sometimes
but uh as a sort of an outside view into
the into the F sharpen.net Community it
feels it sort of feels like f
sharpen.net has this love hate
relationship like one love to be a
functional language part of this big
ecosystem where you can find a lot of
stuff and you can get a lot of support
and you can run your stuff anywhere
without too much hassle but at the same
time it's like oh Microsoft do you
actually care about F sharp or is it
just another language out there are you
going to push features to it
and you can sort of feel like
um depending on where where which person
you talk to there's a sort of a
different feeling about this topic I
think
so this is just a rundown of our
experience and our experience been that
oh it's mostly quite easy to use dotnet
stuff like standard Library things and
uh a lot of other interfaces like Plug
and Play you write F sharp code for it
and it works out of the box
and F sharp itself has a lot of nice
language features that can be used in
order to interrupt with a code that
isn't really written in a functional F
sharp way like you have classes and you
can do all the same things that you do
in C sharp so if you need like a special
feature to interrupt with a library
that's mostly written with C sharp in
mind it usually works out of K
you doesn't always end up with the F
sharp code you would have liked a
written but it's not like a huge amount
of code and you can usually abstract it
away in a in an okay way
and it's not just the stuff that you get
in the framework that's good
there's also a lot of goodies in the
F-sharp community
so like you can find packages that wraps
let's say interesting.net apis and nicer
to use F sharp ways and you can also
find a lot of things like giraffe we use
giraffe a lot in order to build small
apis
and in addition to the stuff that's sort
of nice makes the.net ecosystem nice to
use there are also a lot of stuff that's
just
um special for F sharp or F sharp made
like property based testing Suites like
FS check which is a really nice testing
Suite that can be used in c-sharp as
well but sort of built by the F-sharp
community and parse the combinator
libraries and all other kinds of special
goodies
and the dev shop Community seems to be
quite alter and hard working sometimes
there might be a feeling that they would
love to have a couple of extra hands
like uh
I use ionite with the Cs code now vs
code a lot
um and I see that every time Microsoft
does a huge update on the dotnet
framework they have a lot of work to do
and they would probably love to be
another couple of hands
so fingers crossed that we can be a
couple of hands in some years
if you don't switch to Rider like the
other of us no no Rider
yeah but there's bad stuff as well and I
think the place where we mostly feel
like that mostly grinds our gears right
now as when we're using the Azure SD
case
they not every one of them are sort of
hard to use from F sharp but some of
them certainly are and you kind of get
the feeling that all right maybe they
didn't intentionally try to make make it
hard to use rev sharp but they certainly
didn't succeed making it easy either
at the moment we're trying to swap up to
the new table stores Library like Azure
data tables and implementing this I
table entity interface in F-sharp it's
really really bad Vincent knows I'm
talking about
and that's that's a that's a sad story
actually because um I think F sharp is
the only like big hindley Milner
strongly typed programming language that
could be part of this giant Cloud
Enterprise thing and although I know
that not everybody is sort of excited
about Enterprise programming it pays
bills and if we could do functional
programming to pay the bills it would be
really nice so fingers crossed there
will be better F sharp support in the
Azure SDK going forward
and on to our final section so we hinted
at the start that we were going to speak
about ownership
and we wanted to talk a little bit about
what we mean when we say ownership
so ownership could be that your manager
arrives one day and says hi Matthias
have you seen this code base it's rather
large and you know you hum he just left
for another company what what you say
you own this now Yes sounds good of
course that's one level of ownership the
sort of the the mandatory organizational
hierarchy
um directed ownership model
but that's not the kind of ownership
that we're after we're sort of seeking
the kind of ownership where you engage
with the application you're working on
where you feel that you um you you
actually care about the functionality
and you care about the how this
application's functionality might be
extended or might not be extended if
it's not something that's fitting where
you actually care about the
architectural decisions that are made in
the code and when you find some code
that you don't like it's not like oh
this is the bad code that some previous
developer wrote but more like oh this is
the code I haven't refactored yet
so we want to reach this code this this
level of ownership because it makes it a
lot more fun to work with the stuff we
do and also we think we're able to do a
much better job when we have reached
this level of ownership
and we have a test that you can apply to
your own projects in order to find out
if you reached what we called true
ownership and the test is to ask
yourself
whenever somebody complains about your
system is your response yeah the
previous developer was really yeah not
that good if that's your response you've
probably not reached true ownership yet
if you feel that all right yeah I can
see your problem and I feel that I own
the solution and the application that
needs to change to do this then you're
probably at a better place
so we want to go through uh the entire
stack of PS personalization and say a
little bit about how we feel that we own
each part and this is the point I hope
for previous developers are sort of
curious to see terrified
we'll see we'll be nice let's start with
the functionality so the functionality
is easy to understand it's easy to own
uh in person PS personalization we have
progress and we have favorites if you
favor rice TV series it will pop up in
your your content on the front page and
if that doesn't work
something is wrong and we have ownership
enough to to deal with it deal with it
something has to be done
we have become those people that go to
family gatherings and say like hi
Grandma
have you logged on to an arcade oh you
really should let's do it together and
while we're logged in have you tried
pressing the star yes you press the star
on every show no you didn't absolutely
and when it comes to the code and
architecture it's a bit up and down
parts of it we do truly feel that we own
like the domain model we're like we
might not agree with every design Choice
made but like the whole concept of it
and that this is a piece of code that we
have to live with and learn and
experience together going forward we
feel sort of really bought into that
thing
um the same is uh to go along with a PS
personalization it's built with an
active framework called Orleans and I'm
not going to talk a lot about active
Frameworks but the architectural
decision on a base level in Prius
personalization is to say that a user
and a user's kind of things like your
favorite can be thought of like an actor
and that kind of model also resonates a
lot with us because the actor model has
a lot going for it when it comes to
separate things that can be kept
separate and the functional domain that
we're working in also has a lot of stuff
that can be kept separate
but there are stuff we're not that fan
of as well
and I talked a little bit about FS check
this property-based testing framework
and property based testing is cool NFS
check is cool but like 200 line model
based property-based tests are not that
cool they are probably grown and grown
and grown and whenever they fail it's
like either guide which is back there
somewhere yeah he knows how to fix them
we tend to like try to rebuild and
re-run and hope for the best two
reverence is always enough so yeah
two-way runs and then you agree
we should probably look into that
sometime in the future yeah
and monitoring is maybe the hardest part
to have ownership about
we have alarms
um popping up from time to time
and we also have a dashboard but when a
new exception arises or this spike in
the dashboard
we don't know if it's something we can
deal with next week or something we need
to do now so
um because one of the previous
developers can say that oh that's that's
something we see from time to time with
time it's not that
um
that's hard
um so it's pretty uh understandable to
see how you end up this way because you
develop a system and then you're going
to put it into production so you want to
graph out a lot of stuff about this
application because you want to know how
it performs and you don't really know
perhaps what's going to be important and
what's not going to be important but
like you know how the application works
you know all the details from it so
having a huge Board of metrics is good
and then you deploy it then you find
some
anomalies
yeah the stuff where the line goes
across the the stuff where it shouldn't
go above uh you find those places and
you put up with some alarms and you
don't need anything else because you
know all the things so when something
pops up no problem
yeah and when inheriting the application
we wanted to own the monitoring because
it's important but it was difficult
and we hope that the thoughts around SRE
like site rely built engineering might
improve these kinds of things so SRE
contains a lot of stuff about actionable
alerts making an alert actionable for
somebody who hasn't worked on that
application before and there's a lot of
stuff about doing smart notifications
that you get from Trends rather than
just crossing a limit one time
all right so when we sort of we're in
there the completion of our slide deck
we sat down until like ownership
why do we feel differently about
ownership in the different places of the
application
why do we love the functionality so much
to load the monitoring
and to us it came down to
ownership it's that understanding
so the pieces of the code that we
understand or that taught us an
important lesson we feel strongly
connected to those we feel that we own
those parts of the code
and those things that we don't
understand we feel sort of like oh this
is not my plate I don't understand this
thing
and I think you can't expect to build a
system where everything is instantly
understandable because you want the next
developer to own it what you got to
think about is like okay but maybe I can
make the most important pieces
understandable because then I know that
the ownership and maintainers will come
even though I'm not able to give the
best kind of Handover to the next
developer
so think about ownership with ownership
and how it relates to understanding is
sort of our finishing point there
so inheriting a large F sharp
application went pretty okay
we have delivered new stuff to
production without breaking it that
often that often
we didn't did the call back Frieda and
gear from apparently this spring
and I hope that I don't be called back
either in November when I leave for
print but you know Mateus sometimes has
to be the first to call back somebody
from parental leave
foreign
so yeah to sum up yes you're going to
inherit an F-sharp application it can
actually be quite an enjoyable
experience and it was that for us and we
do think it is because the application
we inherited had some stuff going for it
a lot of stuff was sort of like
contained within small nuggets of
functionality and if sharp certainly
could help with that especially in the
domain model
and those places where it wasn't put
together well maybe there wasn't that
much side posting but we had great Maps
working in a mob
and then again this sort of illustrates
that you don't have to write F sharp
that's crazy hard even for people that
doesn't know a lot of F sharp from
before so we do think that F sharp
doesn't have to be really hard for new
Developers
and finally again if you make somebody
understand something they will feel
ownership for it
so I think it's only one point left
are there any questions
yeah
we haven't counted the number of lines
of code so unfortunately we can't give a
good answer there
is a thousand ten thousand hundred
thousand
maybe it's between ten thousand
100
yeah it's I can give one estimate so
um
when I first loaded it into ionite like
the entire solution it wouldn't load
into ionize in vs code so I had to
manually go in and build each separate
sub application in order to get built
not executable like assemblies so the
main process when you loaded the entire
solution wouldn't time out
so uh it's at least big enough to cause
trouble to at least simpler editing and
highlighting software
problems using uh some different
libraries which were obviously designed
for c-sharp so uh what's the reason for
the shark for those
problems when it's really easy to
interrupt between c-shock and sharp oh
great question so
I think you can either say that
so in previously I built the system uh a
rather smaller one but also like a
production system
that use that strategy to interface with
the world around it so it was like um
when we were going to the database there
was this small c-sharp shim and the
c-sharp code was written in a way that
was targeting F sharp so it was mainly
using models from an F-sharp assembly
and so on so on
um and that worked out okay but a nice
thing about F sharp is that
um you can so easily use result types
and those kind of things that sort of
fits very well with the borders of your
application environment
so even though you might have to write a
little piece of code that is uh it's not
optimal the stuff you get after it when
it's F sharp the entire way can be
pretty good
was that an answer yeah
any other questions yeah
foreign
how do you do that how do you do you
have any practice on doing it
yeah do you want to take this yeah we
have we sit together uh
almost from the from the morning on and
solve different problems we prioritize
tasks together and all sorts in and
discuss our architecture and code
writing code and writing the tests as
well
so and then we sit down with not one
computer because we're all really
individualistic so everybody wants their
own keyboard and mouse and stuff so we
put on a timer and then I start for 10
minutes and when my 10 minutes are up
there might be Matthias and the Matthias
doesn't want to use my keyboard and I
don't want to use this so we move along
to his computer
and then we move along to Fidel's
computer and guys computer and then
we're back at my computer where I can
finally use my nice keyboard
any other questions
all right if um one more question
back there
yeah
I'm more programming task with a limited
scope would be fine to just
keeping keep to start with the domain
model maybe yeah I think that's uh
that's a good sum up as well if uh the
theme that you're becoming a part of has
sort of some self-contained tasks and
they are able to dedicate the resources
or well we don't think really think
that's right because we think that mob
programming actually makes you work
faster that's a long story we're not
going to cover her but if you're able to
work on that limited piece of
functionality along with another
developer there's probably not any
faster ways to get into codebase in our
review
more questions
they're all dead Jim
no actually it's a very good question
because in a in a team where you work as
a mob people might change jobs and go
away but you don't ever really end up in
the situation where you're just stuck
with something and there's nobody there
um I think the way we felt that nobody
was there was when people were on
Parental leave then we were sort of
stuck without the stuff to use
but yeah um the way you work sort of uh
it really impacts if there's a big
inheritance or a small one or you should
maybe turn it around because big
inheritance is good but not in software
I think we're sort of running closer and
on time here
um if you have other questions we're
going to be at the nrk stand on down on
the floor just pop by and say hello
you can also just send us a tweet if you
have something you think about later
fire away and I think that's all for now
thank you very much
[Applause]
together
so yeah
leave it at least
so um
is
it
all right
sorry there you go yeah
oh
oh man the crowd today
everyone's here
don't aren't they yeah
okay it is very bright but I'm pretty
sure I'm getting the thumbs up that I am
on and therefore should not stop saying
mean things about the people in the
audience
good afternoon
everybody uh thank you for coming along
to my session this afternoon I know it
already feels a little bit like it's the
Friday afternoon we're not really used
to being back at conferences whole
yesterday people talking learning stuff
was exhausting and unlike the last
couple of years we had to leave the
house
and like put on real pants to come here
so
we'll try and keep this a nice light
session this afternoon uh so that you
can recharge and get through the final
session before the party tonight
so
let's get started hi my name is Amy I'm
a freelance front-end developer which
means I spend most of my time at the
beach and the rest of the time working
from my pajamas So in theory the
pandemic changed absolutely nothing for
me except I was I was technically
allowed to leave the state I just wasn't
going to be allowed back in if I did
I'm heavily involved in the Perth Tech
Community I run a user group The Perth
Azure user group and um Vice chair and
director of conference content for the
what I've been told is the largest Tech
Conference in Australia DDD Perth which
ran a couple of weeks ago
I also have a beautiful gray and light
border collie who features fairly
heavily in my talks because who doesn't
like looking at pictures of dogs and
he's not a huge fan of the fact that I'm
leaving again although to be fair he
does far prefer my partner to me so I'm
also not sure that he actually knows
that I'm gone
today we're going to talk about how to
build a quokobot which is a side project
that I did for fun which has zero
practical uses whatsoever a couple of
years ago so we're going to go through
and because I don't know any better this
talk is pretty much all live demo so
we're going to keep our fingers crossed
and build a crocodile
so for those who don't know what a
quacker is thank you for completely
trusting the fact that you have no idea
what you're walking into here
crackers as the image suggests uh very
small cute little animals they are only
found in one island off the coast of
Western Australia where I live
they have no natural Predators on this
island and as such they don't realize
that they should be afraid of people
they also always look like they're
smiling so because you can get up close
and personal and they look like they're
smiling they take excellent selfies
the Poor's struggle to hold the cameras
so usually you've got to do it for them
now because everyone's familiar that
everything in Australia is trying to
kill them everyone knows this right
everything in Australia is trying to
kill us
hardly ever happens yes
because everything's trying to kill us I
wanted to uh to build something to
Showcase that we do have some cute
animals as well there are non-lethal
creatures in Australia
so a few years ago for an event that was
happening in Sydney I had to build a
chat bot in I think had about 10 minutes
and so I decided to build a bot
that sent you pictures of Quakers uh so
we used very very Advanced AI in the bot
where if you sent a message that
included the word quokka it would send
you a picture of a quokka
if you didn't include the picture of a
quokka if you didn't include the word
Crocker it would send you a picture of
my dog so either way you ended up with a
cute photo
after I did this demo I was like this
was actually really easy it was fun to
play around with some stuff I got to
Tinker with serverless which I don't
normally get to do I was chatting with
some friends at the drinks afterwards
where all good ideas come from and
someone went why didn't you add AI to it
we could do image recognition
and so because that's where all good
ideas come from we decided to Tinker
with it a little bit and add some
cognitive Services uh using the
Microsoft Azure cognitive Services
custom Vision tool which allowed us to
use machine learning aware not AI
machine learning to recognize pictures
of Quakers so you can send in a picture
and it would tell you if the picture
contains a quacker or not
So today we're going to go through and
start building out the bot now this bot
is built uh using WhatsApp as much as I
would love to not use a Facebook product
unfortunately uh most telcos around the
world are really weird about people
using their phone systems for apis so
they won't let you do anything with MMS
so to send and receive images we went
with using WhatsApp so
let's get started
so here I have an Azure function already
set up and ready to go and I'm going to
start off by requiring
the package
from twilio which I'm going to use to
generate and send the message
and then I'm not going to type this I'm
just going to copy and paste it because
we have better things to do today than
watch me fumble with a keyboard
what we're going to do is we're going to
go through and create a messaging
response from the package the messaging
response uses a certain a a language
called twiml which is pretty much XML
we use that to generate
the message
now in our function
we set the message
body
to be welcome to
crocodile
and we should do it so then if I open up
WhatsApp and go hi
in theory I should get a response
welcome to crockerbot so pretty quickly
we've been able to get some responses
but I did say we wanted to choose what
people were looking at
so we're going to go through and use our
very very Advanced AI
otherwise known as an FL statement
so we're going to go through and when
someone sends us a message we actually
want to know what the message says so to
do this we're going to have to pass the
message and we're going to have to use
the
query string package for that
and then I'm going to pass the message
that comes through so I'm going to pass
the body and then the text is the body
of the body and then
I'm going to log that out to the console
just so we can have a look at what's
going on
so now when I send
a message and go hi
it's gone through and processed it and
somewhere here
what's worked
um
I need to use contact context log
because I'm doing Azure functions
and now here in amongst all the other
stuff I can see
I have a message that says hi
what's up crocobot
we're at NDC I was like so something a
little bit more
what's up crocodile we're NDC outside
apparently we're not sure that we're at
NDC Oslo
so once we've gone through and gotten
that we're then going to add a very
advanced
AI so
grab this over here
If the message contains the word Crocker
we're being case insensitive here
we're going to
test it against the text
and set
the message body
to be you want to quokka we let them
know that they're asking for a quokka if
not
we're going to set the message Buzzy
body to say well you didn't ask for a
Crocker are you sure because clearly you
want to quarker
can I have a quacker
and I should get a response back
I didn't save it
and let's try again can I have a Crocker
it is really not liking me today
I'm just going to remove this all
together
wow crocobot is determined I'm going to
restart this
is
you'd have to have body return message
ah good point so really this should not
have worked before
everyone learns more by helping me right
okay this is what I should had context
dot done
and we're setting the body to the
message to string and we're also setting
the headers to use text XML because uh
we're we're using XML for the twiml
message
now
I should get a response back
it is really not liking me today
ah there we go
straight bracket somewhere
what are we sixth Time Lucky
here we go yay hi you didn't ask for a
quokka are you sure
can I have a Crocker
you want a quacker
awesome so but when someone asks for a
Crocker we don't just want to tell them
hey you asked for a Quaker they kind of
already know that we want to give them
an image so to do that
I'm going to
want to do that we're going to go
through and we're going to have a look
at another function we're using I'm not
going to go through and type this all
out because we don't have time for that
because clearly I'm going to take a
little bit longer to actually write the
code
so here what we're going to do
this is
not the one I want
ah here okay here what we're going to do
is we're going to go through and have a
look and we're going to check does the
message include the word quacker if it
does we're going to give it an image now
this image is also being randomly
generated based on the fact that we have
20 images in a folder and it will
randomly generate which image it uses
each time
the fallback from our if statement is
we're then still going to send them a
picture of a Crocker because you know
what even if they haven't asked for a
picture of a quokka clearly people don't
realize that they want a picture of a
quokka
so we're going to go through
and I'm going to pull in my crocobot
function
and
because I'm doing this check elsewhere
I'm going to go through and I'm going to
build a reply using my external clock
about function
there we go so I'm going to build my
reply I'm going to feed in the text that
I get in the image and my crocod butt
function uses different versions it will
get back and I'm specifically letting it
know I want to use plain text not HTML
and let's
log out the reply that we get back
so now I go
can I
just gonna go high
and here
I have logged out to my console welcome
to clock about
sending us a whole bunch of information
and here it has a URL to an image
about of a Crocker
so at the end of my function
I'm going to go through and now set
message dot body to equal the reply dot
body which the clock about function is
generating and message drop media to
equal reply dot media which is the image
URL
now when I send through hi I should get
a response back
which is welcome to crocodile I can do a
bunch of different things need a picture
let me just ask me not sure if you've
seen a Crocker send in a picture and I
will tell you if there's a quacker in it
now can I can I have a quacker
there's a picture of a Quaker
you might not be able to see it the
clock is
the clock is a little bit small
the quokka decided it wanted to hire a
bike
which is the best way to get around
rottnest Island
so here we go we've gone through and
we're checking whether or not someone
has asked for a quokka and we'll send
them a picture of a quokka and if
someone hasn't asked for a Crocker
we're going to send them a picture of a
quokka and let them know what else we
can do
but the whole point of this is we need
people to be able to send in pictures
and work out if there's a Crocker in it
so this is where the custom Vision API
comes into play
now
custom vision
was a recommended tool when I got
started doing this the main reason I
used it was because it was really easy
and I didn't have to delve too deep into
how machine learning worked or spend a
lot of time working out how to do it I
gave it a bunch of images and I said
these are quackers and then I gave a
bunch of image other images and said
these are not quackers and then I
clicked the button that said train model
and it spent a whole lot of time
thinking and it identified a whole lot
of things
so it was able to recognize Quakers we
then went through and tried to confuse
it with a bunch of other things like so
when you find Lego quokkas we're like
this this is still a quokka so we're
really confused about the fact that that
was a quokka uh same as illustrations of
quokkas and
pictures of not Quakers
because they try and get in everywhere
so they've got to have these little
doors to stop them from getting into
stores
so we send in a whole lot of pictures to
train it on how it went uh so this
training model has been through a lot of
iterations I think we're currently at
version 13. uh so I've gone through and
done it at the start it was fairly good
there are a few different Australian
animals that confused it wallabies small
kangaroos wombat confused it for some
reason
um I think they probably don't see the
tails in the quackers and the fact that
wombats don't have tails
or don't have long tails so it was
confused about that for a while however
a whole bunch of people sent these
animals in I was able to go through and
re-categorize it so on each image I'm
able to go through and let it know that
actually it's wrong
a wombat Is Not a quokka
and that table to make it more accurate
so it has been super useful having a
whole lot of people on the internet
doing it when it was really confused
about wombats one person sat there and
sent in like 40 photos of wombats
and I was able to go through and retrain
it and go these are not quackers
so later on in the talk you're going to
get a chance to go through and try this
out yourself so I challenge anybody who
manages to trick crocobot and send in
something that uh it thinks is a quacker
that it's actually not because at the
moment
it's looking pretty accurate
so we're going to go through
and link up custom vision
to our crocobutt
so
to do this
I'm just going to copy and paste this
all across and then we can talk through
the code
so
I have another file here which is
quacker test which is where I go through
and run the test on the image
so custom Vision has two API clients
there's prediction and training I think
is the other one so if I wanted I could
set it up people could send in pictures
of clockers and it would retrain the
model but for the moment we're just
doing prediction I then have all my API
key credentials which I have saved
elsewhere because
I only showed my API key that one time
and I swear it's not going to happen
again
turns out most services are actually
really good I think I managed to get
like two minutes before I had an email
going
yeah you realize you made this public
we've cut it off his how to get a new
one so we go through we create a results
variable we then fill the results
variable by using our predictor
and we're using the classify image URL
function so this means we send in a
image URL as the name suggests we also
give it the project ID so this is the
particular image model that I'm training
that I'm running it against and the
iteration as I said this has been
through multiple different iterations so
I can actually run it against a very
early version if I wanted but at the
moment I believe we're running against
13.
I also then give it the URL of the image
the WhatsApp API is actually pretty
useful with with that side because it
actually gives me a live URL of the
image that I can use so I didn't have to
play around with uploading it somewhere
to the internet
I also then generate the outcome from
the results which we're going to go
through
and
have a look here
so it gives us a whole lot of data back
from Custom Vision but we don't need
much of that information all we need to
know is the prediction results so it
gives me two percentages
one for the Quaker tag and one for the
negative tag so I'm going through and
getting the probability from the
negative tag and the probability from
the clocker tag and I'm then just going
to return that outcome back so I get the
two numbers that I need
so
I go through I've gotten the image
from my WhatsApp message this does
actually allow me to have multiple
images being sent in but for the moment
I just want to keep it to one image so
if there's an image if there's any
number of images I'm going to get the
first one
if there is an image I'm then going to
send that through to custom vision
once I get the results back which
remember that's then two numbers quokka
and not quacker I'm going to send
the results through to another function
which
is clock results and this just goes
through and formats the message it
formats the results into a nice easy to
read message so it converts the
probability results into a percentage so
it's a bit easier to read and it will
then format a message
so I've got a bit of a function here it
said so sorry that doesn't look like a
quacker puts the results in it's pretty
sad there here's a Crocker or yep that
looks like a Crocker
and then the results
and I may be about to be in trouble
because my computer has
just said that it's going into loud low
power mode because it's refusing to
charge
this is going to be fine so
we're going to go through and get the
results back
from that we have the reply the reply
also then includes a photo which we're
going to go through and send as the
media
we then go through
and send the message at the end
so if we didn't get an image we still
run the reply through the quakerbot
function but this time is when it gives
us some information about crockerbot
what you can do and again sends a
picture of a Crocker
so now
foreign
and send in an image
here's one I prepared earlier
so it's going to go through it's going
to have a look and run this through
custom vision and I should get some
results back it says yes that looks like
a Crocker
now
if you don't believe me
if you think
that
I have clearly planned this
give it a go yourself so if you have
WhatsApp installed on your phone you
should be able to scan this QR code and
it will open up a new conversation with
quakerbot
I will also add a disclaimer at that all
photos that are sent in to crockerbot
will at some point soon be shown on the
screen
please keep this in mind
be aware of the conference code of
conduct
and please don't get me in trouble
so
once we've gone through and done that
everybody should be able to send in
pictures
and get back results on whether or not
that is a quokka perhaps you don't have
a picture of a quokka to send in or
something that looks like a Crocker
remember you can still ask it for a
picture
but
this isn't super interesting to do all
the time like it's okay to be able to
send in images but we wanted something
that was a little bit more interactive
for if I wanted to showcase the bot at a
conference so we're using another API
which is a Sync API which I'm not going
to go into too much
but every time someone sends in an image
I add that image to a list of past
results as well as the results that you
get back from Custom vision
every time clockabot sends an image
I will then also go through and update
the previously sent image
which
I'm then able
to build out in a results page
so this page is live updating so as
people send in pictures of quokkas or
things that might look like quokkas this
page should go through and update to
include the last sent in image the
results from the last sentient image and
then the last picture that crocobot sent
back
uh so this way I'm able to go through
and see what people are sending in
and see the results that have come back
which is pretty cool
so
after we went through and did all this I
was like well you know not everybody
uses WhatsApp so I'd really love to
include
another form of communication for
crocobot so I had a think about some
really good
well-used modern forms of communication
and
which ones we could integrate like
clearly facts was a high up one
unfortunately all the companies that
offer fax apis no longer do apparently
people aren't using faxes anymore
so I went with the next most popular
form of communication which is email
because who doesn't love emails
so
I'm not going to go through this because
anybody who really would like to know
about how fun it is to deal with email
apis
Peter come up to me later I'm happy to
answer any questions that you have or
for me to just tell you how much fun it
was to deal with doing this so for
anybody who hasn't dealt with email apis
before fun fact
emails from apis typically come through
as multi-part form data
which is a particularly fun format of
data to deal with mainly because there's
a lot of packages out there to pass said
data so it's really really easy to use
except the time that I was doing this
none of them worked with Azure functions
they're all really good for like Express
or something like that none of them
worked with Azure functions
however one did work with Azure
functions the only problem was it was
assuming multi-platform data was more
from like a HTML form and it didn't like
images coming through so I spent a lot
of time fighting with that and
thankfully had quite a few friends who
got roped into helping me with the fact
that I was not a fan of JavaScript and
things were not working and eventually
we got it sorted
so
for our email function we go through and
pass the form data which is now super
easy to do because they fixed the
package I was using
we then go through and check does the
email include an image if so I get the
image
this image comes through as a buffer
which means I can still send it through
to custom vision
but for WhatsApp we used the classify
image URL for emails we use the classify
image buffer function so we send through
the the buffer of the image file
uh we then go through and I've been
using the send grid API to receive and
send the messages back
I go through and format a bit of
information
we talked about with the crocobot reply
we were using plain text for WhatsApp
the HTML versions of each of my messages
as well which I use for email
and the same as WhatsApp if there's an
image send it to custom Vision let my
function know that I'm sending in binary
information this time and it will use
the binary function
I then get the results back again as
HTML and then set the message
as the reply
so
now
if I open up my email
if I can find it
now if I open up my email
I'm going to send an email to hi at
quakers.dev
I'm just going to send a message that
says hi
and I should get a response back
here we go I have an email
welcome to crockerbot
so I should now also be able to send
through
an image
there are quackers in this photo
[Music]
um
I think I'll insert it
hi
hi crockers.dev
is this a quokka
and then send it through and while we're
waiting for the email response to come
back
you can try this yourself as well so the
email is high at clockers.dev
you can send an email through and talk
to crockerbot that way
while I wait for my response
see is an email fun to use this was
clearly the best option
am I getting an error ah fun
what have I got here
I think my image was too big
I think
that one's probably going to be too big
as well but we'll give it a go
hi at
parkers.dev
yes I want to send without a subject
and we'll give this a go while that's
going through and probably failing again
because this
wasn't good enough I wanted to let
people know some information about
quokkas so I added functionality to send
in a quokka fact now I could have
searched the internet for all of these
facts but that sounded like a lot of
work to me so instead I open sourced it
and during hacktoberfest I created an
issue on the repo and said
add a fact about Crockers to this array
and I'll approve the pull request and
you get hacktoberfest point and it was
really great because I had a whole lot
of facts about Quakers sent in
most of which from people who I'm pretty
sure had no idea what a quokka was
but they were after they were able to go
through and participate in hacktoberfest
so I go through
and grab a random item from my array so
if somebody asks for a fact it will send
through a random fact
so now I can go can I have a fact
and here we go fun clock effect number
511 quokkas have the ability to swim but
you won't find them doing the butterfly
stroke very often
this is technically a quokka
WhatsApp is not liking me at the moment
so I'm able to go through and send in a
quacker fact I also added the
functionality
so as well as checking for if
someone included the word Crocker I
checked for if their message includes
the word fact if it included the word
fact I send in a fact I also wanted
people to be able to report if there
were any issues so we added the
functionality of If the message includes
the word error issue or wrong
it would then report a bug which would
send
which would send through an image to me
this is really this is going to be
really fun
anybody happen to have a service charger
in the room
a Microsoft Surface charger
I think there was one coming from the
back
this is why
any questions while I'm plugging in do
you want some questions early
Ken Crocker see in the dark I would
Hazard a guess yes because fun fact
quokkas are nocturnal
uh so crackers are actually nocturnal
animals which is why during the day they
seem very slow and sleepy and don't
really move much but if you ever spend
any time on rottnest Island at night
they become entirely different creatures
they bounce around they get into tents
they get into anything that you have
food that you haven't tied down
and yeah they become entirely different
creatures
can they climb to I would tell guess
they probably can climb trees
they are small marsupials so they can
bounce a little bit I'm not sure they'd
climb climb but they could probably hop
up trees
can you have them it's okay are people
just getting facts and then asking me
the questions
yes
but I don't want to touch that
yep
so this was a side project to build this
can you do you have
a night on how money all that it took
how many hours it's taken me to build
this
yeah
well I'm not sure I'm not sure I could
work it out I've I've
definitely spent at least 100 hours on
this
um I'm not entirely sure if I've spent
more than 200 however taking the
presentation into account they'd
probably be getting on 200 hours
um
clearly far too much
yes yes the time spent dealing with
email was included in those hours so
that was a lot of time
yeah half of that was fighting with
emails so
a little bit of information about how
this works uh well my computer
finishes its tantrum
for the record it was 75 when I started
this talk so
there are two versions of this email and
WhatsApp so the email sends a when you
send in a WhatsApp message it goes to
the twilio WhatsApp API which then
triggers the Azure function which sends
it through
two cognitive Services custom vision and
goes back again
the email version sends from computers
or phones through to the send grid API
to Azure functions then to custom vision
and Back Again
there is information about this on
crockers.amiescapers.dev
which I will tweet out later and I have
information about how it all works as
well as
going step by step through how I built
it so I wrote a blog post when I first
originally built it
and then when we added the custom Vision
I went through and wrote another blog
post and then I wanted to play around
with the Azure static web apps and so I
wrote another blog post as I went
through and rebuilt it with that so it
was originally to separate Services
there was the front end website and the
Azure function but then I made it all
under Azure static web apps which was
really cool to play around with also has
information about how you can use it so
if you still don't believe me you're
able to continue to go away and start
bugging it it does go to sleep at times
so if you don't get a response the first
time just kind of ping it a few times
and it will it'll wake up the serverless
function and sort it out
now this is a project that I say has
zero practical applications and was
entirely for fun and playing with tech
however I've had plenty of people asking
about ways that you can expand it so
what this is doing is sending an image
through a various Communications API
it's then sending that image through to
a machine learning model and getting
results back so there are plenty of
practical applications that you could
use for this I've had someone expand
this and do
red back or not API so you send in a
picture of a spider and it will tell you
if it's a red back spider or not
that kind of defeated the purpose of
showcasing
non-lethal Australian animals
to me
I kind of wanted to keep it cute I've
also had someone come up after I've
given this at a conference and they
worked for a local government and wanted
to use it to if you could train the
model to recognize what was actually
recyclable material you could take a
photo of what was in your recycling bin
and it'd tell you if something wasn't
supposed to be there so there are plenty
of different applications that you could
do it however I wanted to have a play
around and have a little bit of fun with
it
so you can do that I
will be hanging around
for the rest for not for the rest of the
conference I will be around for the rest
of the day and for a bit tomorrow
morning if anybody has any questions
they would like to ask me afterwards
um
otherwise you can find me on Twitter if
you would like to know more about the
Azure functions and the cognitive
Services API I'm pretty sure there's a
booth somewhere that knows something
about that I don't know there's people
in shirts with lightning bolts on it
somewhere there's a Microsoft Booth
where you can go and have a chat to them
they're talking all about Azure
functions so you can go and see them if
you have any questions that I can't
answer
does anybody have any questions about
the bot
is this bot still running technically
yes it should be
I'm going to restart it
you know what I don't trust this I'm
going to switch it back to the live
version
there we go this bot is now switched
back to the live version
um so that should be running give that a
go ask a question again if a couple of
minutes in a couple of minutes if it's
still not working
yep
at your services
has also the book service so how did you
make decision just doing uh
magic functions and stand of the full
blown bot suite and why do you think
it's the best way from that point so why
did I build it with the WhatsApp and
Azure functions rather than using a full
bot Suite so the original purpose of
this I was actually speaking at a twilio
superclass event so oddly enough they
wanted me to use a twilio Communications
API for my demo so it originally did
that I think I had considered building
it in something else along the way but
it's sort of one of those things where
you sort of don't really think about it
until it's like oh it'd be a lot of work
to rebuild it from scratch now
I
also mainly used it as an opportunity to
play around with various different apis
that I wanted to try so even though it
was probably a bit more work to do it
that way it was an opportunity to play
around with a few different things
rather than
a bot service which would
I would Hazard a guess definitely make
my job easier
but would be less fun
wow you've managed to trick it a night
vision quokka is not quacker
I am really impressed come and find me
afterwards
um and I have a shiny quokka sticker
very limited edition shiny Crocker
sticker for you
um so that is impressive although to be
fair I would like to point out that that
quacker is very clearly evil looking
so
clear I would Hazard against cuteness
seems to play in the machine learning oh
wow I think we've it's disappeared but I
think there was another there was a baby
quokka in a pouch which it said wasn't a
quokka so if someone sent that in
um and wants to come up afterwards
there's another shiny Crocker sticker in
it because that was a quokka
sorry
a fox or was it a fox
ah okay so
it was a fox all right I just saw it
very quickly and then it disappeared and
it looked like a baby Crocker in a pouch
oh there's a fox that said okay if
anybody has a result that it said was a
quokka then it wasn't come and see me
after the talk I have some shiny Crocker
stickers
um I'm actually really impressed I
haven't managed to have anybody trick it
for a very long time so
um clearly clearly um
Norwegians
have some interesting animals that look
like Quakers any other questions
yep
the what's the pricing for the WhatsApp
API I have no idea so I think I think it
comes down to like point zero one cents
per message or something like that
um don't quote me on that but the real
cost is you have to pay for the phone
number that you use and Australian phone
numbers are super expensive to get
um so I think I pay
five to eight dollars a month
for that one which is super fun for a
bot that actually sits there and does
nothing for a large portion of time
so yeah don't yeah don't quote me on
that one but I think
when everyone uses it at a conference I
pay nothing for that it's really just
the ongoing cost of having the phone
number
what about the Azure functions
oh
I actually don't know about that one
either come and see me afterwards I can
have a look I'm not going to get my
Azure portal up on on the screen
and even if I try not to do it it will
somehow end up on the projector hey come
and see me afterwards and I'll find out
although full disclosure I am a
Microsoft MVP so I don't pay that myself
any other questions
I don't think anyone's ever asked about
costs
any other questions
yep
yeah
yeah so when I sent through the image it
had a public URL does that mean all
images from WhatsApp you send on
WhatsApp have a public URL
I don't work for WhatsApp and I avoid
dealing with WhatsApp where possible but
I would Hazard a guess that means yes
let me see if I can do I have here in
the console somewhere
I don't think I logged out the URL
so it would depend on whether or not
it's WhatsApp or twilio that has the
Public Image URL so
yeah it might just be the twilio API
that does that
um I can have a look after yeah come up
and see me afterwards and we can have a
play around and see if it gives you a
public URL for that one
is any of the codes available any of the
code available on GitHub all of the code
is available on GitHub because I cannot
be asked making things private
um like seriously if someone wants to go
through and have a look at my code on
GitHub that's fine go for it
github.com
[Music]
yep so I can tweet this out afterwards
so it's github.com Amy Kaepernick
quackers
and there's no security dependencies
uh yes all of the code is available
there on GitHub you can also see as I go
through and made changes I'm pretty sure
it's got
all the way back to when I first started
building it on there
so you can have you can have a look at
it there's probably still the commit of
when I accidentally added my API key to
it so
just for your thing called BFG
BFG the word nuke
clear out all your commits and get rid
of it just uh it'll be clean yeah that I
don't want that
oh no it's fine so I act I don't need to
clean my commit because uh as soon as I
committed my API key uh twilio sent me
an email and said you've committed your
API key we've nuked it here's how to
refresh it
um so they sorted that for me
so yeah all of the code is available on
on GitHub I'll tweet it out afterwards
any other questions
aspect ratio matters there like how are
you handling the image
does image aspect ratio matter
I would Hazard against no I am doing
absolutely nothing to the images so I
did look at processing the images so
that way if someone sent in a massive
image it would squish it down
but I started doing it and then gave up
because that was a lot of work going
through and processing images
um I would Hazard against the aspect
ratio doesn't matter I've had people
sending in landscape portrait Square
images so yeah that doesn't make as much
of a difference the images it sends back
I do believe are all square but that's
just because I've gone through and
cropped them all and made them smaller
and it's
an image that
everyone's just wants yeah
a very wide image with a quacker on the
edge and it's not detecting the Crocker
is the image which one
this one
that one that one
ah that one
um I'm pretty sure aspects
doesn't I'd say that's more I'm I'm
pretty sure this is a computer generated
Crocker it looks a bit like the ones we
get in some ads so that might not be it
um other than that I'm not sure aspect
ratio makes a difference anybody happens
to have a really wide image with a
quokka on the side
see if you can break it
any other questions
the image prediction the custom vision
how fast is it
um I'm
not too sure I think the results
actually come through fairly quickly but
then again I I still think that you know
a couple of seconds is fairly quickly
when people are like oh no no this
should be a no more than two
milliseconds
um
it comes through fairly quickly it's the
lag
I think is more to do with the fact that
my Azure function is like the base level
I'm not using anything fancy it's not
very big it doesn't have much power
behind it and it's probably definitely
not rated for when I use it at
conferences and there's a bunch of
people spamming it at once
so yeah from my experience the
predictions have been pretty good the
one thing with custom Vision that does
take time is if I go through and do
training depending on how many images
I'm training it takes between a couple
of minutes and like an hour to go
through and retrain it
that answer the question
any other questions
that's right this is like the most
normally people are like no questions
I even tried bribing people with
chocolates at times like if you ask a
question here I'll give you a chocolate
and still people don't ask questions
any other questions
cool well I'm pretty sure we're out of
time thank you everybody for bearing
with my technical difficulties uh my
computer going flat and the fact that I
clearly can't write code this after I
wanted to say this morning but it's
actually this afternoon let's just blame
my jet lag
five days after I arrived in Oslo
so thank you very much for coming along
to my talk I hope you heard I hope you
learned some interesting things today at
the very least learned what a quokka was
which is clearly the most important part
of my talk if you have any questions
y'all have any more questions you're
welcome to come up and have a chat to me
afterwards or find me at some point at
the conference enjoy
[Applause]
thank you
come on I just want to mirror my hey
it's working check check one two one two
three
well it's officially 40 after uh but I
have this policy which I like to wait
for
you know the minute and 59 seconds that
way I can start on time but that person
that walks in at the last minute can
still be on time
and usually when I say that someone
walks in at the last minute but uh I
don't see anyone in there there you are
thank you for walking in at the last
minute
thank you for Von being volunt told to
be the butt of my joke so how's everyone
doing today
yeah did you learn lots and lots and
lots of crap that you hoped to get to
use someday
welcome to another talk where you learn
lots and lots of stuff that you hope to
get to use I I
this this joke is going to be apropos
have nothing to do with my talk but it's
a fun joke that I like to start talks
out with sometimes I haven't used in a
couple years uh but uh it's a simple
joke what is a pirate's favorite
programming language
I you might think it'd be our M80 but as
first love be the C
that was actually a joke that my son
told me when he was like eight years old
it's like what's a pirate's favorite
letter of the alphabet
and he told me that and I'm like you
know those are both programming
languages
geek dad so so welcome everyone uh to
dungeons dragons and graph databases
my name is Guy Royce I'm a developer
Advocate at redis there are three things
on this slide that matter
one of the matters to my boss
right there
one of them matters to me that'd be the
Twitter account
and one of them matters to you which is
the GitHub URL the GitHub URL uh matters
because I have sample code and the
slides and all that stuff and it's all
out on GitHub under github.com guyrice
so those are the three things that
matter on that slide there's the logo
follow me on Twitter please and hey
here's code that you can actually play
with to use to play with this stuff so
I'm a developer Advocate this means what
I'm doing right now is part of my job
which honestly is kind of a kick-ass job
but in addition to being a developer
advocate
I play a lot of Dungeons and Dragons
I know that might come as a shock
I totally don't look like like I should
be playing dungeons dragons I totally
look like I should be running the game
I do that too but so I thought I'd
include my character sheet here there's
a bunch of details on here but the only
thing that really matters is down here
in the bottom right corner my ability
scores
see I've got an intelligence eight and a
wisdom of eight and a Charisma of 16.
that tells you everything you need to
know about this talk
it's going to all Sizzle no steak
and as a player of Dungeons and Dragons
I have a problem you know I need to
level up my character so I can take on
bigger challenges and defeat bigger and
more powerful monsters get better
treasure to buy better gear and the
cycle repeats and the only place to do
that is a dungeon
you got to go to the dungeon to kill the
monsters so you need to find the rooms
in the dungeons that are the best rooms
to explore
you've got to find the best monsters
that are the appropriate challenge that
I can overcome them and Max my
experience but not so much that we have
a tpk
and of course you need to find the rooms
that have all the gold
and so
this is a problem all of us Gamers have
this problem
um
but since I'm also a developer I thought
well I could build a database I could
put all the rooms and all the monsters
and all the treasure in the database and
I could query it and I could figure out
which rooms I could go to first I could
optimize my gaming experience
and of course my first thought was I
could use a relational database
right that's like your default what kind
of database do we need probably a
relational one but um there's another
cool kind of database
called a graph database
and so we could use a graph database and
so what we're going to do is we're going
to explore what it would look like to
solve this problem with a relational
database with SQL how many people here
know SQL that should be everyone right
yeah
how many people here have used graph
databases before probably a couple of
yeah a few yeah
um
and uh we're going to use a graph
database so I'll compare and contrast
these and so the first question that a
lot of you probably have is
what the hexagraph database
I can tell you one thing it's not is
this comes up a lot is people hear graph
and they think it's graphql
graph database is not graphql although
it plays nicely with a graph database
because they're using the same metaphor
graph database is a database it's a
database it's a way of storing things
not a way of querying things of course
you do need to query your databases so
that's going to come up
but the question before this is really
you know before I can answer what's a
graph database I have to ask what's a
graph
now many of you have probably taken math
and done some graph Theory uh I have not
so if you are one of those people you
know more than me congratulations
um
but we'll sort of give a five or ten
minute Layman's introduction to graph
Theory and then we'll go into graph
databases
so a graph is well it's a series of
nodes or vertices
connected by edges or relationships
um they can represent all sorts of
things mathematically this 20-sided die
right here is a graph
the points are the vertices
and the edges are well the edges
and so this graph its main purpose in
life would be to represent a platonic
solid a 20-sided die roll for initiative
um
and but they don't have to just be
platonic solids they don't have to be it
doesn't have to be geometry you can
represent all sorts of things with a
graph
perhaps the symbols graph
is really boring
it's a null graph that's a graph with no
nodes no edges
and some mathematicians debate whether a
null graph is a real graph or not
um
it's kind of like saying is null and
undefined the same thing in JavaScript I
don't know
um why do we have null and undefined in
JavaScript anyhow but null graphs are
from a graph database point of view an
empty database and so they're not very
interesting so we're not going to talk
about it anymore
let's put some nodes to our graph
so now we've got a simple graph this is
technically a graph there's no
relationships here there's no edges
connecting these nodes but they're just
kind of points floating out in space so
we've got a collection of nodes so we
don't know a lot about them uh it's
almost like a set like you could
represent a set using a graph without
relationships
probably not the most efficient way to
do it but you could do it
and this is perfectly valid you do not
have to have relationships in a graph
for it to be a graph it's not a very
useful graph
so let's add some relationships
so now our graph is growing a little bit
it's got some uh we can see that node e
is hanging out there by itself nodes a C
G and D are sort of clustered there in
the middle together
and B and F are best friends forever
there in the bottom right corner
and so this is kind of looking like what
you would think of when you think of a
graph
portions of this graph are isolated
so e is out there all by its Lonesome
it's not connected to anything it's an
isolated sub graph
B and F are also an isolated subgraph
because they're not connected to the
larger graph and in fact the big part of
the graph in the middle is also isolated
from all the other parts in the graph so
we can refer to parts of a graph as
being isolated if they're not connected
to other parts of the graph they're just
little Islands
if uh no part of your graph is isolated
like this graph here if every node is
connected by way of another node to
another node
then it's considered to be connected so
we have an isolated subgraphs this is a
connected graph every node has a path to
any other node not directly necessarily
but there's a path so D connects to C by
way of a or a and b
so connected graphs
a fully connected graph is when every
node connects to every node and um
this little subgraph here A B and C
they're fully connected because a
connects to all the other nodes in the
graph
this um this is best described by a
network diagram you've ever seen that
that circle with all the nodes in a
network and then you've got chords going
across it to make it like a you know a
star and everything connects that is a
fully connected graph we've we've seen
these before
um I just did this one because it looks
prettier with the rest of my slides
so a fully connected graph is where all
the nodes are connected
these graphs that I've been showing you
are undirected
an undirected graph is where the
relationships don't well they don't have
a direction
um a is connected to b b is connected to
a they're related there's a vertic
vertic there's a Vertex connecting them
but there's no sense of
I don't know any other word than
direction to describe directionality
um but there's no additional information
you can make graphs be directed and that
gives extra information in the
relationship so now we know that a is
connected to B and it's in it has a
natural Direction in the case of an
undirected graph that might be like
friends on Facebook like if you were you
and I are friends on Facebook because we
are right absolutely yeah
um
then that's a mutual thing and so it's
an undirected relationship
but um if I follow you on Twitter and
you don't follow me back that's a
directed relationship
another example might be uh my my
siblings
they're all my siblings there's there's
not a direction to that relationship
it's just my sister is my sister and I'm
her brother and that's just an
undirected relationship but my mother
there's a natural direction to that
relationship my mother big at me I did
not beget her right
and so directed and undirected
when we're talking about these graphs
and we can talk about an idea of degrees
the nodes of a graph have degrees
a degree is simply the number of edges
it has coming in and out
so node a here has three relationships
three edges three vertices
and so it has a degree of three
if we have a directed graph
it can have an out degree and an in
degree which is the number of
relationships coming out and in
respectively
and probably the uh the the most
important thing is that there really
aren't a lot of rules about how things
connect in a graph this is neat and tidy
because it fits on a flat piece of paper
but it doesn't have to be
two-dimensional it doesn't care about
dimensionality at all anything can
connect to anything nodes can connect
more more than once to each other with
different properties so here we've got a
and C connecting to each other mutually
in a direct graph a connects to itself
so you can connect these nodes and edges
any way you want there's no rules
yeah you're unlike Ghostbusters you're
allowed to cross the streams
so that's my like five minute graph
Theory some total of all my knowledge
uh a graph database is then when you
take this graph model and you represent
it digitally and you lay data over top
of it so then the nodes become things
that you care about
and then you can put data on those nodes
so these nodes represent rooms of a
dungeon and properties on those rooms in
the dungeon and they represent the
monsters of a dungeon and the the
treasure in a dungeon
and so here we'll like we have a monster
Alice the elf and another monster Bob
the ogre they've got properties fun fact
actually my grandparents names are Alice
and Bob or well were I suppose
they've been gone a long time
um and so I suppose my grandmother was a
bit Elfin uh my grandfather was
certainly not an ogre he was a very nice
old man
um
but I've always found it kind of funny
that you know this sort of stereotypical
like the classic elements oh it's always
Alice and Bob was like I was using it
for years and I realized one day oh crap
those are my grandparents names
but uh so you add these uh these nodes
now have properties you can think of
them as rows in a database almost
and then the relationships uh can have
uh Types on them to tell you what type
they are and we can also have properties
so you lay data on top of this graph
structure and you get yourself a
database worthy of Mordor
a couple notes
um about nodes and relationships the
nodes in a graph uh represent items I
tend to use them for nouns
and the relationships represent those
connections between those nodes I tend
to use this for verbs and so uh the
nodes can have a label for what they are
they have more than one label so it
could be a room but you could also have
like a chamber
or a corridor it might be a type of room
and they could be both of those things
and they can have art attributes with
strings and booleans and numbers and
stuff in them and a node can just Sand
by itself it doesn't need relationships
to exist it can just be out there and
you can query it
a node can certainly be an island it can
be isolated
the relationships are a connection
between two nodes they have a type as
opposed to a label they can only have
one type if you want to have a different
type of relationship you create a second
relationship
uh they have a Direction
and they can have attributes as well as
well so like leads2 might have an
attribute of a distance if you were
doing some sort of pathing algorithm to
find the best path through a dungeon
knowing the distance might be useful
because you could find the shorter path
based on the the weights or the the
distance that's represented in that that
edge
and uh and this is important if you're
using a graph database the relationships
cannot exist without a node so if you
remove a node from your graph the
relationships go away they delete it
automatically
um so if you've got data in there that
you care about
no you don't
I find that if I'm doing it right it
reads like a sentence
where you've got a direct object
or a a subject a transitive verb and a
direct object so the room contains a
monster so I've got a room node I've got
a contains relationship to a monster
node
so
thank you for attending my TED Talk
that's all the theory and just the
concepts around this let's get into the
real meat of how to do this
because we've we've still got a problem
well I've got a problem anyhow uh and I
uh you know I want to optimize my uh
dungeon runs my dungeon crawls and um I
haven't decided how I'm going to solve
it yet am I going to use a relational
database
with the tables and the columns and the
rows and the and the the foreign keys or
am I going to use a graph database with
the nodes in the relationships
spoiler alert it's going to be graph
and so uh when we go to talk to a
relational database we use
SQL or SQL which one's the right one
quick show of hand says SQL
SQL
excellent I guess he writes both ways
so
he's a gift for Jeff no
well yeah now I'm going to get all the
red cards yeah
so when we talk to a relational database
we use SQL
uh we we all know SQL it's it's the only
language that I learned in college back
in the early 90s that I still use on
occasion
don't use any others I still use SQL
uh and you know you're selecting from
the tables you're joining on foreign
Keys getting the fields back filtering
with where Clause right we all know this
stuff we've all used this a lot in our
career
the equivalent or an equivalent for
graph databases and the graph database
uh we're looking at today is going to be
redisgraph redis graph uses Cipher
and Cipher uses this matching syntax to
find things
and it's actually kind of cool because
if you look at it
it's kind of like ASCII art
it looks like the right it looks like
the graph that I want to query that I
want to match against
and that matchers is really kind of the
cool part if we zoom in on that we've
got this the room contains the monster
right
that matches a room node
colon room means match any node in the
graph
that has a label of room
the R means assign it to
the variable R so I can use it later in
my query
the parentheses
make it a node and so it's like round
right it's like it's like I drew a
circle around it
same thing for Monster here this finds
any node in the graph
with a label of monster and assigns it
to the variable m
and then in the middle here we have a
relationship
that matches any
um any relationship with a type of
contains and you'll notice right there
that there's an arrow on it so we
actually
hang on there we go all right you got
that little arrow right there it's
actually a line with a label on it so
you've got like circles and lines
connecting them together so it looks
kind of like the thing that we want to
query which I think is kind of neat
and this is at the heart of it and so
this says find any room that contains a
monster
match that pattern in the entire graph
you can imagine that if you have a
really big graph and really poor queries
this could be slow
you can optimize that don't worry
um
so to explore
Cipher a little bit deeper I'm going to
go through our classic crud operations
create read update and delete
and I'm going to show how we would do
this in SQL which we should all know
already
and if you don't know that's okay I
didn't know once too
and I'm going to show how we could do
the same thing with Cipher and this is
going to just create nodes we're not
going to do relationships yet we'll do
that in it in a bit
so if we want insert into a room a we
need to have a room table created
already and so we're assuming we have a
room table
and we say insert into room with our
field names and then the values for
those fields
to do it with Cipher
we call create
and we give it a pattern and this
pattern defines
that node so we're saying create a node
with a label of room assign it to
variable R for a use later
and then we call set and then we start
setting properties on that node
now one thing that's very important to
note here is is that in the SQL our ID
and name are baked into the table right
we have a schema
the graph node does not have a schema
and so we've decided that we want to
have two properties on here but we could
add any properties we want now or later
so we create it and we set a couple
properties but it's schema-less so we
can change our minds do what we want
make a mess if we want
so this is the create syntax it's fairly
straightforward
to read our room
with SQL this is the first thing we
learn
select star from users where clue
greater than zero
to query a graph database we use the
match keyword
we'll say match our colon room again
that matches
all nodes that are of type of room with
it with a label of room assigns those to
the variable R we add a where Clause to
filter them out
so where are the ideas one and we return
it
so far so good
when it's time to update a room
we use an update statement in SQL which
I've always thought was kind of
I've always thought these were kind of
heavy like you got to set your
individual fields and everything it's
kind of weird
um
I suppose you have to always just
specify the fields you want to set but
so update room set name equals statue
Hall the statue room is getting more
statues it's getting an upgrade my my
Grandma will be pleased
to do this in Cipher
I think this is actually pretty
interesting because in the previous one
we were saying match room where ID
we're doing that again but in the query
we returned it
and here we're going to set properties
on it so whereas before it was match
room where ID equals one return this is
match room where ID
and then start setting properties on it
um what's kind of neat here too is that
because there's no schema we could add
properties later so if their property
wasn't there we could add a new property
as well which would be very hard to do
with a relational database just because
it's schemeless
and so here we're setting the name
statue Hall we could also say like rdot
is trapped equals true or something like
that whatever we want to do
and then to delete a room
deletion is my favorite command
uh we can delete from rooms where ID is
equal to one we've all done this
make sure you put that where ID equals
one or you're going to have a bad day
and maybe be updating your resume
to do this in Cipher it's the same again
it's matchware
and then instead of returning or instead
of setting properties we just delete the
node and if there's any relationships
those relationships go away with it
so we're at that that point of the uh of
of
um
of learning where we think we know
things but we don't know them as well as
we think we know them like this is easy
I could do this I'm ready to use this
now no you know wait there's more
it's the dunning-kruger effect that was
the word I was looking for
um there's an I want to make a note here
on the syntax I've been doing that match
where
but you can actually
um I've been using the syntax or match
room where ID equals whatever
you can also embed that into the match
so this is a little more of a concise
syntax you're saying match the pattern
of a room
where the ideas won where it's got a
property of one and you can put multiple
properties on there so you could say I
want all rooms have an idea of one and a
name of
you know statue Hall
uh and it's inside those curly braces
it's just like uh it's Java syntax or
JavaScript syntax it's just
key colon value comma key colon value
comma key colon value if it's a Boolean
used true or false if it's a number you
just use a number if it's a string you
put it in quotes
so it's a familiar syntax
but this is a a more convenient way to
match things sometimes
and this works with create as well where
here I'm creating a room
and then I'm setting properties on the
room after I create it I can also just
create a room with the curly braces and
the properties I want
and you'll notice that I don't assign
room to a variable here I just do colon
room and that's not a typo that's
because I don't need to refer to the
room because I've created it and I'm
done
so there's some other syntax you can use
here to make this a little more
terse
and you can see this here when we go to
create monsters I'm creating a monster
on the bottom right there I don't assign
monster to M and I just give all the
properties
and when I'm creating treasure here you
can see that you can mix and match these
so you can create a node with properties
assign it to a variable and then add
even more properties if you want to live
your life that way
so
so far our relational database we've got
three tables they've got some property
they've got some rows in them
we've got three rooms in our graph are
in our dungeon we've got two Treasures
two monsters
our graph is just a bunch of nodes
floating out there in space they're not
related to each other at all other than
by the fact that they have a a label of
room or a label of monster or a label of
treasure
so the next interesting thing that we
need to do
is we need to put a monster in a room
so how do we do this with a relational
database
foreign key
so we have to alter our table
and then update that table to put those
monsters in a room so now Alice the elf
is in room one which is the statue room
which was recently upgraded to the
Statue Hall
and Bob the ogre
grandpa is in the armory
this makes sense to me
um
so in a relational database we'd have to
alter our schema and then make some
updates
how do we put a monster in a room with a
graph database
well we need to create a relationship
and to do that we need to match a couple
of nodes so here we're matching a room
with an idea of one monster with an ID
of four so this gets uh
uh the the statue Hall and Alice the elf
and then we call create
and we can reference those variables we
used earlier
without creating them and then Define
the relationship between them say create
a contains the relationship between them
so this will then put that monster in a
room it'll create a relationship where
the the room contains a monster
putting treasure in a room is the same
deal
I'm a little bit of a completionist and
I could not make these slides
so
but it's the same deal we're doing a
foreign key
we're updating the relationship
and so now our relational database is
this is a really common pattern with the
relational database right we've got
we've got a root table and with a
one-to-many relationship to Rooms To
monsters and treasures
our graph
uh is starting to look a little more
graphy
uh the rooms now contain things they
have contains relationships you still
got these nodes kind of floating out
there but there's a few relationships
connecting them together
and we actually have enough that we can
do some interesting queries
so I say it's munchkin time
anyone play munchkin everyone it should
be everyone come on
we're going to loot the room yeah
or look for trouble one of the other
so um we can query what rooms have
monsters and what rooms have treasure in
a useful way
and if we were to do this say to farm
all the XP I want to find the room
that's got the biggest monster or get a
list of monsters by experience points to
do that with a relational database we do
a basic join
so select from a couple tables where the
IDS match and Order descending
to do that with uh
a graph database using Cipher
we need to match a pattern a pattern of
the room contains a monster
so every room
that contains a monster is going to
result give us a row of results
and then we're going to return the ID
the name and the experience points for
those rows
if a room does not contain a monster
it's not going to return anything
if room contains only a treasure it
won't return anything if it contains
more than one monster we'll get multiple
the same room will be there multiple
times
and then we're just going to order it
descending by the experience points so
the the biggest experience points flow
through the top so this is actually
doing exactly the same thing that we're
doing with the relational database so
far we haven't done anything with graph
that we can't do with SQL and vice versa
we could do the same thing to get all
the gold
uh it's the same basic join
but we want to find the room that has
the most gold and here we're going to
find rooms that contain treasure we
don't know if they have monsters or not
but they can contain treasure we could
query rooms that contain both monsters
and treasure
by sticking some stuff on the other side
of that that query so we have an arrow
pointing back the other day way
but here we're just doing Treasures
and this is the same query as before
just with treasures instead of monsters
so this is kind of cool but
so what
this is just like relational databases
with extra steps right
well it gets interesting when you start
connecting your rooms together and this
is where graph databases start really
differentiating from a relational
database
how would we connect a room to a room in
a relational database how would we
connect a room to a room in a graph
database
in a relational database
we need to create a new table
and that table is going to have IDs for
the room that's going from and two
so
we insert into that table
that's a you know row two in that table
says that room one the statue room leads
to
room two the barracks
and then this table gets really big and
querying this table gets kind of hairy
because you're because it's recursive
right
there's ways to do it I always forget
the name of the way to do this in in I
think in SQL Server I know there's a
word for it I always forget the name of
it and then someone in the audience
always reminds me
yeah ctes yeah that's it uh so you can
use CTS to do this I haven't used them I
hear they're a pain in the ass
so I don't want to
um
but you can do that so this is how you
would model what you're really doing
here actually is you're modeling the
graph using a relational database
because you're saying well this is a
node and this is how they connect
ing rooms and graph
is familiar
because instead of connecting a room to
a monster a room contains a monster or a
room contains a treasure we just say a
room leads to another room and so we
match room one
we match room two and then we create a
relationship between them because the
relationship between the rooms is
exactly the same in its nature as the
relationship from any node to any node
and so this allows us to create a very
natural sort of semantic structure it it
matches how you think about the problem
this room just connects to this room
whereas with a you know relational
database that you've got this table it's
hard to reason about
and so our graph database here for this
relatively small problem our relational
database here uh is um kind of kind of
complicated
um this big blue connections table over
here is going to get big
our graph database kind of looks like
what it is
I mean I put this over top of a map of a
dungeon on purpose because it kind of
looks like a dungeon you can look at it
and get a sense of it's like a subway
map right
and so I think it's a tidier way to
represent these sorts of problems
and with our graph database here we
should be able to do some interesting
queries
um but I just I just remembered an aside
so I did the same talk
um a couple months ago at NDC London and
they put a video of it up on YouTube and
the guy who did the uh the the map that
I'm using the background Dyson logos
he watched the video and tweeted at me
the coolest thing ever I've been well
look consuming his maps for like five
years and it's kind of a fun moment
um so if you're watching Dyson thanks
for all the awesome Maps
so we can do some more interesting
queries now that we have these rooms
connected to rooms
um and so we're going to do some of
these
and one of the syntaxes that allow us to
do the interesting queries is these
variable length relationships
so we've got a match down here it's got
a little star there we haven't seen the
little star before
what does this little star mean
well this matches a room
and that matches a room matches a couple
nodes the star says
Match multiple Hops and so this would
match a room that leads to a room
a room that leads to a room that leads
to a room or room that leads to a room
that leads to a room that leads to a
room that leads to a room that leads to
a room to you guys leave when I say that
too many times
and so it can match multiple paths now
if you just do a query and match this
and return it against the graph
that's going to be a lot of paths right
so don't do that that's a good way to
get a timeout
um but this is a query that you can do
and you can also
give us some limits so here we're saying
it needs to be at least one half away
but not more than three
so this would match up you know a room
leads a room that leaves a room that
leaves room leads to a room but no more
um and so you can put boundaries around
it
and so this lets us build interesting
queries like hey uh I'm in the dungeon
I'm in a room what are some nearby rooms
that I could go to
well we could say I assuming I'm in room
number one
I can match room one leads to one or two
rooms away another room
and then I could return the idea name of
those rooms that are nearby so this
finds nearby rooms this would be kind of
like uh if you were doing Facebook you
could do a query and say give me a list
of all the people that are the friend my
friends and their friends
which you can guarantee Facebook does
it's that sort of query that could that
could be useful
let's add a little bit more to it let's
find the nearby room with the most gold
so here we have a little more complex of
query we've got a room that we're in
leads to one or two hops away
that room must contain treasure
we'll return the name of that room and
the ID and the gold piece value of that
treasure
order that's descending so the most
expensive the biggest item goes to the
top and then limit it to one
now I know which room I want to go to
next the room that's two hops away or
one hop away with the most gold
nearby because I'm lazy valuable because
I want to be rich
you could query the longest path through
the dungeon
you want to hit every room
this query will do that
and the way it does it is it does that
room leads to a room with a star so it
finds all the paths in that graph every
single one of them every room to every
room
and all the paths that can get to that
room
not just the shortest path all of them
and uh here we assign that to the
variable p in our match
that's the path
once we have that path we can ask
questions of it
so here we're going to find all the
rooms and all the paths to all the rooms
sign up the p
and then we'll return the nodes that are
in that path
and the length of that path in hops
and then we can order that by that
length descending limit one and that'll
give us the longest path between any
room to any room should give us the
longest path through the dungeon
sort of the traveling salesman problem
for Dungeons and Dragons aficionados
we can do the room with the biggest
treasure
here's some other syntax here we're
using a a grouping function here so
we're going to match all the treasure
nodes
and then we're going to take those
treasure nodes and say Max of a
particular value on that node so this is
going to get the the most valuable the
value of the biggest treasure in the
entire dungeon and we're gonna give it a
name of Max GP
then we can look for all the rooms that
contain treasure where the gold piece
value is equal to that Max gold piece
value so this will find the room with
the biggest treasure or if there's two
ties will give you two rooms back
and then we return them
and you can actually combine all of
these together
so here we're matching for Treasure and
getting the max gold piece value
and then we use that to match the room
that would contain it make that the
destination
and then we get the path from the room
we're in
to the room we want to go to which is
the destination
then we get the nodes the link and we
get the link the nodes in that path the
length of that path
and sort it by length ascending which
will give us the shortest path to the
room with the most gold
now this is
not the most efficient way to do this
because it ends up having to query every
path in the dungeon to get there there's
actually a shortest path algorithm that
we can use instead so this does a very
similar thing but instead of
just filtering our data we're actually
going to call shortest path algorithm in
redis graph to
say from start to stop give me the
shortest path there
and this runs about an order of
magnitude faster
cool
I hope the answer is yes
otherwise I'm going to go back to
America and cry
let's demo this I think we've got time
for demo I actually I blew through that
a little quicker than I normally do so
that's
a good thing
so I've got some demos here can we see
my screen I think we can
no this is the War Room yeah
so I've got a couple little demos here
one thing I've done is I've built a
random dungeon generator
and it will just generate a random
dungeon and shove it into redis graph I
create random names and everything I'm
not going to go into the code of the
random dungeon generator because it's
mostly about generating random names and
random rooms that kind of stuff but it
does write to redis graph whenever it
makes these changes and I'm going to go
ahead and run this just do npm is my
font big enough
or do I need to hit command plus about
five times
everyone in the back read it
that's probably way too big isn't it
screw it go big or go home right
if you ain't first your last shake and
bake
um
so I'm just going to do npm start that's
going to run server.js
it's done
I now have a generated dungeon is it
isn't that an impressive demo everyone
okay
um let's go ahead and look in the graph
so I've got this tool here redis insight
which is a little GUI for redis
you can get it at uh I think I have a
link to it in the end it's redis.com
redisinsight I think
um
and I'm going to go to this little
workbench here and I'm going to query
the graph database so I'm going to say
graph
dot query
and the the graph I created is slightly
different from one of my slides I have a
dungeon node which has a name for the
whole dungeon and it has entrances and
exits but then it has rooms and monsters
and stuff and the IDS work a little bit
differently but
this will show that this stuff is real
so query dungeon
and we'll go into here
we'll let's see let's say we'll do uh
the select star.star select star from
query for graph first
and let me in dig in that a bit too so
I'm just saying match node I don't care
about its label
just match in give me any node give me
all the nodes and return them
so this is like select star this is just
dump the entire graph out
and so this tool has a really cool
uh visual representation here we can go
for the text response here if we want
all right it just shows you all the
nodes
that's not nearly as cool so we're going
to go with the the graphical response
here
and watch everything Bounce Around
see if I can get that to
you know
it's a little tight but so here we have
a random monster
I have no idea how to pronounce that
genith The Wraith
six Rays if I and the cool thing here
with this particular pillow is if I
double click on that it should give me
all the relations let's find a room
now here's the dungeon the Forgotten
Fortress of all Superior uh
but if I double click on that
it's totally worked
and normally if you double click on this
I think it's my trackpad
if you double click on it would show you
all the nodes
this demo is totally failing
let's let's do this let's match let's
match the dungeon so that node is of
type dungeon there's only one of them
we say match D colon dungeon
return
d
so there we go
there's the dungeon the Forgotten
Fortress
there we go
and so here's all the rooms right this
is kind of cool and there's the has
entrance has exit here's the damp Hall
as there's seven semi-precious stones
nine gems no monsters
maybe there's some monsters in the big
chasm
I'm not seeing any
wait there's a monster three Orcs six
wraiths so we can sort of using this
tool browse the graph
somewhat awkwardly at this resolution if
you had a big monitor it'd be really
nice
um
and you can also get just like the text
out of it
and so some of these queries I was
showing you earlier we could we could
run here I've got them in
a little queries.text here so
I go down to like um
let's go to the shortest path to the
most gold the hard way
this is that shortest path to most gold
without using the the function
if I go up here say graph dot query
dungeon
ah I did it wrong
yeah it's got indentation in it
I've changed the version that I've used
to do this particular aspect of the demo
here and I have clearly I didn't
rehearse this
so let's add some spaces here
put a quote there
oh no I've lost it all anyhow
[Laughter]
I've got a better idea
let's do it from code
so I've got in here just a little demo
that shows you how you can query this
using JavaScript I use JavaScript
because because I hate myself
it means I go home at night and I Cry
so here I'm just using node redis which
is uh the the officially supported redis
client
for uh for node
I'm creating a client I'm connecting I'm
handling any errors
and then I call client.graph.query give
it the key name my graph is in a key in
redis as dungeon and then I give it a
query and so this is this simple query
here is just going to match the dungeon
return Dia's name and the ID
and if I run this
we can see that we get
very hard to read Json out
so let's
do this
the dash dash silent will get rid of the
the node demo.js stuff and then I'm
piping into a command line tool called
JQ which is kind of like said for for
JavaScript for Json which is fantastic
it's great tool and the main thing it's
being used to do here
is make my output pretty so here we got
our dungeon name the Forgotten Fortress
of all pirar uh
if we run the uh generation again and
run this command again we'll get another
dungeon name
the dim caves of bungo
let's do one more just for just for
just for the hell of it
one of these days I'm getting something
that's just horribly inappropriate
the fabled castle of hergbog
I'm going to use that in my next d d
game
um
but what we can do is we can take some
of these queries I've shown you earlier
and we can just swap them out here in
the code
so we'll go to this query here
go into demo.js
because I'm using
back ticks that will work
so that ran in about 900 milliseconds
which isn't bad
it's slow by Reddit standards but it's
not bad and um this is the longest path
through the dungeon these are the nodes
and that is the length of that path so
there's three edges between those nodes
if we do
the other
query
down here which uses the shortest path
algorithm
we should see a significant Improvement
I actually haven't demoed that
comparison live so you're going to find
out with me how much of an improvement
it is I know I said order of magnitude
earlier in the talk I may have been
making that up on the Fly
let's run that
eight milliseconds it's two orders of
magnitude I was totally making that up
on the Fly
I meant to say I didn't want to
exaggerate you know
but yeah so clearly that's a lot faster
right and uh and it should have gotten
me the same results
it actually gave me a different result
result for the longest path the shortest
path through the dungeon
um oh no no no this is the
this is these are the nodes
these are the edges
node Edge node Edge so
so they both have they both have the
length of three so it's the same path
so cool
that's the demo it's
it actually works it actually works yeah
so let's go ahead
get back to the slides
there we go you all see that
I can't see the screens that you see so
so this has been fun and kind of a
impractical exercise right but there are
actually practical applications for
graph databases I handed that some
earlier as we were friends on Facebook
but you don't follow me on Twitter
because I know that's how you are
thank you for letting me pick on you by
the way practical applications obviously
social networks social graph is an
obvious super obvious application
Twitter Facebook you got a social graph
friends of friends of friends you can
query a graph database and say well give
me all my friends of friends and then
their friends and then you can do like
intersections of those sets and say this
is probably a friend that you should
know you probably know this person
because you have these all these people
in common graph databases are excellent
for that kind of stuff
genealogy this is just social networks
extruded over time
right
um you know so you've got parents and
children and siblings and spouses and
all that kind of stuff another natural
problem to solve with the graph database
Transportation Networks
all of your intersections are obvious
nodes
your roads are the edges bus stops train
stations
taxi pickups those would all be part
nodes on the transportation Network and
then you could query that Network and
find the shortest path you could weight
those edges based on traffic conditions
and find the best path given the traffic
conditions
and Logistics networks so if you want to
figure out
I had a boss who like to use an example
of uh poison spinach
it's like anti-pop eye
but um the uh where you had we had some
problems in the US a few years ago with
spinach that had been contaminated with
E coli and it's like well we figured out
that it's in these stores where they
bought it and we could query the
logistics network of the stores and the
warehouses and the trucks and the farms
and figure out which Farms it could have
come from
um you know I suppose I don't have this
example here but of course epidemiology
is an obvious scenario for this as well
so
but too soon
[Laughter]
so so lots of practical applications I
actually think there's an even more
application for redis graph which is
honestly it really would work for any
database
a lot of your problems that you could
solve with a relational database can be
modeled neatly in a graph database
almost in a more
I shut her almost to say this an
object-oriented way like object-oriented
programming in my brain has always been
programming around nouns whereas like
functional programming is programming
around verbs or procedural is
programming around verbs and this feels
in a way similar it's like I could
easily map all of my uh graph entities
to an object graph in memory
and so I feel like there's a good
Synergy there so really any problem you
could model like a policy system with a
graph database and you've got policy
nodes and you've got customer nodes and
you've got writer nodes and just all the
things that you would have like on an
insurance policy
but if you want to play with these any
of these practical or impractical
operate options with
um graph databases the easiest way to do
that is to use Reddit stack write a
stack is well it's just redis
but redis with
plugins so redis has this capability to
add modules to it you can add Json redis
Json so you can have a Json type you can
add search so you can search those Json
documents you can add graph databases
which is what we've been talking about
today so you can use redisgraph as part
of Reddit stack
uh there's a Time series mechanism in
there as well
and redis Bloom adds probabilistic data
structures if anyone that was in Steve's
talked yesterday on probabilistic data
structures he was using redisplume
you want to get rid of Stack go to
redis.io Doc slash stack and there'll be
a nice Docker command that you can copy
and paste and you'll be up and running
before you know it
so
and um while we're talking about all the
paying the bills here
I've been working for redis for one die
four minus one years
uh we have a Discord server I'm often on
it many of my co-workers are on that as
well so if you are a Discord user and
you want to use these toys and play with
them and do cool stuff and you have
questions you can post them on Discord
discord.gg redis we got about I think
we've got about 6 000 people in there
now or so or seven thousand it's growing
quite nicely
um the client I use to talk to
redisgraph and just to redis in general
is called redis insights if you do write
a stack it comes automatically with it
you can install it separately
at redis.com redis insight
and um if you want to uh you don't want
to install redis on your machine you
just want to use a cloud thing there's
free Cloud instances out there at
redis.com try free and if you could use
code stack 200 then you will get 200 in
free credits and my boss will know that
you attended my talk
all the slides are up on GitHub all the
code is up on GitHub so you can you can
QR code this link it will never give you
up nor let you down or take you to some
site that it's not supposed to
everyone's like oh [ __ ]
uh that's my talk I've actually got time
for a couple questions if anyone has any
so yeah we got about seven minutes or
does everyone just want to go start
drinking
[Laughter]
a monster being contained by two rooms
so yeah so the question was is uh you've
got referential Integrity uh in a
relational database
and uh that keeps you from putting a
monster say in two rooms and how do you
keep that from happening in graph the
answer is you don't
a graph doesn't provide that that is
something you'll have to do in your code
so uh graph doesn't know the schema you
could put you could you could say a room
contains a room you could say a monster
is contained is in multiple rooms you
could totally do that now semantically
that doesn't make any sense but the
graph doesn't care you can connect
anything to anything
yes sir
um no actually I'm not but uh my father
is Bigfoot
I haven't seen him in years he's hard to
find yeah
he went out one day for milk and
cigarettes and never came back
[Laughter]
yes sir
you know I don't honestly I don't know
um
I can't imagine that the question was is
querying against the edges versus the
nodes more performant than one way or
the other I don't think there's a big
difference
um there's probably some algorithms
where this matters some of the building
algorithms like the shortest path
algorithm you can you can use weights on
the edges if you tried doing that
another way you wouldn't have access to
that algorithm so there's certain things
it kind of just it works that way
um I wouldn't imagine there'd be a huge
difference but I don't know I find in
general I tend to if I
lots of times if I find myself wanting
to put properties on my edges that means
I actually have a node that I didn't
realize I had
so like I tried modeling a uh whoever
who all ever played muds the multi-user
dungeons text-based things okay you're
all over 40.
um
in their
I tried building one of those using
redis graph as a back end because it was
a very natural metaphor right and it
would be fun for this talk
and what I ended up doing was I created
connections between the rooms to be the
corridors and I quickly realized that
the the edges were actually door nodes
and then the doors were in rooms and
connected to other rooms because I had a
bunch of properties that were on those
and so uh that's the that's just my sort
of back of the envelope experience and
so I think if you find what you're
asking is I want to load up my edges
with data you probably have nodes that
you don't know you have
but that's just sort of armchair
architecting
any other questions I see one back there
that's a great question so he asked he
noticed that I had a node that connected
back to itself and uh when you query
that
will it go forever
can you create an endless loop in a
query because there certainly are if you
go path to path what are all the paths
through some of these graphs well
sometimes they're infinite it will stop
the graph detects this I I don't know
how it does internally but it does do
that it won't uh run forever so great
question I meant to bring that up in my
talk and I forgot so thank you for
filling in my gaps so another hand up
there right there and then there's one
back there
yeah so the question is how's the
scaling graph databases are pretty
memory heavy
um it's actually pretty good redis has
some limitations because the graph is
stored in a key
uh the graphs are limited to about 195
megabytes for a single key
if you are doing a lot of modifications
because it's in a single key
um you can't scale it horizontally
because redis has to have that key in a
particular Shard and it lives there now
if you need to read and you're just
you're if you've got a read heavy graph
which I think is often the case
um then you can replicate that key to
other nodes to other shards and then you
can scale that out very nicely
horizontally
um
as far as just performance internally
they can be Memory hungry there's
there's two ways in memory to represent
a graph I don't have a slide for it I
almost almost put the slide in but I
didn't uh one way is that you can have a
bunch of linked lists and so a linked
list has a node and then it's all the
nodes it has relationships to it or in
that linked list and then you got a
linked list for each node in the graph
that's nice and compact it does it's
memory efficient
but it's a lot of O of n operations
across lists right linked lists you guys
you got to walk the list
the other way that you can store a graph
in memory is you can use a matrix
and that Matrix then is all the nodes
and all the nodes
and then there's a number representing a
particular type of edge between those
two nodes and then you've got a
it takes has a space complexity of O of
N squared that's the problem with that
approach uh you know if you've got a
million nodes and you've got a million
by a million Matrix that's big and
that's where this starts to blow up
memory uh redis actually kind of splits
the difference and we use a library
called graph blasts and so it uses uh
sparse Matrix matrices to store that
which basically means it doesn't store
the zeros
and then it's it's a very performant API
against those sorts of matrices and then
all your queries are just linear algebra
problems
and so it actually performs very good at
scale the bigger limitation is just you
can only shove so much into a individual
key in redis
um but yeah that's a good question
uh I saw another question back there
how would I choose between a relational
graph database
so if I was doing real work
I would probably choose to use a
relational database until I I couldn't
um
honestly
um the graph database
well I'm clearly the only answer is
redis
[Laughter]
the thing that's really the
differentiator for graph database I mean
it's it's it actually is a good metaphor
for the kinds of problems you would want
to solve but the thing that really
differentiates it is the pathing queries
so if I've got nodes and I want to do
solve pathing problems between things
that that's really it's it's super power
so for social graphs it's great because
it lets you find friends of friends and
find intersections to those structures
for transportation stuff it lets you
find paths through Transportation grid
but there's lots of things that are
passing problems that you need to solve
so that's where it shines and so if I
had those sorts of problems I would be
looking at graph databases if I didn't
have those sorts of problems I'd
probably use something a little simpler
I would use redis
yes
what's the licensing on Reddit stack
Retta stack is under the redis source
available license which is a I'm going
to say it's a very generous license it
basically says you can use it all you
want and if you want to manage it
infrastructure yourself you don't have
to pass the dime unless you're going to
resell it as like a competitive product
so you can't take redisgraph as a module
put on a redis and say hi we're
releasing this new graph product
yeah if you want to do that you'll have
to pass some money right but otherwise
if you're like you know like if you're
an auto manufacturer and you want to use
a graph database for some reason and you
want to use redisgraph and you want to
manage the infrastructure yourself have
fun it's perfectly fine
any other questions
I think
I don't know if I have till 40 or 50. I
think I think I'm Donnie and I
I've lost track
yeah we're done we're a minute over so
thanks a lot everyone