Advertisement

How Anemic Objects Kill OOP

Jul. 13, 2016
Advertisement

More Related Content

Advertisement

How Anemic Objects Kill OOP

  1. /16@yegor256 1 How Anemic Objects
 Kill OOP Yegor Bugayenko
  2. /16@yegor256 2 1. Procedural programming 2. Object thinking (programming)? 3. Practical example 4. What is anemic model? 5. Refactoring 6. Let’s discuss
  3. /16@yegor256 3 1. Code is king (how) 2. Imperative 3. Same as hardware 4. Data is visible
  4. /16@yegor256 4 1. Object is king (what) 2. Declarative 3. Same as real world 4. Data is hidden
  5. /16@yegor256 5 a = 3 + 5; new Sum(3, 5);
  6. /16@yegor256 6 complexity is growing because data has no semantic
  7. /16@yegor256 7 OOP was supposed to become a solution
  8. /16@yegor256 8 “Objects expose behavior and data” — article about
 Procedural Programming
  9. /16@yegor256 9 API DB book1 book2 book1 = API.fetch(); book2.isbn = book1.isbn; book2.title = book1.isbn; DB.save(book2);
  10. /16@yegor256 10 class Book { public String isbn; public String title; }
  11. /16@yegor256 11 class Book { private String isbn; private String title; public String getIsbn(); public String getTitle(); public void setIsbn(String); public void setTitle(String); }
  12. /16@yegor256 12 1. Data is still visible 2. Still imperative 3. No semantic
  13. /16@yegor256 13 API DB new DBBook(new APIBook());
  14. /16@yegor256 14 class APIBook implements Book { String title() { // make HTTP request // parse JSON and // return title } }
  15. /16@yegor256 15 class DBBook implements Book { private Book book; String title() { String title = this.book.title(); // save title to the DB return title; } }
  16. /16@yegor256 16 what do you think?
Advertisement