Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // CHALLENGE (work in pairs):
- // Move from f(o) -> o.f() and sure that the code is CQS compliant.
- //
- // 1
- class CsvFile<T extends Lines>{
- public CsvFile(Path path){
- ...
- }
- Collection<T> lines();
- }
- // 2
- interface Ping {
- void send();
- }
- // 3
- interface TcpSocket {
- Stream<Byte> stream();
- }
- // 4
- // Iovation - a company that maintains a blacklist of email addresses and corresponding IPs
- interface Blacklist {
- boolean contains(WebsiteVisitor websiteVisitor);
- }
- WebsiteVisitor {
- String email();
- String ipAddress();
- }
- // 5
- //interface AnonymousUserAuthenticator {
- // Token authenticate(String username, String password) throws WrongAuthenticationCredentialsProvided;
- //}
- Authentication{
- private String name;
- private String password;
- Authentication(String name, String password){...}
- public boolean authenticate() throws WrongAuthenticationCredentialsProvided;
- public Token token();
- }
- // 6
- interface Test {
- interface Result {
- void print();
- }
- boolean hasFinished();
- Collection<Result> getResults();
- }
- if (test.hasFinished()) {
- for (Result result : test.getResults()) {
- result.prettyPrint();
- }
- }
- // 7
- boolean destroyButtonPresent =
- widgets
- .stream()
- .filter(Widget::isButton)
- .map(button::label)
- .anyMatch("Destroy The World"::equals);
- // 8
- interface File {
- void open(); // test instead of throws FileNotFound
- }
Add Comment
Please, Sign In to add comment