Unsafe Sharing
- Sharing references to data can be dangerous
- Making copies is sometimes preferable
public void setupEmployees() {
List<Product> products = Inventory.fetchProducts();
ProductDatabase.setProducts(products); // Stores parameter in a member variable
QualityChecker.identifyDefects(products); // Removes non-defective products
ReportGenerator.defectiveItemsReport(products); // Stores defective products
}
14 / 22