Recent Pos

Factory Design Pattern Implementation Inside DAO Example


abstract factory design pattern implementation in java jdbc
⇒ This is one of the most useful core creational design patterns.
⇒ This describes the solution for the object creation problem.
⇒ According to this pattern we want to implement a special object/method that can create the object and return.
⇒ After the observing the project code of the previous example i.e. EmployeeDAO we found the code creating the Connection is duplicated into multiple methods, this makes the system to manage difficult.
⇒ To solve this problem we may want implement a ConnectionFactory utility.
⇒ The following is an ConnectionFactory for the Project:

⇒ Now we can use ConnectionFactory utility in our ems project as:

Download this

Singleton Pattern:

⇒ It is also an important object oriented design patterns.

⇒ It designs only one instance for a class in the given context and can be used throughout the project. The most common way of creating singleton pattern in Java is to have only one object in JVM as shown below:

How many ways we can create object in Java?

We have three basic ways to do this:

1. new keyword.

2. newInstance() method of class.

3. De-serialization.
Note: The factory method and any other listed would be taken as derived ways of creating the Java object.
<-Previous: Example Application for CRUD Operations Using JDBC | | Next->Working with JDBC ResultSet object

No Comments

Post a Comment