- 6 hours
- Medium
Free online content available in this course.
course.header.alt.is_video
course.header.alt.is_certifying
Got it!Last updated on 4/15/20
Organize Persistence Logic in Your Code with the Repository Pattern
Evaluated skills
- Organize Persistence Logic in Your Code with the Repository Pattern
Question 1
What are the three aspects of repository patterns?
Careful, there are several correct answers.An application programming interface (API), usually implemented in Java as an interface.
A set of facade classes that implement the interface and carry out persistence operations using a particular persistence technology (e.g., one set that uses Hibernate, another that uses JAXB).
A factory method, or an injection mechanism, that is configured to pick the particular facade desired for the application.
A good logging system to uncover problems when they arise.
A configuration file to select which facade class should be used.
Question 2
What could a CRUD interface look like for a vehicle object?
Careful, there are several correct answers.public interface VehicleRepository { public void create(Vehicle v); public Vehicle read(String registration); public void update(Vehicle v); public void delete(Vehicle v); }
public interface VehicleRepository { public void newVehicle(Vehicle v); public Vehicle read(String registration); public void listAll(); public void delete(Vehicle v); }
public interface VehicleRepository { public void newVehicle(Vehicle v); public Vehicle get(String registration); public void save(Vehicle v); public void remove(Vehicle v); }
public interface VehicleRepository { public void save(Vehicle v); public List<Vehicle> list(String registration); public void store(Vehicle v); public Vehicle get(String registration); }
Question 3
What are the main problems with facades and interfaces that are particularly relevant for persistence?
Careful, there are several correct answers.Lost features.
Errors can be lost or obscured.
There is no logging.
Patterns are over-used.
- Up to 100% of your training program funded
- Flexible start date
- Career-focused projects
- Individual mentoring