What Have You Learned?

You’ve already finished one more chapter. Welcome to the next level!

Now you know how to deal with magic numbers, and you can replace them with constants or enums as the situation requires. You’re able to implement iteration in the way that best fits your needs, and you’ll stay clear of exceptions or performance pitfalls while you’re at it. You know how to format your code in a readable way, and you’ve seen how the Java API can help you to make it more concise and efficient.

That last part’s important, and the learning doesn’t stop here. The Java API is huge—really huge. In Java 9, there are more than 4,000 public API classes alone. Each one of these has a purpose that can help you. We don’t recommend that you go through all of them right now. But when you’re programming, ask yourself now and then, “Could this piece of code be useful in a different context as well?” If the answer is yes, then there’s a chance that you can find a helpful class in the Java API. So you should try searching the API at least briefly.

Eventually, you’ll learn about other helpful classes, similar to Collections or Objects. And you’ll get more and more proficient in using them over time. In the end, knowing your API is what makes a true professional.

In the next chapter, we’ll get more specific and zoom in on one particular aspect of programming: code comments. They don’t influence the execution of your code, which is why many programmers don’t pay them much respect. But good comments can mean a huge difference to the readability of your code. As we’ve mentioned now and then (read: all of the time), that’s really important. So make sure that you can apply comments in the right way!

Footnotes

[21]

https://docs.oracle.com/javase/9/docs/api/java/util/regex/Pattern.html

[22]

Admittedly, the code is somewhat brittle. You can’t easily add a conversion to a third unit without rewriting the method. This comparison is about formatting not extensibility, so we’ll ignore that problem for now.

[23]

https://docs.oracle.com/javase/9/docs/api/java/util/Formatter.html

[24]

http://www.stringtemplate.org/

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.143.5.15