
This course includes our updated coding exercises so you can practice your skills as you learn.
See a demo
Discover who benefits from this course, aspiring Java developers, junior to mid-level Java developers, and IT professionals from other segments, through practical tips to level up and boost confidence.
Explore how the Java best practices course teaches clean code through short modules, practical exercises, and micro-learning, with downloadable source code for hands-on practice.
Understand how float and double precision can introduce errors in money calculations in Java. Use integers (cents) or BigDecimal for exact results, noting BigDecimal's precision control and its verbose syntax.
Learn how the plus sign in Java string concatenation harms performance in loops, and compare bad practice with good practice using StringBuilder, StringBuffer, or StringJoiner.
Represent business identifiers as strings, not integers, to preserve leading zeros and future flexibility, and use Java's UUID class to generate unique string identifiers.
Understand why primitive types trump boxed primitives in Java to avoid null pointer exceptions, reduce auto boxing overhead, and know when primitives are unsuitable for collections.
Adopt the modern Java date and time API from the Java Time package, store timestamps in UTC, and convert to local time for different time zones.
Apply command-query separation to define method responsibility: separate state changes from computations, and avoid undocumented side effects by using focused methods like deposit and withdraw.
Validate parameters at the start of methods with null checks and non-negative guards, throwing IllegalArgumentException when inputs are invalid, demonstrated by good versus bad price list practices.
Design method signatures with clear, verb-driven names and use interfaces over concrete classes to keep parameters concise. Employ splitting or parameter classes to reduce parameter count and boost readability.
Learn when to return values from Java methods, favor empty collections over nulls, and choose between defaults, exceptions, or optionals for non-collection results.
Always use the @Override annotation when overriding methods in Java. See how it prevents signature mistakes in equals, ensures correct overrides, and affects hashset duplicates in the sample.
Emphasizes encapsulation and information hiding by restricting access to the lowest sufficient visibility, starting with package-private for classes, keeping fields private, and exposing only needed members as public.
Learn why immutable classes are valuable in Java and how to implement immutability by default: avoid setters, mark the class final, make fields private and final, and copy mutable components.
Explore static factory methods as alternatives to constructors, including benefits like readable names, caching, and returning subtypes, and note their differences from constructors and patterns.
Discover the builder pattern as a clearer alternative to telescoping constructors and setters for creating objects with mandatory and optional fields, using a builder and a final build method.
Identify utility classes as collections of static methods that should never be instantiated. Add a private constructor to prevent instantiation and ensure static access via the class name.
Explore dependency injection through the constructor to decouple a service from payment and inventory dependencies, boosting flexibility and testability with frameworks such as Spring, Dagger, and Juice.
Use standard exceptions for argument checks, such as null pointer exception and index out of bounds, and prefer illegal argument, illegal state, or unsupported operation exceptions over runtime or throwable.
Throw exceptions in if blocks in Java methods, illustrated by bank account withdrawal examples, and avoid nested ifs and else blocks for readability.
Learn how to design catch blocks in Java by avoiding empty or ignored exceptions, using meaningful handling, logging, and exception translation to present clear, high-level errors.
Explore how to craft meaningful exception detail messages in Java, including parameter values and constraints, while avoiding sensitive data, to aid production debugging without exposing end-user errors.
Learn how try-with-resources automatically closes resources that implement the auto closable interface, reducing memory leaks and improving exception handling in Java.
Explains how Java's var enables local type inference, emphasizing readability and proper scope. Warns against misusing with generics, literals, and when var is used far from its use.
Explore Java 14 records to create small, immutable data classes with auto-generated constructors and accessors, compare with traditional boilerplate and Lombok alternatives.
Explore why switch expressions in Java outperform switch statements, using arrow syntax to return values, and pattern matching for cleaner, more readable code with built-in completeness checks.
Follow popular naming conventions to improve code readability. The lecture covers class names as nouns with CamelCase, method names in lowerCamelCase, boolean prefixes is/has, getters, and constants and packages.
See how using libraries in Java accelerates development, improves reliability, and lets you focus on business logic, illustrated by a string reversal example using StringBuilder and Guava and Apache Commons.
Follow a four-step approach: prioritize clean, maintainable code and avoid premature optimization by measuring performance before deciding. If you optimize, measure before and after changes and use profilers like Visualvm.
Declare parameters, return values, variables, and fields using interface types when possible, enabling easy implementation swaps; otherwise, refer to objects by their concrete class when no interface exists.
Avoid Java serialization due to security risks and potential code execution during deserialization; use Json as a modern, human-readable alternative, with object mappers for serialization and deserialization.
Split packages by features, not by layers, to create modular, readable Java code that is easier to maintain as the project grows.
Write fast, isolated Java unit tests with descriptive test names using the arrange, act, assert pattern, and aim for at least 80% code coverage across tested paths, including boundary tests.
Conclude the course by applying Java practices to make your code more robust and readable, while seeking help, leaving a review, and exploring more courses for continued growth.
Note: All students of this course receive a 6-month license for IntelliJ IDEA Ultimate — the industry-leading Java IDE trusted by professionals worldwide.
Welcome! My name's Adrian and I'm a professional Software Developer. Elevate your Java expertise with this Java Best Practices course! Designed for Java enthusiasts with some prior experience, this course takes you beyond the basics to explore the art of writing professional-grade clean Java code. Discover the industry's top practices, tips, and techniques that seasoned developers use. Uncover the secrets to designing robust software and enhancing your coding skills. Whether you're a junior-level developer or looking to refine your professional journey, this course empowers you with the knowledge to excel.
COURSE OVERVIEW
This course offers a collection of practical tips and best practices employed by experienced Java developers. It's structured into modules covering Data Types, Methods, Classes and Interfaces, Exceptions, and more. Each lesson can be taken independently and is accompanied by a simple code example. Modules also feature quizzes and coding exercises to give you a more hands-on experience.
COURSE ADVANTAGES
• encourages microlearning – all lessons are no more than 10 minutes and are independent of each other: you can learn even if you only have a few minutes a day!
• based on practice – instead of useless academic theory, you learn the best developing practices drawn from my work experience,
• reasonably priced – compared to stationary developer bootcamps, the course is much cheaper, so you save not only time but also money,
• available anywhere, anytime – the online form lets you run the course in the most convenient place (at home, work or in a café) and time (while commuting by metro or relaxing at home after work), so you can adjust it to your agenda,
• accessible on desktop, mobile and TV – you can display my lectures on the device of your choice, so you don’t have to stick to your PC,
• certificate of completion – after completing the course, you will receive a printable certificate that will make your resume more attractive.