I have tried to make this a "generic" question as I have seen this in Java and C#, and I'm assuming it is in other OO languages as well.
I know there are three "main" frameworks for an application that accesses data and that perform CRUD operations:
Sometimes these design patterns use a DAO and sometimes they use a DTO.
In looking at tutorials and examples of applications that use one of these three design patterns, most, if not all, do something like this:
BaseRepositoryInterface (I have sometimes seen this as an interface and sometimes seen it as an abstract class)
interface BaseRepositoryInterface {
findOne(integer id);
findAll();
create();
read(integer id);
update(integer id);
delete(integer id);
}
SpecificRepositoryInterface
interface SpecificRepositoryInterface implements BaseRepositoryInterface {
// Just Some Examples
specificActionNumberOne(integer id, String someString);
specificActionNumberTwo(integer id, Object someObject);
specificActionNumberThree(integer id, double someDouble);
}
ConcreteRepositoryClass
class ConcreteRepositoryClass implements SpecificRepositoryInterface {
Dao myDao;
// or
Dto myDto;
ConcreteRepositoryClass(Dao someDao)
// or
ConcreteRepositoryClass(Dto someDto)
{
this.myDao = someDao;
// or
this.myDto = someDto;
}
findOne(integer id){
// implement here ...
}
findAll(){
// implement here ...
}
create(){
// implement here ...
}
read(integer id){
// implement here ...
}
update(integer id){
// implement here ...
}
delete(integer id){
// implement here ...
}
specificActionNumberOne(integer id, String someString){
// implement here ...
}
specificActionNumberTwo(integer id, Object someObject){
// implement here ...
}
specificActionNumberThree(integer id, double someDouble){
// implement here ...
}
}
This is not always exactly the same in all examples, but they all tend to follow the same format.
Given this, is there a name for this design pattern?
Is it safe to assume that this pattern whose name I am looking for is the "presenter", "controller", or "view model" portion of the aforementioned frameworks, just further abstracted?
Aucun commentaire:
Enregistrer un commentaire