Week 4 Flashcards
What does DAO stand for? Where does the pattern come from?
Data Access Objects, comes from Core J2EE
How does DAO work?
Separates business/domain layer from the data layer. Abstracts/encapsulates the data source and access to it.
What data source functions are encapsulated by DAO?
CRUD - Create, Retrieve, Update, Delete
The motivation behind the DAO pattern is isolated the _________/______ differences from the rest of the implementation.
business/domain.
You can easily change one part without changing the other.
What pattern is commonly added to the DAO pattern?
Factory
What are the 4 typical components of the DAO pattern?
Data source
Business/Domain object
Data Access Object
Data Transfer Object
Name this: Could be linked to an RDBMS, LDAP, XML
Data Source
Name this: Requires access to the Data Sources to obtain/store data
Domain or Business object
Keep in mind the access is not direct in this pattern
Name this: Performs the CRUD operations for the program and abstracts the data source
DAO
Name this: Encapsulates data sent between the DAO and Domain/business layer
DTO
When would you use a DAO interface? Why?
When there are multiple entities in the Data Source.
Same interface to access all entities, you implement a DAO class for each entity
Ex. entity_nameDAO
Should the Domain Object get “raw” exceptions from the Data Source? (Like SQLException)
No, the DAO should handle exceptions related to the Data Source and throw customer exceptions to the Domain Object
What is the Value Object? (Not DTO, even if its called that by mistake)
A small (usually immutable) object that encapsulates a value, like money, time, date.
The “bean” pattern is a programming convention. Explain
The constructor
Instance variables access modifiers
Getters and Setters
Serializable
no-arg public constructor
private instance vars
Getters and setters exist for each instance var
implements serializable
What is the bean pattern used for? If you need introspection or notifications should you implement it?
Reusable components. If introspection and notifications are needed implement JavaBean API