ºÝºÝߣ

ºÝºÝߣShare a Scribd company logo
Make Defensive Copies

           Parag Shah

 http://www.diycomputerscience.com
Even though Java is a safe language, it is still
possible for programmers to make safe mistakes
     and destroy the invariants of an object
Make defensive copies
Make defensive copies
Make defensive copies
Make defensive copies
Make defensive copies
When to not make defensive

When a collaborator is doing an explicit hand-off
 of the object in the constructor
When it is very expensive to make copies
Model objects... eg: Hibernate pojo's

More Related Content

Make defensive copies

  • 1. Make Defensive Copies Parag Shah http://www.diycomputerscience.com
  • 2. Even though Java is a safe language, it is still possible for programmers to make safe mistakes and destroy the invariants of an object
  • 8. When to not make defensive When a collaborator is doing an explicit hand-off of the object in the constructor When it is very expensive to make copies Model objects... eg: Hibernate pojo's