samedi 16 avril 2016

CRUD operations template in java

I'm designing a system where I must perform several CRUD operations among the System entities. Just for make sure I searched in forums to see how it's resolved by someone else.

I found 4 "patterns". All of them agree in the READ operations so I skip them. I'll define the patterns:

Pattern 1

void add(E entity);
void update(E entity);
// Read operations...
void delete(E entity);

Pattern 2

E create(<ListOfEntityProperties>);
void update(E entity);
// Read operations...
void delete(E entity);

Pattern 3

boolean add(E entity);
boolean update(E entity);
// Read operations...
boolean delete(E entity);

Pattern 4

E add(E entity);
void update(E entity);
// Read operations...
void delete(E entity);

I don't quite understand the difference and advantages/disadvantages of each one (and no one explains it). What are the differences between each "pattern"? What criteria to use?

Thanks in advance for your answers

Aucun commentaire:

Enregistrer un commentaire