5/23/2006

Generating Java Best Seller Book Titles

A slews of books are written for each tech buzz, and their titles are so similar to the point you can reliably predict it. Just for fun, I've written a simple Java class to generate these titles.

import java.util.Arrays;
public class BookTitlesGen {
public static final String[] technologies = new String[]{
"AJAX", "EJB3", "JSF", "Web Services"
};

public static final String[] templates = new String[] {
"XXX in Action", "Professional XXX",
"Effective XXX", "Master XXX",
"XXX Definitive Guide", "Core XXX",
"XXX Cookbook","XXX Bible",
"Head First XXX", "XXX Best Practice",
"A Developer's Guide to XXX",
"XXX Unleashed", "XXX for Dummies",
};

public static void main(String[] args) {
genBookTitles();
}

private static void genBookTitles() {
for(String technology : technologies) {
String banner = "Best Seller Books for " + technology;
char[] line = new char[banner.length()];
Arrays.fill(line, '=');
System.out.println(banner);
System.out.println(line);
for(String template : templates) {
String title = template.replaceAll("XXX", technology);
System.out.println(title);
}
System.out.println("");
}
}
}

Best Seller Books for AJAX
==========================
AJAX in Action
Professional AJAX
Effective AJAX
Master AJAX
AJAX Definitive Guide
Core AJAX
AJAX Cookbook
AJAX Bible
Head First AJAX
AJAX Best Practice
A Developer's Guide to AJAX
AJAX Unleashed
AJAX for Dummies

Best Seller Books for EJB3
==========================
EJB3 in Action
Professional EJB3
Effective EJB3
Master EJB3
EJB3 Definitive Guide
Core EJB3
EJB3 Cookbook
EJB3 Bible
Head First EJB3
EJB3 Best Practice
A Developer's Guide to EJB3
EJB3 Unleashed
EJB3 for Dummies
They are roughly in the order of popularity. To save space, I omitted the output for JSF and Web Services. Can't we have better names?