We can now show a Google map on the screen which is great.
But before we move on and start showing the markers there's one last little thing on a mentioned one
to focus on the index dot t s file right now.
I want to point out something inside of here.
This is going to seem like a really strange thing to point out.
Nonetheless I just want to mention it.
Let's just take a look at a diagram I think you'll start to understand what I'm going to be talking
about here.
OK.
So quick diagram.
All right so this is kind of a crazy diagram.
Its purpose is to try to show all the different things that we can effectively do inside the index dot
t s file and I know that's weird to say but let's just kind of walk to the diagram step by step it's
going to zoom in a little bit here and go up to the top so inside of our index dot t s file we've got
an import statement for our company class.
Now we currently have that commented out near we could very easily uncommon it with our company class.
We have two things that we can effectively do with it.
We can use it to create a new instance of a company and then with that instance of a company we can
reference its company name catchphrase latitude longitude Likewise we've got the User class as well
it's currently commented out but whatever we can easily uncommon commented with the User class we can
create a new instance of it or and then reference that instances name latitude and longitude.
So I'm just trying to describe like the total surface area of what we can do inside that index dot test
file right now.
And so that's basically what we can do with the company and the user there technically are other methods
available to us like you know the name properties a string that has like a two upper case method and
so on.
I'm just trying to write out or diagram out all the different things that we've added into our application
that's specific to our application so in other words the surface area of the company and the user classes
is quite small.
Let's now start to think about that map we just created however I need to zoom back out just a little
bit.
So in the last video we created that Google map right.
So we said right here we said new Google Maps map dot map.
This creates an instance of a map right here we could technically assign the results of that to a variable
like so and then down here we could write out map and try to call a bunch of different methods attached
to that Google map we created.
So if I put a dot right there I'll see all the different methods that are attached to a map.
So I see add listener bind to changed fit bounds get get bounce all these different things.
Those are all different methods we actually saw inside the type definition file.
So another way of seeing all those different methods would once again be to command click on map right
there and you'll see all those same functions listed out right here.
These are all functions that belong to that instance of a map.
And so those are what these boxes all represent size diagram right here.
So we've got methods like set zoom set center set street view and so on.
So why is this relevant.
Well there's going to seem like a weird thing by just want to point it out.
These are all methods that we have exposed inside of our index dot t yes file.
So if another engineer started to come into our project they could look at that map variable and say
oh hey look at these cool methods attach the map you know what I feel like just starting to call them.
So another engineer might come into our project start calling the methods associated with that map in
very easily break our application.
I know that sounds strange.
I know that's weird like that's the job of Google Maps right.
Google Maps is here to expose all these different methods.
My only point is that you and I as the sole developers of this application have not vetted these methods
we haven't sat down and said Oh yeah if you call these things our application is going to continue to
work perfectly.
We didn't do that.
So in theory if someone started to call these methods it might horribly break our application again.
I know this sounds like a stretch but let me just make a suggestion maybe if we found out a way to limit
other engineers access to these methods right here maybe that would just slightly decrease the chances
of our application breaking horribly.
So here's what I'm going to suggest maybe we start to like firm up or limit the number of things we
can do inside the index not TSA file.
Maybe we say the only things you can do inside of this file is create a new company reference its properties.
Create a new user reference its properties and then maybe we should create a new class called Map like
our own custom map class and this custom map class can be used to create a new instance of a Google
map.
So this right here like will create a new instance of map to be precise and during that process we can
create a new instance of a Google map and also on that map class we can add a method called Ad marker
and we'll use that function right there to achieve our original goal this application of showing a marker
for user and company on the actual map.
So again this class right here you and I are going to create this is like maybe a better name for a
be like custom map like so so then wrapped up inside this class we will have some logic to create a
Google map and the important thing here is that that Google map and all of its associated dangerous
functions and methods right here will not be easily exposed inside of our index dot t s file and so
if another engineer came into our project they can't just open up that index dot test file and start
calling random methods on the Google map.
Instead we've hidden all those methods we've wrapped them all up and taken them away from engineers
and hidden them behind this facade of sorts or this kind of like black box of custom map.
And the only thing you can do with custom map is create a new map and add a marker to it again.
I know this sounds like a stretch but the whole idea here is that if we have a program where these are
like the only things you can do.
Chances are it's going to be way more challenging for people to come into our app and start to break
things.
All right so let's take a quick pause right here.
When we come back the next video we're going to start to extract this logic to create a Google map right
here into a new class.
And once again this logic to create a Google map is going to wrap up all that stuff or Sammy our new
class is going to wrap up the Google map and try to hide its existence from other engineers so they
can't accidentally break our application.
All right.
So quick pause right here.
Take care of that in the next video.