I'm making a project based on MVC pattern, but I have doubts about the location of the methods (insert, update and delete), I don't know if it is in the Model classes or is in another part (please look the code). Another doubt about this is the interfaces (class Car implements CarInterface { ... }
), it's necessary or can I avoid it?
Controller:
class ServletCar extends HttpServlet {
...
public void doPost( ... )
{
...
switch (action) {
...
case 'insert':
Car n = new Car();
n.set( request );
n.insert();
...
break;
...
}
...
}
}
View (Car.jsp):
...
<form action="ServletCar" ...>
...
</form>
...
Model:
class Car {
// attributes
...
// gets ands sets
...
// functions i,u,d
public void insert( ... ) { ... }
public void update( ... ) { ... }
public void delete( ... ) { ... }
// other methods
...
}