mercredi 21 août 2019

Should DAO methods receive a data object as parameter or just its contents?

I am thinking about two different approaches for a DAO and I was wondering which is more correct. Let's say that we have the following class:

public class Employee {

private int id;
private String name;

//getters and setters

}

And the following two approaches for the DAO:

A)

public class EmployeeDao {

    public Employee insert(int id, String name) {
    ...
    }

B) :

public class EmployeeDao {

    public Employee insert(Employee employee) {
    ...
    }

My question is whether both approaches are correct and/or one of them is more correct than the other.

Thank you for your attention.

Aucun commentaire:

Enregistrer un commentaire