java-design-patterns icon indicating copy to clipboard operation
java-design-patterns copied to clipboard

Unit of Work pattern is Too simplified

Open lihongjie0209 opened this issue 5 years ago • 2 comments

unit-of-work/src/main/java/com/iluwatar/unitofwork/StudentDatabase.java

how can u save a complex object graph with a simple modify call?

should modify update everything in object graph?

public class StudentDatabase {

  public void insert(Student student) {
    //Some insert logic to DB
  }

  public void modify(Student student) {
    //Some modify logic to DB
  }

  public void delete(Student student) {
    //Some delete logic to DB
  }
}

lihongjie0209 avatar Apr 18 '19 02:04 lihongjie0209

It.s seems better to add a final prefix before String delete, modify, insert。 public interface IUnitOfWork<T> { String INSERT = "INSERT"; String DELETE = "DELETE"; String MODIFY = "MODIFY";

cloudeswift avatar May 31 '20 12:05 cloudeswift

It.s seems better to add a final prefix before String delete, modify, insert。 public interface IUnitOfWork<T> { String INSERT = "INSERT"; String DELETE = "DELETE"; String MODIFY = "MODIFY";

@cloudeswift variables of interface are final static by default. This PR is not required https://stackoverflow.com/questions/2430756/why-are-interface-variables-static-and-final-by-default

IAmPramod avatar Jun 15 '20 02:06 IAmPramod