mercredi 7 septembre 2022

Choosing Design Pattern Java [closed]

There are two code blocks. I call two different methods in these code blocks (save and update). I want to combine them without using if statement. Which design pattern should I use?

Thanks

System.out.println("Common 1");
repository.save(data);
System.out.println("Common 2");

System.out.println("Common 1");
repository.update(data);
System.out.println("Common 2");

Aucun commentaire:

Enregistrer un commentaire