From the course: Secure Coding in Java
Unlock the full course today
Join today to access over 24,800 courses taught by industry experts.
Mutability - Java Tutorial
From the course: Secure Coding in Java
Mutability
- [Instructor] When writing Java code, it is often simple to just create getters and setters for all of your data elements. It's a bad habit from Java (mumbles) that has taken hold of many other areas. We'll spend a little bit of time talking about mutability of our data. I will warn you, this is a little bit of a soap box for me, because this is something I'm very passionate about across the way we write applications in web as well as desktop and backend processing. Making classes immutable is not an easy task. If you're writing libraries and need to protect your consumers and ultimately protect their users, you need to take immutability seriously. In addition, if you're integrating with other systems, immutability should be a primary concern. First and foremost, you need to treat all class attributes as final when possible. This applies primarily on data transfer objects, but even your worker objects that maintain…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.