Guest User

Untitled

a guest
Dec 13th, 2017
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1. //
  2. // CHALLENGE (work in pairs):
  3. // Move from f(o) -> o.f() and sure that the code is CQS compliant.
  4. //
  5.  
  6.  
  7. // 1
  8. class CsvFile<T extends Lines>{
  9. public CsvFile(Path path){
  10. ...
  11. }
  12. Collection<T> lines();
  13. }
  14.  
  15. // 2
  16. interface Ping {
  17. void send();
  18. }
  19.  
  20.  
  21. // 3
  22. interface TcpSocket {
  23. Stream<Byte> stream();
  24. }
  25.  
  26. // 4
  27. // Iovation - a company that maintains a blacklist of email addresses and corresponding IPs
  28. interface Blacklist {
  29. boolean contains(WebsiteVisitor websiteVisitor);
  30. }
  31.  
  32. WebsiteVisitor {
  33. String email();
  34. String ipAddress();
  35. }
  36.  
  37. // 5
  38. //interface AnonymousUserAuthenticator {
  39. // Token authenticate(String username, String password) throws WrongAuthenticationCredentialsProvided;
  40. //}
  41.  
  42. Authentication{
  43. private String name;
  44. private String password;
  45. Authentication(String name, String password){...}
  46. public boolean authenticate() throws WrongAuthenticationCredentialsProvided;
  47. public Token token();
  48. }
  49.  
  50.  
  51. // 6
  52. interface Test {
  53. interface Result {
  54. void print();
  55. }
  56. boolean hasFinished();
  57. Collection<Result> getResults();
  58. }
  59.  
  60. if (test.hasFinished()) {
  61. for (Result result : test.getResults()) {
  62. result.prettyPrint();
  63. }
  64. }
  65.  
  66.  
  67. // 7
  68. boolean destroyButtonPresent =
  69. widgets
  70. .stream()
  71. .filter(Widget::isButton)
  72. .map(button::label)
  73. .anyMatch("Destroy The World"::equals);
  74.  
  75. // 8
  76. interface File {
  77. void open(); // test instead of throws FileNotFound
  78. }
Add Comment
Please, Sign In to add comment