For example, to create a course selection management system for students, the database has three tables: students, teacher, and course.
Dao layer interface design:
Interface studentdao
{
Public void insertstudent (student Stu );
Public void removestudent (long ID );
Public void updatestudent (student Stu );
Public student findstudent (long ID );
/**
* Other Dao Methods
**/
}
Interface teacherdao
{
Public void insertteacher (teacher tea );
Public void removeteacher (long ID );
Public void updateteacher (teacher tea );
Public Teacher findteacher (long ID );
/**
* Other Dao Methods
**/
}
Interface coursedao
{
Public void insertcourse (course C );
Public void removecourse (long ID );
Public void updatecourse (course C );
Public Teacher findcourse (long ID );
/**
* Other Dao Methods
**/
}
Business layer interface design:
Interface studentservice
{
Public void savestudent (student Stu );
Public void deletestudent (long ID );
Public void updatestudent (student Stu );
Public student getstudent (long ID );
/**
* Other service methods
**/
}
Interface teacherservice
{
Public void saveteacher (teacher tea );
Public void deleteteacher (long ID );
Public void updateteacher (teacher tea );
Public Teacher getteacher (long ID );
/**
* Other service methods
**/
}
Interface courseservice
{
Public void savecourse (course C );
Public void deletecourse (long ID );
Public void updatecourse (course C );
Public Teacher getcourse (long ID );
/**
* Other service methods
**/
}
Write these two interfaces and create their implementation classes respectively, for example:
Public class studentdaoimpl implements studentdao;
Public class studentserviceimpl implements studentservice;
The methods in studentserviceimpl call the interface methods in studentdaoimpl.
The writing of other classes is similar.