April 2018
Intermediate to advanced
396 pages
11h 8m
English
For the factory method, we will be showing an example with databases. To keep things simple (just because the actual java.sql.Connection has a lot of methods), we will define our own SimpleConnection and it will have concrete implementations for MySQL and PostgreSQL.
The diagram for the connection classes looks like the following:

Now, creating these connections will depend on the database we want to use. However, using them will be exactly the same because of the interface they provide. The actual creation might also involve some extra computations that we want to hide from the user and which will be relevant if we're ...
Read now
Unlock full access