Advertisement
English transcript
The reason why we asked you the last question about creating an error and
fixing the error is because an important skill of developers
is to be able to get past errors.
There's no developer who writes code perfectly the first time.
If you think about it,
the whole Google search product was not written in one day perfectly.
It was a lot of iteration over many years, and it continues to be.
So, regardless of whether you're a new developer or you're an experienced
developer, in order to get to the end goal, it's not exactly a straight path.
You'll run into obstacles along the way, and you have to be really creative in
terms of trying to come up with other solutions to go around that obstacle.
So once you get around it, then you'll run into another obstacle and so on.
And you just always want to keep thinking of ways to get
around that obstacle.
And eventually, after a lot of work, you finally find the path to the goal, and
even though it was super challenging, it was totally worth it in the end because
you feel empowered and confident and just really proud of your work.
So the really good developers know how to rebound from an error and
continue with their work.
So here are some habits and
strategies that they use to debug, or fix, their errors.
First they read the error message.
When you're writing a document in Google Docs, for example,
if there's any misspellings, then it will tell you with a red underline.
Similarly in Android Studio, if you have typed XML incorrectly, then
it will have a red, squiggly underline, or it will be highlighted in red.
Also, in this bar on the side here,
it will show you the message if you hover over the red bar.
But in our XML Visualizer, there's also helpful error messages.
So if I create an error, like removing this quotation mark, it will tell me
that there's an uneven number of quotes and that I need to fix it.
Sometimes, it also tells you the line number that the problem is on.
The line numbers are on the left hand side here.
So, on line six, we know that there's a problem.
This helps narrow down the problem space instead of having to read through all
your code and trying to figure out what the problem is.
If you still don't understand the error message, try to
identify words that you do understand and the words that you don't understand.
You can always Google search for the words that you don't understand, or you
can just copy the whole error message and paste that into a Google search.
The other technique is to use working code samples and
compare it to what you have to try to figure out what went wrong.
We've already given you some code to look at in the last few videos, and
another good resource is the Common Android Views cheat sheet that
we'll provide you.
Here, we see the names of different views, and we also have code snippets as
well as a preview of what they would look like on the device.
You can always compare your code to what we have here and
see if there's any differences.
The third technique is to use undo.
If you're paying attention when you type,
you should be able to see pretty quickly when you type something wrong.
Try undoing the last few keystrokes to see if any of those fixed the error.
As we showed you before, you can hit Cmd+Z to undo a change or
Cmd+Shift+Z to redo a change.
On Windows, it's Ctrl+Z to undo and Ctrl+Shift+Z to redo.
Or in the XML visualizer, we have these nice handy buttons for undo and redo.
If you really don't know what to do, you can always hit this Reset Code button,
which brings you back to the original code that we gave you,
which should work.
The fourth technique is to just ask for help.
You can reach out to other students on the peer chat in the lesson or
on the forums.
Oftentimes, just talking to another person will
help you work out your errors.
Don't be afraid to ask for help.
There's a lot of really nice Android developers out in the community who
are willing to help you.
In fact, being able to ask for help is an important skill for developers.
There are no bad questions.
The more you practice the better you'll be at knowing who to ask and
what to ask them in order to help you get to your answer faster.
You can also take a screenshot of the work that you're doing, whether it's
on the phone or in the XML Visualizer, and share that along with the code
on the forums or in chat so that people know the context in which you're asking.
Check out the instructor notes for more details.
Okay, so here's a chance for you to practice some of those techniques.
I have some code here that has errors.
If you click on the link below, it will bring you to the XML Visualizer
with this code already populated in there.
There's a bunch of error messages, so I want you to try to read them and
try to resolve the errors.
Then come back and describe at least two problems that you saw.
For extra credit, tell me if you discovered all four problems.
fixing the error is because an important skill of developers
is to be able to get past errors.
There's no developer who writes code perfectly the first time.
If you think about it,
the whole Google search product was not written in one day perfectly.
It was a lot of iteration over many years, and it continues to be.
So, regardless of whether you're a new developer or you're an experienced
developer, in order to get to the end goal, it's not exactly a straight path.
You'll run into obstacles along the way, and you have to be really creative in
terms of trying to come up with other solutions to go around that obstacle.
So once you get around it, then you'll run into another obstacle and so on.
And you just always want to keep thinking of ways to get
around that obstacle.
And eventually, after a lot of work, you finally find the path to the goal, and
even though it was super challenging, it was totally worth it in the end because
you feel empowered and confident and just really proud of your work.
So the really good developers know how to rebound from an error and
continue with their work.
So here are some habits and
strategies that they use to debug, or fix, their errors.
First they read the error message.
When you're writing a document in Google Docs, for example,
if there's any misspellings, then it will tell you with a red underline.
Similarly in Android Studio, if you have typed XML incorrectly, then
it will have a red, squiggly underline, or it will be highlighted in red.
Also, in this bar on the side here,
it will show you the message if you hover over the red bar.
But in our XML Visualizer, there's also helpful error messages.
So if I create an error, like removing this quotation mark, it will tell me
that there's an uneven number of quotes and that I need to fix it.
Sometimes, it also tells you the line number that the problem is on.
The line numbers are on the left hand side here.
So, on line six, we know that there's a problem.
This helps narrow down the problem space instead of having to read through all
your code and trying to figure out what the problem is.
If you still don't understand the error message, try to
identify words that you do understand and the words that you don't understand.
You can always Google search for the words that you don't understand, or you
can just copy the whole error message and paste that into a Google search.
The other technique is to use working code samples and
compare it to what you have to try to figure out what went wrong.
We've already given you some code to look at in the last few videos, and
another good resource is the Common Android Views cheat sheet that
we'll provide you.
Here, we see the names of different views, and we also have code snippets as
well as a preview of what they would look like on the device.
You can always compare your code to what we have here and
see if there's any differences.
The third technique is to use undo.
If you're paying attention when you type,
you should be able to see pretty quickly when you type something wrong.
Try undoing the last few keystrokes to see if any of those fixed the error.
As we showed you before, you can hit Cmd+Z to undo a change or
Cmd+Shift+Z to redo a change.
On Windows, it's Ctrl+Z to undo and Ctrl+Shift+Z to redo.
Or in the XML visualizer, we have these nice handy buttons for undo and redo.
If you really don't know what to do, you can always hit this Reset Code button,
which brings you back to the original code that we gave you,
which should work.
The fourth technique is to just ask for help.
You can reach out to other students on the peer chat in the lesson or
on the forums.
Oftentimes, just talking to another person will
help you work out your errors.
Don't be afraid to ask for help.
There's a lot of really nice Android developers out in the community who
are willing to help you.
In fact, being able to ask for help is an important skill for developers.
There are no bad questions.
The more you practice the better you'll be at knowing who to ask and
what to ask them in order to help you get to your answer faster.
You can also take a screenshot of the work that you're doing, whether it's
on the phone or in the XML Visualizer, and share that along with the code
on the forums or in chat so that people know the context in which you're asking.
Check out the instructor notes for more details.
Okay, so here's a chance for you to practice some of those techniques.
I have some code here that has errors.
If you click on the link below, it will bring you to the XML Visualizer
with this code already populated in there.
There's a bunch of error messages, so I want you to try to read them and
try to resolve the errors.
Then come back and describe at least two problems that you saw.
For extra credit, tell me if you discovered all four problems.