Let assume I have two simple model classes: Product
and Brand
It is obvious I have a query method in Product
class like this
Product product = Product.findById(123);
What if, I want to query products by brand?
ArrayList<Product> products = Product.findByBrand(234);
// or
ArrayList<Product> products = Product.findByBrand(new Brand("ABC", 234));
Assume 234 is the brand ID in the database.
I assume the 2nd way of writing make the method more easy to test as I can mock the Brand
class in my unit test, right?
Brand
objects exclusively for safety and ease-of-you. In that case, it might make sense to use visibility. – rwong May 23 '15 at 11:35Brand
objects. – Bart van Ingen Schenau May 23 '15 at 17:28