SlideShare una empresa de Scribd logo
1 de 24
Descargar para leer sin conexión
/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

Más contenido relacionado

Más de Yegor Bugayenko

Más de 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
 

Último

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Último (20)

2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
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
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
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
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 

Java Annotations Are a Bad Idea