Skip to content

Instantly share code, notes, and snippets.

@freekman
Created January 19, 2015 13:25
Show Gist options
  • Save freekman/cc83b53402192190e9b8 to your computer and use it in GitHub Desktop.
Save freekman/cc83b53402192190e9b8 to your computer and use it in GitHub Desktop.
Interface Separation
package task4;
import java.util.List;
/**
* @author Ivan Genchev ([email protected])
*/
public class MyClass {
class Customer {
}
//
// interface CustomerRepository {
// void register(Customer customer);
//
// List<Customer> findAll();
// }
//
interface CustomerFinder {
List<Customer> findAll();
}
interface CustomerRegistry {
void register(Customer customer);
}
class PersistentCustomerRepository implements CustomerFinder, CustomerRegistry {
@Override
public List<Customer> findAll() {
return null;
}
@Override
public void register(Customer customer) {
}
}
class ClassUnderTest {
private final CustomerFinder finder;
ClassUnderTest(CustomerFinder finder) {
this.finder = finder;
}
public void method1() {
finder.findAll();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment