I have a code that has the following structures:
HashMap<String, List<Integer>> shops;
boolean hasCustomerBeenInShop(int customerId, int customerRefId) {
return shops.get("customer_ids").contains(customerId) || shops.get("shop_ids").contains(customerRefId);
}
The hashmap is prepopulated.
I was wondering what would be an effective way to convert this code into a more OO approach?
For example creating an object that has as members the customerId
and customerRefId
and overriding the hash
method would not work since the condition for existence in the map does not depend on both of them being set for the object.
Although the code snippet is simple enough I was wondering if there is a design pattern I am overlooking.
Aucun commentaire:
Enregistrer un commentaire