Java Reference
In-Depth Information
Appendix A
A Tour of Paradigms
Many books, articles, and conversations will wax poetic about programming language paradigms,
comparing and contrasting “imperative,” “object-oriented,” and “functional” without explaining what they
are. Worse, when people go to explain these particular styles, the result is often rather vague. This appendix
will provide an overview of the three dominant paradigms in post-functional programming by implementing
the same functionality three different ways: we will use a database set-up process as a common problem,
and show how you would solve that problem in each of the different paradigms. All of this will be done
directly from within Java, so you can see how Java looks when forced to be strongly in one single paradigm.
At the end of the chapter, we will highlight some additional programming paradigms and styles so that you
are at least familiar with the terms.
The database that we will be setting up is the database we used in chapter 5. This is a collection of the
words used in all the works of Shakespeare, indexed by line. The database looks like Figure A-1 . The data
comes from the Project Gutenberg text at http://www.gutenberg.org/ebooks/100 . To create this database,
we will have to perform the following steps:
1.
Create the schema, including the tables.
2.
Parse and insert the works of Shakespeare file.
a.
Empty lines and comments should be skipped.
b.
Text breaks (i.e., where a new text begins) need to be recognized, and a text
entry created.
c.
Each line needs to be parsed, and a line entry created.
d.
Each word in the line needs to be parsed.
i.
If the word does not previously exist, a word entry needs to be created.
ii.
A line_word entry needs to be created.
 
Search WWH ::




Custom Search