Java Tutorial: Exception-Handling 1: Types of Programming Bugs

Java Tutorial: Exception-Handling 1: Types of Programming Bugs


Java Tutorial: Exception-Handling 1: Types of Programming Bugs

Completed for an introductory Java class. Part 1: Before you can learn to fix bugs, you must learn the types that exist: syntax bugs, logic bugs, and code bugs.


Content

0.9 -> I'll be covering exception-handling in Java.
6.3 -> So the first step to understanding exception-handling is to
9.9 -> understand the general types of bugs you encounter in programming.
15.4 -> So a bug is any code or any part during the execution of that code that that
21 -> code doesn't turn out what you want it to turn out.
26.5 -> So the three types of bugs are 1. syntax bugs,
30.8 -> 2. logic bugs, and 3. code bugs.
33.4 -> So syntax bugs relate to the conventions of the
37 -> programming language you're using itself.
40 -> So each language has its preferred syntax.
44.3 -> And if you violate that syntax, that code won't, can't,
48.1 -> be parsed, which prevents it from being compiled, which
52.6 -> prevents it from being run.
55.7 -> An example is that Java expects each line of code to be terminated
63.1 -> with a semicolon. C++, C#, many other languages
70.2 -> enforce this requirement too, but Python doesn't require semicolon.
77.5 -> So you just have to account for how you should use each
83.9 -> language. The second type of bugs are logic bugs and they occur
87.2 -> when the code compiles, it runs, but it gives you the wrong
91.6 -> answer. This happens when
98.1 -> you haven't mapped out what each step of your
102 -> program, each step of your algorithm does.
105 -> So, for example, the getAverage(..) function.
109.5 -> It takes two operands and it should return their average, but
114.6 -> if you only divide one operand by 2, the sum
122.5 -> won't be correct. The third type of bugs are code bugs.
127.3 -> This occurs when your code itself
132.4 -> generates an error and code bugs can be divided to compile-time
136.9 -> or run-time and this specifies during which process the
143 -> bug occurs and it's important to know whether the bug is
148.5 -> compile-time and run-time so you know when you have
151 -> to take care of it and how you should take care of it
153.7 -> because fixes for compile-time and run-time errors are different.
158.9 -> An example of a code bug is passing the wrong
162.2 -> type of argument to a function.
167 -> Those are the three types of programming bugs: syntax bugs, logic
170.4 -> bugs, and code bugs.

Source: https://www.youtube.com/watch?v=VQ4repSB-Ro