So I am currently studying for the OCPJP exam and have come across the sections requiring you to learn about:
DAO Pattern Factories and using factories from the API
Well from some googling this is what I understand so far:
to create only one instance of the class for the specific purpose, to do this:
set the default constructor as private
provide a public method to create and instance if one hasn't been created already
store the object in a private reference variable
to be 100% sure no one else can create a second object override the clone() method and throw a CloneNotSupportedException It is suggested to mark the method synchronized
Data Access Object - DAO
An object that provides an abstract interface to some type of database or persistence mechanism, providing specific operations without exposing details about the database.
the advantage is the relatively simple and rigorous separation between two parts of an application that can and should know very little of each other.
An object for creating other objects.
Typically has a method for every kind of object it is capable of creating.
determines the actual type of object to be created.
a way to combine simple objects into more complex ones. eg a car object is made up of objects like, an engine, wheels etc.
So a car has-a engine and a car has-a wheel etc.
So what I want to know is what I found correct in terms of Java technology?
And can you refer me to more comprehensive explanations and if possible examples?
Also do you know of any tutuorials or examples one could play with these ideas with?
And yes I plan to read head first Design patterns but am not quite there yet.