Java Annotations Are Evil

/24@yegor256 1
Аннотации — это зло
Yegor Bugayenko
Annotations Are Evil
/24@yegor256 2
“Егор в своем стиле: все
гондурасы, а я д’Артаньян.”
Д’Артаньян и три мушкетёра (1978)
/24@yegor256 3
“Попал как будто на выступление
лидера какой-то секты.”
The Evil Cult (1993)
/24@yegor256 4
“Автор — маньяк.”
The Silence of the Lambs (1991)
/24@yegor256 5
1000+
takes.org
14000+
jcabi.com
rultor.com
jare.io
since

1988
2007
250+
/24@yegor256 6
since 2014
/24@yegor256 7
Compiler: @Override, @Deprecated, @SuppressWarning
DI: @Inject, @Singleton, etc.
Serialization: @XmlElement, etc.
Validation: @NotNull, etc.
Behavior: @GET, @Transaction
AOP: @RetryOnFailure, @Cacheable
Unit testing: @Test, @Before, @Rule, etc.
Lombok: @ToString, @EqualsAndHashCode, etc.
Something else?…
/24@yegor256 8
class Page {
@GET
String index() {
return “Hello, world!”;
}
}
/24@yegor256 9
class Page {
String index(Request request) {
if (request.method().equals(“GET”)) {
return “Hello, world!”;
}
return “Method not allowed”;
}
}
/24@yegor256 10
class Page {
@GET
String index() {
return “Hello, world!”;
}
}
class Dispatcher {
String dispatch(Page page, Request request) {
if (request.method().equals(“GET”)
&& page.getClass().getMethod(“index”)
.isAnnotationPresent(GET.class)) {
return page.index();
}
return “Method not allowed”;
}
}
/24@yegor256 11
Page Dispatcher
/24@yegor256 12
Page
Dispatcher
1 upside down
/24@yegor256 13
Page
Dispatcher
2 unclear dependencies
???
/24@yegor256 14
—Ты BeanPostProcessor видишь?
—Нет.
—А он есть!
ДМБ (2000)
/24@yegor256 15
Page
3 no encapsulation
Data
/24@yegor256 16
HelloPage
GETPage
/24@yegor256 17
class HelloPage implements Page {
@Override
String index(Request request) {
return “200 Hello, world!”;
}
}
class GETPage implements Page {
private final Page page;
@Override
String index(Request request) {
if (request.method().equals(“GET”)) {
return page.index();
}
return “Method not allowed”;
}
}
/24@yegor256 18
procedural
/24@yegor256 19
object-oriented
/24@yegor256 20
Compiler: @Override, @Deprecated, @SuppressWarning
DI: @Inject, @Singleton, etc.
Serialization: @XmlElement, etc.
Validation: @NotNull, etc.
Behavior: @GET, @Transaction
AOP: @RetryOnFailure, @Cacheable
Unit testing: @Test, @Before, @Rule, etc.
Lombok: @ToString, @EqualsAndHashCode, etc.
/24@yegor256 21
/24@yegor256 22
Can I see the code?Можно ли посмотреть код?
/24@yegor256 23
The Shining (1980)
/24@yegor256 24
yegor256.com
1 of 24

Recommended

Can Distributed Teams Deliver Quality? by
Can Distributed Teams Deliver Quality?Can Distributed Teams Deliver Quality?
Can Distributed Teams Deliver Quality?Yegor Bugayenko
269 views23 slides
Are You Sure You Are Not a Micromanager? by
Are You Sure You Are Not a Micromanager?Are You Sure You Are Not a Micromanager?
Are You Sure You Are Not a Micromanager?Yegor Bugayenko
245 views16 slides
On Requirements Management (Demotivate Them Right) by
On Requirements Management (Demotivate Them Right)On Requirements Management (Demotivate Them Right)
On Requirements Management (Demotivate Them Right)Yegor Bugayenko
220 views16 slides
My Experience of 1000 Interviews by
My Experience of 1000 InterviewsMy Experience of 1000 Interviews
My Experience of 1000 InterviewsYegor Bugayenko
219 views20 slides
Are you sure you are not a micromanager? by
Are you sure you are not a micromanager?Are you sure you are not a micromanager?
Are you sure you are not a micromanager?Yegor Bugayenko
251 views15 slides
Quality Assurance vs. Testing by
Quality Assurance vs. TestingQuality Assurance vs. Testing
Quality Assurance vs. TestingYegor Bugayenko
660 views25 slides

More Related Content

More from Yegor Bugayenko

Software Testing Pitfalls by
Software Testing PitfallsSoftware Testing Pitfalls
Software Testing PitfallsYegor Bugayenko
295 views35 slides
Five Trends We Are Afraid Of by
Five Trends We Are Afraid OfFive Trends We Are Afraid Of
Five Trends We Are Afraid OfYegor Bugayenko
378 views23 slides
Experts vs Expertise by
Experts vs ExpertiseExperts vs Expertise
Experts vs ExpertiseYegor Bugayenko
422 views28 slides
Who Cares About Quality? by
Who Cares About Quality?Who Cares About Quality?
Who Cares About Quality?Yegor Bugayenko
272 views21 slides
Quantity vs. Quality by
Quantity vs. QualityQuantity vs. Quality
Quantity vs. QualityYegor Bugayenko
326 views34 slides
Experts vs Expertise by
Experts vs ExpertiseExperts vs Expertise
Experts vs ExpertiseYegor Bugayenko
225 views37 slides

More from Yegor Bugayenko(20)

Zold: a cryptocurrency without Blockchain by Yegor Bugayenko
Zold: a cryptocurrency without BlockchainZold: a cryptocurrency without Blockchain
Zold: a cryptocurrency without Blockchain
Yegor Bugayenko282 views
How to Cut Corners and Stay Cool by Yegor Bugayenko
How to Cut Corners and Stay CoolHow to Cut Corners and Stay Cool
How to Cut Corners and Stay Cool
Yegor Bugayenko318 views
How to Be Honest and Keep a Client? by Yegor Bugayenko
How to Be Honest and Keep a Client?How to Be Honest and Keep a Client?
How to Be Honest and Keep a Client?
Yegor Bugayenko478 views
Object-Oriented Flavor for JUnit Tests by Yegor Bugayenko
Object-Oriented Flavor for JUnit TestsObject-Oriented Flavor for JUnit Tests
Object-Oriented Flavor for JUnit Tests
Yegor Bugayenko691 views
How to Avoid Outsourcing Disaster? by Yegor Bugayenko
How to Avoid Outsourcing Disaster?How to Avoid Outsourcing Disaster?
How to Avoid Outsourcing Disaster?
Yegor Bugayenko846 views
What's Wrong With Object-Oriented Programming? by Yegor Bugayenko
What's Wrong With Object-Oriented Programming?What's Wrong With Object-Oriented Programming?
What's Wrong With Object-Oriented Programming?
Yegor Bugayenko2.2K views

Recently uploaded

Data Integrity for Banking and Financial Services by
Data Integrity for Banking and Financial ServicesData Integrity for Banking and Financial Services
Data Integrity for Banking and Financial ServicesPrecisely
21 views26 slides
Scaling Knowledge Graph Architectures with AI by
Scaling Knowledge Graph Architectures with AIScaling Knowledge Graph Architectures with AI
Scaling Knowledge Graph Architectures with AIEnterprise Knowledge
30 views15 slides
Tunable Laser (1).pptx by
Tunable Laser (1).pptxTunable Laser (1).pptx
Tunable Laser (1).pptxHajira Mahmood
24 views37 slides
Piloting & Scaling Successfully With Microsoft Viva by
Piloting & Scaling Successfully With Microsoft VivaPiloting & Scaling Successfully With Microsoft Viva
Piloting & Scaling Successfully With Microsoft VivaRichard Harbridge
12 views160 slides
SAP Automation Using Bar Code and FIORI.pdf by
SAP Automation Using Bar Code and FIORI.pdfSAP Automation Using Bar Code and FIORI.pdf
SAP Automation Using Bar Code and FIORI.pdfVirendra Rai, PMP
23 views38 slides
Design Driven Network Assurance by
Design Driven Network AssuranceDesign Driven Network Assurance
Design Driven Network AssuranceNetwork Automation Forum
15 views42 slides

Recently uploaded(20)

Data Integrity for Banking and Financial Services by Precisely
Data Integrity for Banking and Financial ServicesData Integrity for Banking and Financial Services
Data Integrity for Banking and Financial Services
Precisely21 views
Piloting & Scaling Successfully With Microsoft Viva by Richard Harbridge
Piloting & Scaling Successfully With Microsoft VivaPiloting & Scaling Successfully With Microsoft Viva
Piloting & Scaling Successfully With Microsoft Viva
SAP Automation Using Bar Code and FIORI.pdf by Virendra Rai, PMP
SAP Automation Using Bar Code and FIORI.pdfSAP Automation Using Bar Code and FIORI.pdf
SAP Automation Using Bar Code and FIORI.pdf
Igniting Next Level Productivity with AI-Infused Data Integration Workflows by Safe Software
Igniting Next Level Productivity with AI-Infused Data Integration Workflows Igniting Next Level Productivity with AI-Infused Data Integration Workflows
Igniting Next Level Productivity with AI-Infused Data Integration Workflows
Safe Software263 views
Transcript: The Details of Description Techniques tips and tangents on altern... by BookNet Canada
Transcript: The Details of Description Techniques tips and tangents on altern...Transcript: The Details of Description Techniques tips and tangents on altern...
Transcript: The Details of Description Techniques tips and tangents on altern...
BookNet Canada136 views
Attacking IoT Devices from a Web Perspective - Linux Day by Simone Onofri
Attacking IoT Devices from a Web Perspective - Linux Day Attacking IoT Devices from a Web Perspective - Linux Day
Attacking IoT Devices from a Web Perspective - Linux Day
Simone Onofri16 views
GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N... by James Anderson
GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N...GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N...
GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N...
James Anderson85 views
Empathic Computing: Delivering the Potential of the Metaverse by Mark Billinghurst
Empathic Computing: Delivering  the Potential of the MetaverseEmpathic Computing: Delivering  the Potential of the Metaverse
Empathic Computing: Delivering the Potential of the Metaverse
Mark Billinghurst478 views
AMAZON PRODUCT RESEARCH.pdf by JerikkLaureta
AMAZON PRODUCT RESEARCH.pdfAMAZON PRODUCT RESEARCH.pdf
AMAZON PRODUCT RESEARCH.pdf
JerikkLaureta26 views

Java Annotations Are Evil