English subtitles

← Getting Past Errors

Get Embed Code
13 Languages

Showing Revision 3 created 05/24/2016 by Udacity Robot.

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