-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating

Persistence Best Practices for Java Applications
By :

We, as software engineers, often discuss and adopt layered architectural solutions, but why? Why should we consider using this code style? What are its surrounding trade-offs? In order to provide a better understanding of code design patterns, we’ll illustrate a scenario around accomplishing a simple mission: storing and retrieving data from a database – more specifically, a library system that manages books and their respective data. At first glance, our task looks quite straightforward, right? Let’s get started.
First, we see the need to create an entity, a Book
class, which we can use to handle the library’s domain – our business domain. The first characteristic we can assume is that our Book
entity should be immutable. In this domain, the Book
entity attributes should be title
, author
, publisher
, and genre
.
The following code sample represents the described Book
class. Notice all fields...