Book description
Write code that's clean, concise, and to the point: code that others will read with pleasure and reuse. Comparing your code to that of expert programmers is a great way to improve your coding skills. Get hands-on advice to level up your coding style through small and understandable examples that compare flawed code to an improved solution. Discover handy tips and tricks, as well as common bugs an experienced Java programmer needs to know. Make your way from a Java novice to a master craftsman.
This book is a useful companion for anyone learning to write clean Java code. The authors introduce you to the fundamentals of becoming a software craftsman, by comparing pieces of problematic code with an improved version, to help you to develop a sense for clean code. This unique before-and-after approach teaches you to create clean Java code.
Learn to keep your booleans in check, dodge formatting bugs, get rid of magic numbers, and use the right style of iteration. Write informative comments when needed, but avoid them when they are not. Improve the understandability of your code for others by following conventions and naming your objects accurately. Make your programs more robust with intelligent exception handling and learn to assert that everything works as expected using JUnit5 as your testing framework. Impress your peers with an elegant functional programming style and clear-cut object-oriented class design.
Writing excellent code isn't just about implementing the functionality. It's about the small important details that make your code more readable, maintainable, flexible, robust, and faster. Java by Comparison teaches you to spot these details and trains you to become a better programmer.
What You Need:
You need a Java 8 compiler, a text editor, and a fresh mind.That's it.
Publisher resources
Table of contents
- Foreword
- Acknowledgments
- Welcome!
- 1. Start Cleaning Up
- 2. Level Up Your Code Style
-
3. Use Comments Wisely
- Remove Superfluous Comments
- Remove Commented-Out Code
- Replace Comments with Constants
- Replace Comments with Utility Methods
- Document Implementation Decisions
- Document Using Examples
- Structure JavaDoc of Packages
- Structure JavaDoc of Classes and Interfaces
- Structure JavaDoc of Methods
- Structure JavaDoc of Constructors
- What Have You Learned?
- 4. Name Things Right
- 5. Prepare for Things Going Wrong
- 6. Assert Things Going Right
- 7. Design Your Objects
-
8. Let Your Data Flow
- Favor Lambdas Over Anonymous Classes
- Favor Functional Over Imperative Style
- Favor Method References Over Lambdas
- Avoid Side Effects
- Use Collect for Terminating Complex Streams
- Avoid Exceptions in Streams
- Favor Optional Over Null
- Avoid Optional Fields or Parameters
- Use Optionals as Streams
- What Have You Learned?
-
9. Prepare for the Real World
- Use Static Code Analysis Tools
- Agree On the Java Format in Your Team
- Automate Your Build
- Use Continuous Integration
- Prepare for and Deliver Into Production
- Favor Logging Over Console Output
- Minimize and Isolate Multithreaded Code
- Use High-Level Concurrency Abstractions
- Speed Up Your Program
- Know Your Falsehoods
- What Have You Learned?
- Bibliography
Product information
- Title: Java By Comparison
- Author(s):
- Release date: March 2018
- Publisher(s): Pragmatic Bookshelf
- ISBN: 9781680502879
You might also like
book
Java 8 in Action
Java 8 in Action is a clearly written guide to the new features of Java 8. …
book
Java Concurrency in Practice
"I was fortunate indeed to have worked with a fantastic team on the design and implementation …
book
Optimizing Java
Performance tuning is an experimental science, but that doesn’t mean engineers should resort to guesswork and …
book
The Well-Grounded Java Developer, Second Edition
Understanding Java from the JVM up gives you a solid foundation to grow your expertise and …