SlideShare a Scribd company logo
/24@yegor256 1
Yegor Bugayenko
Java Annotations Are

a Bad Idea
/34@yegor256 2
14K+
1.2K+
250+ Why Me?
/42@yegor256 3
takes.org
eolang.org
“Elegant Objects”
/42@yegor256 4
cactoos.org
/24@yegor256 5
Object
/24@yegor256 6
Object
Smth
/42@yegor256 7
Maintainability suffers.
/24@yegor256 8
Object
/24@yegor256 9
class Storage {
void save(@NotNull Book book) {
//
}
}
storage.save(book);
w/annotation
/24@yegor256 10
class Storage {
void save(Book book) {
//
}
}
storage.save(new NotNullBook(book));
w/o annotation
/24@yegor256 11
class Storage {
@RetryOnFailure
boolean save(Book book) {
//
}
}
boolean done = storage.save(book);
w/annotation
jcabi.com
/24@yegor256 12
class Storage {
void save(Book book) {
//
}
}
boolean done = new RetryFunc<>(
book -> storage.save(book)
);
w/o annotation
cactoos.org
/24@yegor256 13
class Storage {
@Cacheable(forever = true)
Book find(int id) {
//
}
}
Book book = storage.find(123);
storage.find(123);
w/annotation
jcabi.com
/24@yegor256 14
class Storage {
private final Func<Integer, Book> cache = new StickyFunc<>(
id -> this.findById(id)
);
Book find(int id) {
return this.cache.apply(id);
}
Book findById(int id) {
// ..
}
}
Book book = storage.find(123);
storage.find(123);
cactoos.org
w/o annotation
/24@yegor256 15
class Book {
@XmlElement
void getName() {
//
}
}
String xml = marshaller.marshal(book);
w/annotation
/24@yegor256 16
class Book {
private final String name;
String asXML() {
return new Xembler(
new Directives()
.add(“book”)
.add(“name”)
.set(this.name)
).xmlQuietly();
}
}
String xml = book.asXML();
w/o annotation
xembly.org
/24@yegor256 17
class BookResource {
@GET
String index() {
return “Hello, world!”;
}
}
// ???
w/annotation
/24@yegor256 18
class BookFront implements Take {
Response act(Request req) {
return new RsText(“Hello, world!”);
}
}
new FtCli(new BookFront()).exec();
w/o annotation
takes.org
/24@yegor256 19
class Book {
@Inject
private final Storage storage;
String name() {
return this.storage.sql(
“SELECT name FROM book WHERE id=123”
);
}
}
Book book = container.get(Book.class);
String name = book.name();
w/annotation
/24@yegor256 20
class Book {
private final Storage storage;
Book(Storage s) {
this.storage = s;
}
String name() {
return this.storage.sql(
“SELECT name FROM book WHERE id=123”
);
}
}
Book book = new Book(new Storage());
String name = book.name();
w/o annotation
/24@yegor256 21
@Singleton
class Storage {
String fetch(String sql) {
// ..
}
}
Storage storage = container.get(Storage.class);
container.get(Storage.class);
w/annotation
/24@yegor256 22
w/o annotation
No Singletons!
/24@yegor256 23
Object
/24@yegor256 24

More Related Content

PDF
Can Distributed Teams Deliver Quality?
PDF
Are You Sure You Are Not a Micromanager?
PDF
On Requirements Management (Demotivate Them Right)
PDF
My Experience of 1000 Interviews
PDF
Are you sure you are not a micromanager?
PDF
Quality Assurance vs. Testing
PDF
Is Java Getting Better?
PDF
Typical Pitfalls in Testing
Can Distributed Teams Deliver Quality?
Are You Sure You Are Not a Micromanager?
On Requirements Management (Demotivate Them Right)
My Experience of 1000 Interviews
Are you sure you are not a micromanager?
Quality Assurance vs. Testing
Is Java Getting Better?
Typical Pitfalls in Testing

More from Yegor Bugayenko (20)

PDF
Software Testing Pitfalls
PDF
Five Trends We Are Afraid Of
PDF
Experts vs Expertise
PDF
Who Cares About Quality?
PDF
Quantity vs. Quality
PDF
Experts vs Expertise
PDF
Zold: a cryptocurrency without Blockchain
PDF
Life Without Blockchain
PDF
How to Cut Corners and Stay Cool
PDF
Math or Love?
PDF
How much do you cost?
PDF
Make Customers Trust You
PDF
How to Be Honest and Keep a Client?
PDF
Object-Oriented JUnit Tests
PDF
Object-Oriented Flavor for JUnit Tests
PDF
How Much Do You Cost?
PDF
How to Avoid Outsourcing Disaster?
PDF
What's Wrong With Object-Oriented Programming?
PDF
How Bright Is Our Future?
PDF
Java Annotations Are Evil
Software Testing Pitfalls
Five Trends We Are Afraid Of
Experts vs Expertise
Who Cares About Quality?
Quantity vs. Quality
Experts vs Expertise
Zold: a cryptocurrency without Blockchain
Life Without Blockchain
How to Cut Corners and Stay Cool
Math or Love?
How much do you cost?
Make Customers Trust You
How to Be Honest and Keep a Client?
Object-Oriented JUnit Tests
Object-Oriented Flavor for JUnit Tests
How Much Do You Cost?
How to Avoid Outsourcing Disaster?
What's Wrong With Object-Oriented Programming?
How Bright Is Our Future?
Java Annotations Are Evil
Ad

Recently uploaded (20)

PDF
Getting Started with Data Integration: FME Form 101
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Accuracy of neural networks in brain wave diagnosis of schizophrenia
PPT
Teaching material agriculture food technology
PPTX
Big Data Technologies - Introduction.pptx
PDF
A comparative analysis of optical character recognition models for extracting...
PDF
Encapsulation theory and applications.pdf
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Electronic commerce courselecture one. Pdf
PDF
Encapsulation_ Review paper, used for researhc scholars
PPTX
Tartificialntelligence_presentation.pptx
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PPTX
Machine Learning_overview_presentation.pptx
Getting Started with Data Integration: FME Form 101
Building Integrated photovoltaic BIPV_UPV.pdf
Programs and apps: productivity, graphics, security and other tools
The Rise and Fall of 3GPP – Time for a Sabbatical?
Accuracy of neural networks in brain wave diagnosis of schizophrenia
Teaching material agriculture food technology
Big Data Technologies - Introduction.pptx
A comparative analysis of optical character recognition models for extracting...
Encapsulation theory and applications.pdf
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
Advanced methodologies resolving dimensionality complications for autism neur...
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Per capita expenditure prediction using model stacking based on satellite ima...
Electronic commerce courselecture one. Pdf
Encapsulation_ Review paper, used for researhc scholars
Tartificialntelligence_presentation.pptx
Diabetes mellitus diagnosis method based random forest with bat algorithm
Dropbox Q2 2025 Financial Results & Investor Presentation
Machine Learning_overview_presentation.pptx
Ad

Java Annotations Are a Bad Idea