Design of J2EE Dao layer and business logic layer

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.