SlideShare a Scribd company logo
1 of 24
Download to read offline
/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

More from Yegor Bugayenko

Software Testing Pitfalls
Software Testing PitfallsSoftware Testing Pitfalls
Software Testing PitfallsYegor Bugayenko
 
Five Trends We Are Afraid Of
Five Trends We Are Afraid OfFive Trends We Are Afraid Of
Five Trends We Are Afraid OfYegor Bugayenko
 
Who Cares About Quality?
Who Cares About Quality?Who Cares About Quality?
Who Cares About Quality?Yegor Bugayenko
 
Zold: a cryptocurrency without Blockchain
Zold: a cryptocurrency without BlockchainZold: a cryptocurrency without Blockchain
Zold: a cryptocurrency without BlockchainYegor Bugayenko
 
How to Cut Corners and Stay Cool
How to Cut Corners and Stay CoolHow to Cut Corners and Stay Cool
How to Cut Corners and Stay CoolYegor Bugayenko
 
Make Customers Trust You
Make Customers Trust YouMake Customers Trust You
Make Customers Trust YouYegor 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?
How to Be Honest and Keep a Client?Yegor Bugayenko
 
Object-Oriented JUnit Tests
Object-Oriented JUnit TestsObject-Oriented JUnit Tests
Object-Oriented JUnit TestsYegor Bugayenko
 
Object-Oriented Flavor for JUnit Tests
Object-Oriented Flavor for JUnit TestsObject-Oriented Flavor for JUnit Tests
Object-Oriented Flavor for JUnit TestsYegor Bugayenko
 
How to Avoid Outsourcing Disaster?
How to Avoid Outsourcing Disaster?How to Avoid Outsourcing Disaster?
How to Avoid Outsourcing Disaster?Yegor Bugayenko
 
What's Wrong With Object-Oriented Programming?
What's Wrong With Object-Oriented Programming?What's Wrong With Object-Oriented Programming?
What's Wrong With Object-Oriented Programming?Yegor Bugayenko
 
How Bright Is Our Future?
How Bright Is Our Future?How Bright Is Our Future?
How Bright Is Our Future?Yegor Bugayenko
 
Java Annotations Are Evil
Java Annotations Are EvilJava Annotations Are Evil
Java Annotations Are EvilYegor Bugayenko
 

More from Yegor Bugayenko (20)

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

Recently uploaded

Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 

Recently uploaded (20)

Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 

Java Annotations Are a Bad Idea