OiO.lk Blog java Java program using Clean Architecture, DAO and Repository
java

Java program using Clean Architecture, DAO and Repository


I’m developing a simple Java console program to access PostgreSQL database using JDBC.
The most inner layers talk to the outer layers by means abstraction (interface and abstract class).

My program follows the Clean Architecture and I have the following:

  • domain
    • entity

        Student.java
      
        Course.java
      
    • repository

        Repository<T> (interface)
      
        StudentRepository (interface)
      
        CourseRepository (interface)
      
  • use case

      StudentUseCase.java
    
      CourseUseCase.java
    
  • infra

    • data

        ConnectionFactory.java
      
        DAO<T> (interface)
      
        StudentDAO.java (interface extends DAO)
      
        CourseDAO.java (interface extends DAO)
      
        StudentDAOImpl.java
      
        CourseDAOImpl.java
      
        StudentRepositoryImpl.java
      
        CourseRepository.java
      

Considering "scalability", the architecture of my program is OK? Can I have Repository and DAO at the same time? I guess so because this approach makes switching DB easier. Besides, My StudentRepositoryImpl has the method getAllStudents(), where it uses 2 DAO methods: getAllStudents() e getCourseByStudentId(int id). So, the StudentRepositoryImpl can properly combines the query results of both DAO methos to composethe Student objects (Student has the attributes: int id, String name and Course course).
I appreciate comments about. Thanks in advance.



You need to sign in to view this answers

Exit mobile version