/42@yegor256 1
Yegor Bugayenko
What’s Wrong With

Object-Oriented Programming
/42@yegor256 2
takes.org
eolang.org
“Elegant Objects”
/42@yegor256 3
“Java is the most distressing
thing to happen to computing
since MS-DOS.”
—Alan Kay, 1997
/42@yegor256 4
“Object-oriented programming
offers a sustainable way to
write spaghetti code.”
—Paul Graham, 2003
/42@yegor256 5
“OO seems to bring at least as
many problems to the table as
it solves.”
—Jeff Atwood, 2007
/42@yegor256 6
Google Trends, May 2017
“OOP (blue) vs FP (red)”
https://goo.gl/Ezmma8
/42@yegor256 7
“Objects are not data
structures.”
—Robert Martin, 2014
https://goo.gl/qmRFH4
/42@yegor256 8
—page 98
“A class is a collection of
data fields that hold values
and methods that operate
on those values”
/42@yegor256 9
—page 40
“An object is some memory
that holds a value of some
type.”
/42@yegor256 10
“An object consists of some
private memory and a set of
operations.”
—page 6
/42@yegor256 11
Theory Practicevs.
/42@yegor256 12
Getters & Setters
1
/42@yegor256 13
public class Book {
private String title;
public void setTitle(String t) {
this.title = t;
}
public String getTitle() {
return this.title;
}
}
/42@yegor256 14
Static Methods
2
/42@yegor256 15
public class BookUtils {
public static void print(Book b) {
System.out.println(
“The title is: ” + b.getTitle()
);
}
}
/42@yegor256 16
NULL
3
/42@yegor256 17
Book b = library.find(“UML Distilled”);
if (b == null) {
// The book not found
} else {
System.out.println(
“This is the book: ” + b
);
}
/42@yegor256 18
Reflection
4
/42@yegor256 19
Book b = library.find(“UML Distilled”);
if (b instanceof Ebook) {
String pdf = Ebook.class.cast(b).getPDF();
}
/42@yegor256 20
Inheritance
5
/42@yegor256 21
pubic class Manuscript {
protected String title;
public String html() {
return “<h1>” + this.title + “</h1>”;
}
}
pubic class Book extends Manuscript {
protected String title;
public void rename(String t) {
this.title = t;
}
}
/42@yegor256 22
Annotations
6
/42@yegor256 23
Book b = new Book();
String xml = m.marshall(b);
@XmlRoot
class Book {
@XmlElement
private String title;
}
/42@yegor256 24
“I invented the term object-
oriented, and I can tell you I
did not have C++ in mind.”
—Alan Kay, 1997
/42@yegor256 25
The article on the blog:

What's Wrong With Object-Oriented Programming?