18. /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
19. /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
20. /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