Creating an organized Java library

后端 未结 2 646
自闭症患者
自闭症患者 2021-01-28 17:51

I want to create a library(Jar file) in Java which would contain all my methods for the database we use. There are about 60 methods in there so I would like to make it more orga

2条回答
  •  再見小時候
    2021-01-28 18:32

    You could save yourself a lot of trouble and write a generic DAO:

    package persistence;
    
    public interface GenericDao {
        V find(K id);
        List find();
        K save(V value);
        void update(V value);
        void delete(V value);
    }
    

    I'd forget about writing your own persistence classes and use a proven solution, like Spring JDBC template.

    This problem has been solved many times, many ways. What do you hope to do to improve upon what exists? How will you justify the added expense of developing, testing, and maintaining this functionality?

提交回复
热议问题