Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Start a free Courses trial
to watch this video
You've heard about the importance of documenting your code. During this video I'll introduce the motivation behind writing our own annotation: the ability to scan for full documentation of non-private methods.
Unit Test Annotation Example
A typical example illustrating the simple power of custom annotations is using them to code and control the execution of unit tests. The tutorial linked below also illustrates an additional component of reflection that I don't cover in this course: method invocation. In this course I focus on using reflection to inspect a Java class. One can also use reflection to actually interact with it, and in this case invoke (or call) methods that have been annotated with @Test
:
Clean Code, by Robert C. Martin
In this video, I reference the following quote:
There is nothing quite so helpful and satisfying as a well-described public API.
- Robert C. Martin
This quote is taken from the book Clean Code, which is a wonderful guide on code readability. In this book, among other topics Martin discusses what he considers to be best practices in naming conventions, error handling, and how to practice good test-driven development. Read more about it on Amazon:
Java Style Guide
Speaking of clean code, a good practice as you start or continue your code-writing career is to adopt standards & conventions for your Java code. Also known as a "style guide", this helps you and your team maximize code readability, keeps your team's codebase consistent, and allows you to develop a baseline of expectations for any developer that joins your team. The best style guide for your team is the one you adopt. Don't have one? Here is one from a company you may have heard of:
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up