Java Best Practices
Are you frustrated or slowed down by messy code? Make sure you don't write such code yourself! This course will teach you how to write clean, readable, and maintainable code that human beings can read and understand clearly.
What you'll learn
Most software is built to last a long time, and one of the key challenges is to keep technical debt at bay. Applying programming best practices is crucial to the long-term success of any software project. In this course, Java Best Practices, you will gain the ability to write high-quality code that others will enjoy reading and working with. First, you will learn the importance of naming and how to choose great names for your classes, variables, and methods. Next, you will discover best practices for creating objects, implementing methods, and the multiple constructs that are involved. Then, you will explore higher-level practices of clean code that go beyond a single class. Finally, you will learn hands-on practical tips to write better automated tests. By the end of this course, you will have the necessary skills to write clean, readable, and maintainable code that human beings can read and understand clearly.
Table of contents
- Introduction 2m
- Class Names Should Be Specific 3m
- Class Names Should Reflect the SRP 3m
- Class Names Recap 0m
- Variable Names 3m
- Checkpoint 02 - Rename Variable 0m
- Method Name Basics 2m
- Methods Must Do One Thing 2m
- Checkpoint 01 - Rename Method 0m
- Methods: Exception to the Rule 2m
- Abbreviations and Spelling 3m
- Exercise 01 - Giving Better Names 0m
- Module Summary 1m
- Introduction 0m
- Use Java Records 4m
- Checkpoint 03 - Use Java Records 0m
- Prefer Dependency Injection 4m
- Know the DI Frameworks 1m
- Checkpoint 04 - Prefer Dependency Injection 0m
- Protect with Guard Clauses 3m
- Use Static Factory Methods 3m
- Apply Constructor Chaining 3m
- Checkpoint 05 - Protect with Guard Clauses 0m
- Recognize Primitive Obsession 3m
- Know the Code Smells 1m
- Builder Pattern to the Rescue 1m
- Exercise 02 - Improving Object Creation 0m
- Module Summary 1m
- Introduction 1m
- Adhere to the CQS Principle 2m
- Keep Your Parameter List Short 3m
- Demo: Reducing the Parameter List 4m
- Demo: Removing Flag Arguments 5m
- Prefer Enums Where Appropriate 2m
- Checkpoint 06 - Prefer Enums Where Appropriate 0m
- Demo: Replace String with LocalDate 1m
- Failing Fast in Methods 1m
- Null Objects - the Next Level 2m
- Exercise 03 - Improving Method Signature 0m
- Reducing Verbosity with var 5m
- Avoiding Unnecessary Object Creation 1m
- Returning Proper Values 4m
- Prefer the Optional 3m
- Checkpoint 07 - Avoiding Unnecessary Object Creation 0m
- Module Summary 2m
- Introduction 0m
- Writing Cleaner Conditionals 3m
- Exercise 05 - Improve Conditional Statement 0m
- Keeping Ternary Expressions Simple 2m
- Switch to Switch Expressions 2m
- How Not to if-else 4m
- Checkpoint 10 - Switch to Switch Expressions 0m
- Prefer Streams over For Loops 4m
- Avoid Overly Complex Streams 2m
- Demo: Running the Search 1m
- Checkpoint 11 - Prefer Streams Over For Loops 0m
- Module Summary 1m
- Introduction 1m
- Catch Specific Exceptions 2m
- Some RuntimeExceptions Shouldn't Be Caught 1m
- It's OK to Catch Some RuntimeExceptions 4m
- The Rules of the Catch Block 2m
- Translate Exceptions 2m
- Checkpoint 12 - Rethrow Exceptions 0m
- Pass Pertinent Information 4m
- Use Multi-catch Where Appropriate 1m
- Exercise 06 - Handling Exceptions 0m
- Prefer try-with-resources 3m
- Module Summary 1m
- Checkpoint 13 - Prefer try-with-resources 0m
- Introduction 3m
- Poor Name Tests 4m
- Demo: Fixing Poor Name Tests 2m
- Clueless Tests 4m
- Demo: Making Tests More Focused 2m
- DRY vs. DAMP 2m
- Exercise 07 - Break up a test 0m
- Demo: DRY vs. DAMP 3m
- Consider Using Libraries 1m
- The Benefit of Helpful Messages 1m
- Demo: Writing Helpful Messages 2m
- Checkpoint 15 - The Benefit of Helpful Messages 0m
- Making Tests Independent 2m
- Favor Composition in Test Infrastructure 2m
- Demo: Refactoring to Composition 1m
- Further Study 1m
- Module Summary 1m